Has anyone been able to use Hibernate 4.3 in an application running on NetWeaver AS Java 7.3. I followed the example here to use the Heavy Resources class loader by creating a Hibernate application library container project which contains the following jar files:
antlr-2.7.7.jar
dom4j-1.6.1.jar
hibernate-commons-annotations-4.0.5.Final.jar
hibernate-core-4.3.6.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
xml-apis-1.0.b2.jar
I then deploy the Hibernate.ear
and I add it as a reference in my apps application-j2ee-engine.xml
file:
<reference reference-type="hard">
<reference-target provider-name="sap.com" target-type="application">Hibernate</reference-target>
</reference>
My application can find the hibernate jars and use them but I’m getting the following error:
java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey
This happens when older version of the JPA API are used by Hibernate. Hibernate 4 uses the 2.1 version of the JPA API and so needs the classes in the hibernate-jpa-2.1-api-1.0.0.Final.jar
file instead of the ones provided by NetWeaver which are JPA 1.0.
I believe that the app is getting the 1.0 version of the JPA classes because the Heavy Resources classloader is delegating to its parent class loader first when looking for the javax.persistence.*
classes and so its finding the 1.0 JPA API classes there and not getting them from the JAR defined in the Hibernate.ear
application like I was hoping it would.
Is there any way to specify that the Heavy Resources class loader becomes child first type class loader? Or has anyone found another way to use Hibernate 4.3 in NetWeaver 7.3?
I'm not familiar with NetWeaver at all so any guidance would be appreciated.
Thanks
I'm an SAP NetWeaver consultant, and I hate to bring the bad news: since SAP NetWeaver 7.3 is based on Java EE 5, it currently only supports JPA 1.0...
There is a lively topic about this very subject on SCN stemming back from 2011 (http://scn.sap.com/thread/2028916) and still being updated as of today (it's well worth the read of all the comments!)
If I may quote from a post by Rolf Paulsen on Jan 15 2014 in that topic:
Finally, the interesting wrap-up of 4 years of SAP statements:
Dec 14, 2009: "With the availability of Java EE6 it now is time to introduce it to our development, but there are no plans available (one week after release of the standard) that would tell us when this standard will be part of the product."
Apr 4, 2012: "It is also planned to bring the features of Neo to the on premise environment afterwards. When this will happen I cannot answer."
Jan 14, 2014: "The implementation is under development and is planned to see the light in the first half of this year." "That's the plugin with web profile. From that time on we will harmonize this with the Cloud updates."Not too fast. SAP plugs some Tomcat EE 6 from the SAP Cloud into the legacy Java EE 5 NetWeaver Java? And only this plug-in will be harmonized with the SAP Cloud (that is good enough with Java EE 6 Web Profile) and support Java EE 6 features?
Sounds like Tobias' answer "Never" to the question "When will SAP AS Java EE 6/7 see the light" remains correct. SAP NetWeaver AS Java itself will stay on Java EE 5 forever.