0

I'm installing a open source project on jee8 security example in wildfly 10, because its working only in glassfish. My project source is there:

https://github.com/robyp1/javaee8sec/

You can find configurations files and modules in src/jboss:

https://github.com/robyp1/javaee8sec/tree/master/src/main/jboss

I use cargo maven 2 plugin to download a wildfly10 instance to install in my cargo/target directory. I install hsqldb and eclipselink as modules. Wildfly start correctly with EclipseLink jap persistence provider instead the ibernate default provider, but It seems my persistence.xml doesn't make changes.

Why?

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="soteria" transaction-type="JTA">
        <jta-data-source>java:jboss/jdbc/soteria</jta-data-source>
        <!-- only for jboss -->
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <!-- TODO: parameterize this -->
        <properties>
            <property name="eclipselink.logging.level.sql" value="FINE"/>
            <property name="eclipselink.logging.parameters" value="true"/>
            <property name="eclipselink.logging.timestamp" value="true"/>
            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>

        </properties>
    </persistence-unit>
</persistence>

I set wildfly log to DEBUG:

[INFO] [talledLocalContainer] 14:56:16,869 INFO  [org.jboss.as.jpa] (MSC service thread 1-6) WFLYJPA0002: Read persistence.xml for soteria
[INFO] [talledLocalContainer] 14:56:16,884 DEBUG [io.undertow.session] (ServerService Thread Pool -- 65) Setting default session timeout to 1800
[INFO] [talledLocalContainer] 14:56:16,894 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) persistence unit search for unitName=null referenced from class=id.swhp.javaee.soteria.business.account.boundary.AccountStore (annotation=@PersistenceContext)
[INFO] [talledLocalContainer] 14:56:16,901 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) persistence unit search for unitName=null referenced from class=id.swhp.javaee.soteria.business.security.boundary.TokenScheduler (annotation=@PersistenceContext)
[INFO] [talledLocalContainer] 14:56:16,901 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) persistence unit search for unitName=null referenced from class=id.swhp.javaee.soteria.business.security.boundary.TokenStore (annotation=@PersistenceContext)
[INFO] [talledLocalContainer] 14:56:16,901 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) added javax.persistence.api:main dependency to javaee-soteria.war
[INFO] [talledLocalContainer] 14:56:16,901 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) added org.jboss.as.jpa:main dependency to javaee-soteria.war
[INFO] [talledLocalContainer] 14:56:16,901 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) added org.jboss.as.jpa.spi:main dependency to javaee-soteria.war
[INFO] [talledLocalContainer] 14:56:16,901 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) added org.javassist:main dependency to javaee-soteria.war
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) added org.eclipse.persistence:main dependency to javaee-soteria.war
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) soteria is configured to use persistence provider 'org.eclipse.persistence.jpa.PersistenceProvider', adding an optional dependency on module 'org.eclipse.persistence'
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component id.swhp.javaee.soteria.business.account.boundary.AccountStore
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component javax.servlet.jsp.jstl.tlv.ScriptFreeTLV
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component id.swhp.javaee.soteria.business.security.control.PbkdfGenerator
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component javax.faces.webapp.FacetTag
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component org.omnifaces.ApplicationListener
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component id.swhp.javaee.soteria.business.security.control.SHAGenerator
[INFO] [talledLocalContainer] 14:56:16,902 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component javax.faces.webapp.FacesServlet
[INFO] [talledLocalContainer] 14:56:16,903 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component id.swhp.javaee.soteria.application.servlet.AuthenticationFilter
[INFO] [talledLocalContainer] 14:56:16,903 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component com.sun.faces.config.ConfigureListener
[INFO] [talledLocalContainer] 14:56:16,903 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component id.swhp.javaee.soteria.business.security.boundary.TokenStore
[INFO] [talledLocalContainer] 14:56:16,903 DEBUG [org.jboss.as.jpa] (MSC service thread 1-6) Adding dependency on PU service service jboss.persistenceunit."javaee-soteria.war#soteria" for component id.swhp.javaee.soteria.business.security.boundary.TokenScheduler
[INFO] [talledLocalContainer] 14:56:16,904 DEBUG [org.jboss.as.server.deployment] (MSC service thread 1-6) Creating module: deployment.javaee-soteria.war:main
[INFO] [talledLocalContainer] 14:56:16,904 DEBUG [org.jboss.as.server.deployment] (MSC service thread 1-6) Adding resource "/C:/Progetti/altri/javaee-soteria-master/target/cargo/configurations/wildfly10x/content/javaee-soteria.war" to module deployment.javaee-soteria.war:main
[INFO] [talledLocalContainer] 14:56:16,906 DEBUG [org.jboss.as.server.deployment] (MSC service thread 1-6) Adding resource "/C:/Progetti/altri/javaee-soteria-master/target/cargo/configurations/wildfly10x/content/javaee-soteria.war/WEB-INF/classes" to module deployment.javaee-soteria.war:main
[INFO] [talledLocalContainer] 14:56:16,906 DEBUG [org.jboss.as.server.deployment] (MSC service thread 1-6) Adding resource "/C:/Progetti/altri/javaee-soteria-master/target/cargo/configurations/wildfly10x/content/javaee-soteria.war/WEB-INF/lib/hsqldb-2.4.0.jar" to module deployment.javaee-soteria.war:main
[INFO] [talledLocalContainer] 14:56:16,910 DEBUG [org.jboss.as.server.deployment] (MSC service thread 1-6) Adding resource "/C:/Progetti/altri/javaee-soteria-master/target/cargo/configurations/wildfly10x/content/javaee-soteria.war/WEB-INF/lib/javax.security.enterprise-1.0.jar" to module deployment.javaee-soteria.war:main
[INFO] [talledLocalContainer] 14:56:16,919 DEBUG [io.undertow.request] (default I/O-3) Matched default handler path /cargocpc/index.html
[INFO] [talledLocalContainer] 14:56:16,927 DEBUG [org.jboss.as.server.deployment] (MSC service thread 1-6) Adding resource "/C:/Progetti/altri/javaee-soteria-master/target/cargo/configurations/wildfly10x/content/javaee-soteria.war/WEB-INF/lib/javax.security.enterprise-api-1.1-b01-20170827.084736-2.jar" to module deployment.javaee-soteria.war:main
[INFO] [talledLocalContainer] 14:56:16,938 DEBUG [org.jboss.as.server.deployment] (MSC service thread 1-6) Adding resource

