HHH-11546 suggests Netweaver support for hibernate >=5.2, but how?

We ported from Hibernate 3.x to 5.2, as it promised SAP Netweaver 7.5 support due to https://hibernate.atlassian.net/browse/HHH-11546 .
SAP Netweaver is a JPA 1.0 or JPA 2.0 (with some tricks) compatible EE5 application server, not JPA 2.1.

We are not using JPA at all but plain hibernate calls. Our application is working fine in Widlfy, but with setting
“SapNetWeaver” as hibernate.transaction.jta.platform
and deplyoying to SAP Netweaver 7.5 patchlevel 16 we get

caused by: java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
at org.hibernate.internal.CacheImpl.(CacheImpl.java:71)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:59)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:80)
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:243)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)

where hibernate ends up looking for some methods not available in JPA 1.0 (see https://forum.hibernate.org/viewtopic.php?p=2490425 )

So how was support for Netweaver tested in Hibernate 5.X? Was there any testsuite? Netweaver is a JPA 2.0 App Server, how to make a hibernate standalone (non-JPA) approach work nevertheless, is it possible?
Otherwise HHH-11546 should be marked as not working as it is not supporting netweaver, is it?

Thanks a lot for your input,

Lars

You should be asking this question the people from Netweaver. As far as I can see from the issue, the fix was provided by a community member. Not sure how good this was tested.

Anyway, the issue is that you have a JPA 1.0 JAR on the classpath somehow.

But HHH-11546 ended up in Hibernate Core suggesting everyone Netweaver is supported since 5.2.x where it most probably stopped working forever since hibernate switched to JPA 2.1 which Netweaver doesn’t support?
So if there is actually no support for Netweaver all code for it should be removed from core sources I would say. Unless there is a way to at least make it work with referring to org.hibernate.* classes only instead of actually using JPA (which is actually my goal but not sure how to get it done due to the exception mentioned above).

You have to somehow exclude the JPA 1.0 JARs from being visible to the application. I don’t know Netweaver, which is why I proposed you should ask someone from the Netweaver community, but generally an App Server has some directory where it stores JARs. You could try to just replace the jpa-1.0 JAR with the JPA 2.1 one. Some App Servers also have the option to specify in which order a deployment class loader should search for classes i.e. a PARENT_LAST strategy is something that might be of interest to you, as you could provide your own JARs in that case.

Thanks for these hints. I was assuming that it might not enough to have hibernate classes to be found first by classloader as Netweaver 7.5 is limited to JPA 2.0 .
But as we are not using JPA but hibernate classes directly that is not the case and we were able to make it work. Here are the instructions for whomever might be interested (hibernate 5.2):

Create a folder “/tmp/hibernate52” on the operating system of netweaver server containing these jars:
antlr-2.7.7.jar
hibernate-core-5.2.17.Final.jar
jboss-logging-3.3.1.Final.jar
xml-apis-1.4.01.jar
classmate-1.3.0.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
jboss-transaction-api_1.2_spec-1.0.1.Final.jar
dom4j-1.6.1.jar
jandex-2.0.3.Final.jar
validation-api-1.1.0.Final.jar
hibernate-commons-annotations-5.0.1.Final.jar
javassist-3.22.0-GA.jar
xercesImpl-2.11.0.jar

Then log in as administrator using netweaver telnet admin console and issue these commands:

add orpersistence
deploy_provider /tmp/hibernate52 -vendor org.hibernate -name hibernate52

Then change META-INF\application-j2ee-engine.xml to use this library:

<library-loader>
		<reference>
			<reference-target provider-name="org.hibernate" target-type="library">hibernate52</reference-target>
		</reference>
</library-loader>

Thanks again for hinting us in the right direction,

Lars

1 Like