Closed rxue closed 1 year ago
Hibernate version to use: 4.3.11.Final
Reference for an NPE: https://stackoverflow.com/questions/7181673/createentitymanager-throws-java-lang-nullpointerexception-at-org-hibernate-engin
Still encountered error with cause when running mvn clean -Parq-glassfish-embedded test
Caused by: org.hibernate.engine.jndi.JndiException: Unable to lookup JNDI name [java:jboss/TransactionManager]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:117)
at org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform.locateTransactionManager(JBossAppServerJtaPlatform.java:55)
... 129 more
Analysis: the property hibernate.transaction.jta.platform
was assigned with wrong value
Conclusion
The Hibernate 4 didn't fully implement the JPA 2.1, e.g. those javax.persistence.xxx
properties such as javax.persistence.schema-generation.database.action
are not supported by Hibernate 4. Moreover, Hibernate is not used as the default JPA implementation Glassfish server, so configuration on using the Hiberation in Glassfish is not out-of-the-box and difficult
=>
strategically it is not a wise choice to use JPA with Hibernate implementation in Glassfish server. Wildfly instead might be a better choice since it support Hibernate out-of-the-box
As per the last error in issue#46
I tried to comment out the
hibernate-validator
dependency from thepom.xml
>dependencies
section, and then add this same dependency to profilearq-glassfish-embedded
with version6.0.22.Final
, which corresponds to the source code of Wildfly, then this error was resolved.However, according to my understanding, the logic of Maven is that the priority of the dependency inside
dependencies
element is in any case always higher than that of the same dependeny inside the profile 'sdependencies
element. This means that whenever the dependency, e.g. thehibernate-vaidator
is assigned in thedependencies
element, the same dependencyhibernate-validator
with another version added insideprofiler
>dependency
is void.=> It is compulsory to use the
hibernate-validator
depdency in thedependencies
element, and the version ofhibernate-validator
should be as it it, i.e. theprovided
. This can be retrieved by means ofmvn dependency:tree
and it is version5.1.3.Final
=> TODO : revert the current committed code a few step back and keep using the
provided
version,5.1.3.Final
ofhibernate-validator
. This also means that the correspondinghibernate-core
probably should be with an older version. NOTE! the version in the Wildfly source code is not relevant to this issue since I am using the embedded Glassfish in integration test