and

[INFO] [talledLocalContainer] 14:56:17,820 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The access type for the persistent class [class id.swhp.javaee.soteria.business.security.entity.Token] is set to [FIELD].
[INFO] [talledLocalContainer] 14:56:17,843 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The target entity (reference) class for the many to one mapping element [field account] is being defaulted to: class id.swhp.javaee.soteria.business.account.entity.Account.
[INFO] [talledLocalContainer] 14:56:17,843 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The access type for the persistent class [class id.swhp.javaee.soteria.business.account.entity.Account] is set to [FIELD].
[INFO] [talledLocalContainer] 14:56:17,849 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The target entity (reference) class for the one to many mapping element [field tokens] is being defaulted to: class id.swhp.javaee.soteria.business.security.entity.Token.
[INFO] [talledLocalContainer] 14:56:17,850 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The alias name for the entity class [class id.swhp.javaee.soteria.business.security.entity.Token] is being defaulted to: Token.
[INFO] [talledLocalContainer] 14:56:17,860 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The column name for element [created] is being defaulted to: CREATED.
[INFO] [talledLocalContainer] 14:56:17,861 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The column name for element [description] is being defaulted to: DESCRIPTION.
[INFO] [talledLocalContainer] 14:56:17,861 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The column name for element [expiration] is being defaulted to: EXPIRATION.
[INFO] [talledLocalContainer] 14:56:17,861 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The column name for element [id] is being defaulted to: ID.
[INFO] [talledLocalContainer] 14:56:17,865 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The alias name for the entity class [class id.swhp.javaee.soteria.business.account.entity.Account] is being defaulted to: Account.
[INFO] [talledLocalContainer] 14:56:17,865 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The column name for element [password] is being defaulted to: PASSWORD.
[INFO] [talledLocalContainer] 14:56:17,865 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The column name for element [id] is being defaulted to: ID.
[INFO] [talledLocalContainer] 14:56:17,865 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The column name for element [email] is being defaulted to: EMAIL.
[INFO] [talledLocalContainer] 14:56:17,865 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The column name for element [username] is being defaulted to: USERNAME.
[INFO] [talledLocalContainer] 14:56:17,876 INFO  [org.eclipse.persistence.metadata] (ServerService Thread Pool -- 65) The primary key column name for the mapping element [field account] is being defaulted to: ID.
[INFO] [talledLocalContainer] 14:56:18,069 DEBUG [org.jboss.as.ejb3] (MSC service thread 1-3) Installing timer service for component TokenScheduler
[INFO] [talledLocalContainer] 14:56:18,086 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0003: Processing weld deployment javaee-soteria.war
[INFO] [talledLocalContainer] 14:56:18,125 DEBUG [org.jboss.weld.deployer] (MSC service thread 1-3) Discovered EXPLICIT BeanDeploymentArchive (javaee-soteria.war/WEB-INF/lib/omnifaces-2.6.4.jar)
[INFO] [talledLocalContainer] 14:56:18,126 DEBUG [org.jboss.weld.deployer] (MSC service thread 1-3) Discovered EXPLICIT BeanDeploymentArchive (javaee-soteria.war/WEB-INF/classes)
[INFO] [talledLocalContainer] 14:56:18,181 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-3) HV000001: Hibernate Validator 5.2.4.Final
[INFO] [talledLocalContainer] 14:56:18,205 DEBUG [org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-3) Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
[INFO] [talledLocalContainer] 14:56:18,206 DEBUG [org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-3) Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.

