-
1. Re: my JPA persistence is ignoring my @Id annotation
myarbrou Feb 12, 2016 2:01 PM (in response to myarbrou)They guys over at access.redhat.com helped me figure out what was wrong. The @Id annotation was getting ignored because no-one was looking for it when the class was loaded up.
Adding the persistence.api and hibernate dependencies into my *objects module fixed it.
-
2. Re: my JPA persistence is ignoring my @Id annotation
smarlow Feb 12, 2016 2:38 PM (in response to myarbrou)I tried deploying your test against WildFly 10 and saw a deployment failure which I attached as scottlog.zip. During application deployment, Hibernate 5.0, is rewriting the entity classes which is a problem, because the entity classes are not part of the application classloader (since they are really part of a static module). So, the attempt to rewrite the static module classes, from the application, is not working. I don't expect that Hibernate will be able to redefine the static module (com.integration.jpaTest-objects) classes as they probably have already been loaded.
Scott
-
scottlog.zip 14.3 KB
-
-
3. Re: my JPA persistence is ignoring my @Id annotation
smarlow Feb 12, 2016 2:55 PM (in response to smarlow)Hmm, looks like I didn't add a dependency on the org.hibernate module, that is why I got the deployment error.
-
4. Re: my JPA persistence is ignoring my @Id annotation
smarlow Feb 12, 2016 3:06 PM (in response to smarlow)After adding the Hibernate module to the static module, deployment seems to be improved
15:04:12,627 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "jpaTest.war" (runtime-name: "jpaTest.war")
15:04:12,643 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) WFLYDS0013: Started FileSystemDeploymentService for directory /home/smarlow/work/wildfly/dist/target/wildfly-10.1.0.Final-SNAPSHOT/standalone/deployments
15:04:12,791 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-1) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.1.Final
15:04:12,795 INFO [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBossWS 5.1.3.Final (Apache CXF 3.1.4)
15:04:12,882 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
15:04:13,143 INFO [org.jboss.as.jpa] (MSC service thread 1-6) WFLYJPA0002: Read persistence.xml for jboss
15:04:13,231 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 58) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'jpaTest.war#jboss'
15:04:13,248 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 58) HHH000204: Processing PersistenceUnitInfo [
name: jboss
...]
15:04:13,261 INFO [org.jboss.weld.deployer] (MSC service thread 1-8) WFLYWELD0003: Processing weld deployment jpaTest.war
15:04:13,498 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-8) HV000001: Hibernate Validator 5.2.3.Final
15:04:13,501 INFO [org.hibernate.Version] (ServerService Thread Pool -- 58) HHH000412: Hibernate Core {5.0.7.Final}
15:04:13,503 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 58) HHH000206: hibernate.properties not found
15:04:13,505 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 58) HHH000021: Bytecode provider name : javassist
15:04:13,543 INFO [org.hibernate.orm.deprecation] (ServerService Thread Pool -- 58) HHH90000001: Found usage of deprecated setting for specifying Scanner [hibernate.ejb.resource_scanner]; use [hibernate.archive.scanner] instead
15:04:13,551 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 58) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
15:04:13,710 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0006: Starting Services for CDI deployment: jpaTest.war
15:04:13,737 INFO [org.jboss.weld.Version] (MSC service thread 1-2) WELD-000900: 2.3.2 (Final)
15:04:13,765 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0009: Starting weld service for deployment jpaTest.war
15:04:13,890 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 58) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'jpaTest.war#jboss'
15:04:14,041 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 58) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
15:04:14,045 WARN [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 58) HHH000431: Unable to determine H2 database version, certain features may not work
15:04:14,073 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 58) Envers integration enabled? : true
15:04:14,384 INFO [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (ServerService Thread Pool -- 58) HHH000397: Using ASTQueryTranslatorFactory
15:04:14,961 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 59) WFLYUT0021: Registered web context: /jpaTest
15:04:14,980 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "jpaTest.war" (runtime-name : "jpaTest.war")
15:04:15,057 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
15:04:15,057 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
15:04:15,058 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final-SNAPSHOT (WildFly Core 2.1.0.CR2) started in 4301ms - Started 362 of 651 services (382 services are lazy, passive or on-demand)
-
5. Re: my JPA persistence is ignoring my @Id annotation
myarbrou Feb 12, 2016 3:15 PM (in response to smarlow)hmm, yeah i don't know why Wildfly has a problem after adding just hibernate. EAP 6.4.6 is all happy go lucky with just org.hibernate and javax.persistence.api
If I don't explicitly add javassist as a dependency i get the same error
ClassNotFoundException: javassist.util.proxy.ProxyObject
but adding it (attached the new module.xml) makes it work correctly.
What I don't quite understand is why it needs that dependency in my *objects modules since the org.hibernate module already depends on it.
-
module.xml.zip 365 bytes
-
-
6. Re: my JPA persistence is ignoring my @Id annotation
smarlow Feb 12, 2016 3:50 PM (in response to myarbrou)In WildFly 10, Hibernate changed to use Javassist for creating a proxy for lazy fetched entities. In earlier releases, Hibernate did not.
Below is what I hacked together for the static module for trying your test:
<module xmlns="urn:jboss:module:1.3" name="com.integration.jpaTest-objects">
<resources>
<resource-root path="jpaTest-objects-0.0.1-SNAPSHOT.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.annotation.api"/>
<module name="javax.enterprise.api"/>
<module name="javax.persistence.api"/>
<module name="javax.transaction.api"/>
<module name="javax.validation.api"/>
<module name="javax.xml.bind.api"/>
<module name="org.javassist"/>
<module name="org.hibernate"/>
</dependencies>
</module>
Its been about 4+ years since I have heard from other community users trying to share persistence unit/entities across different deployments. I found a jira issue that represented some possible extensions to allow that but it was never a priority (the interested community users didn't finish their patch either). The related jira is WFLY-1105.
Scott
-
7. Re: my JPA persistence is ignoring my @Id annotation
smarlow Feb 15, 2016 8:55 AM (in response to smarlow)sebersole are there any (Hibernate ORM) reasons why separate application deployments shouldn't share entity classes via a shared classloader? In this post, we are talking about several WildFly client deployments that contain persistence units but all of the entity classes are in a static WildFly module, that several applications share.
I'm thinking that they need to avoid entity class enhancing that is specific to a particular application. For example, if two applications are deployed that enhance entity classes in different ways. If application A includes hibernate.enhancer.enableDirtyTracking=true and application B include hibernate.enhancer.enableDirtyTracking=false. The first deployment on the app server will determine how entity classes are enhanced.
Thanks,
Scott