You can find all the log server here: https://github.com/robyp1/javaee8sec/blob/master/server_20180202.log or more readable format: https://raw.githubusercontent.com/robyp1/javaee8sec/master/server_20180202.log

What's wng?

Thank you very much

Roberto

robyp7
  • 481
  • 2
  • 7
  • 25
  • Try logging at Finest or ALL level instead, but have you accessed the persistence unit, or are you just deploying and then checking if the database was created? EclipseLink will lazily deploy persistence units, avoiding database access for persistence units that might be on the class path but not intended to be used, delaying actual deployment of them until they are first accessed. You can change this behaviour by setting the eclipselink.deploy-on-startup persistence property to true https://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_deploy_on_startup.htm – Chris Feb 02 '18 at 15:49
  • WildFly is Java EE 7 compliant so you might want to keep that in mind. – James R. Perkins Feb 05 '18 at 01:14

2 Answers2

0

WildFly uses Hiberate as JPA provider not EclipseLink!

So you have to set the property hibernate.hbm2ddl.auto like this

<property name="hibernate.hbm2ddl.auto" value="update"/>

Or you could use the JPA standard property javax.persistence.schema-generation.database.action

<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>

This would be portable and independent of the JPA implementation.

You find all the options in the Hibernate documentation:

http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#configurations-hbmddl

Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82
  • It ships with Hibernate, but you should be able to use any JPA provider you want. – Chris Feb 02 '18 at 15:45
  • 1
    Sure but why do you want to do this? You will not find many devs in the community who can help you with that configuration. Additionally all docs from RedHat are based on Hibernate. – Simon Martinelli Feb 02 '18 at 17:17
  • The idea of having specs like JPA is so that providers can be swapped out. This doesn't mean it's a good idea to override the default JPA provider shipped with an application server. From my experience, this usually leads to more headaches. IMO @SimonMartinelli has given good advice here; it is likely to be easier to make sure ***user*** code can run on a different JPA implementation rather than trying to mess around with the components WildFly ships with. – Mike Feb 02 '18 at 17:56
  • The issue is with a simple flag in the persistence properties. Swapping out providers is akin to someone having a problem with the gas light coming on and saying the should switch cars to a Ford. They accepted the answer though, so to each their own, but there are many reasons to continue with a different JPA provider that you've been using on a different deployment, as providers still have a lot of unique nuances that the app might be tied to. Switching providers is not, and should not be that difficult unless the server has done something wrong. – Chris Feb 02 '18 at 18:49
  • 1
    In my experience switching a provider is a bad idea because this configuration is not tested by anyone. So you are responsible for any problems that will arise when you are using this configuration. Also there is no upgrade path if you are doing that and you always have to retest your configuration with every new release of the app server. So my advice. Don't do that! – Simon Martinelli Feb 03 '18 at 11:23
  • In my experience, you can't rely on anyone else to test your configuration anyway. Any change in the server needs to be retested, and if you are using the default JPA provider included, it too might have changed. A simple provider fix included in the latest server patches can have an impact on your application, causing issues should you need to quickly uptake a server fix. – Chris Feb 05 '18 at 14:21
0

It is possible to use EclipseLink on Wildfly and this is documented in the reference guide. In simple terms you need to add eclipse.jar as a module then set a property so the following entry appears in standalone.xml:

    <property name="eclipselink.archive.factory" value="org.jipijapa.eclipselink.JBossArchiveFactoryImpl"/>