Topic
  • 2 replies
  • Latest Post - ‏2011-02-08T23:02:30Z by brelph
brelph
brelph
2 Posts

Pinned topic Hibernate 3.5.6.final

‏2011-02-08T20:40:42Z |
Hi

I would like to deploy an application using hibernate 3.5.6.final as the jpa provider. I do NOT want to change any JPA settings/configuration in websphere, and instead package hibernate with my application. I also do NOT want to install the feature pack with jpa 2.0 functionality, instead I want to package a jpa 2.0 api jar with my application. Is this possible? I am currently receiving this stack trace:

2/8/11 14:38:18:597 CST 00000046 JPAPxmlInfo E CWWJP0018E: Incorrect syntax or error detected in the file:/opt/IBM/WebSphere/AppServer/profiles/Custom01/installedApps/ipvmgwxdev01Cell01/gwx-acl-webapp_war.ear/gwx-acl-webapp.war/WEB-INF/lib/gwx-acl-1.0.0.BUILD-SNAPSHOT.jar!/ file. The following associated error message occurred: java.lang.NoSuchMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:625)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at com.ibm.ws.jpa.management.JPAPUnitInfo.createEMFactory(JPAPUnitInfo.java:1484)
at com.ibm.ws.jpa.management.JPAPUnitInfo.createEntityManagerFactory(JPAPUnitInfo.java:1325)
at com.ibm.ws.jpa.management.JPAPxmlInfo.extractPersistenceUnits(JPAPxmlInfo.java:393)
at com.ibm.ws.jpa.management.JPAScopeInfo.processPersistenceUnit(JPAScopeInfo.java:140)
at com.ibm.ws.jpa.management.JPAApplInfo.processModulePUs(JPAApplInfo.java:169)
at com.ibm.ws.jpa.management.JPAComponentImpl.startingDeployedModule(JPAComponentImpl.java:878)
at com.ibm.ws.jpa.management.JPAComponentImpl.stateChanged(JPAComponentImpl.java:722)
Updated on 2011-02-08T23:02:30Z at 2011-02-08T23:02:30Z by brelph
  • leealber
    leealber
    19 Posts

    Re: Hibernate 3.5.6.final

    ‏2011-02-08T21:43:52Z  
    Mixed use of JPA 1 and 2 application in WAS 7 is a tricky business. It is mainly due to classloading resolution of different versions of JPA API.

    From your posted stack, it looks like you are using container managed persistence (I may be wrong) and the container tried to resolve the JPA 2.0 API but it can only use the 1.0 API that it loaded from the WAS installation.

    From what I understand, if you want to use WAS 7 without loading the JPA 2.0 FeP, you will need to package your JPA 2.0 API/provider in a certain fashion plus with some limitations:
    • package the JPA 2.0 API in a share library for your application and make sure to set the shared library's classloader to PARENT_LAST or use isolated mode.
    • package the Hibernate provider and its depending packages either in your application or an application shared library with PARENT_LAST or isolated classloader.
    • Only JSE mode access is allowed. I.e no container managed persistence/injection. You will have to use Persistence bootstrap class to obtain your emf and manage the emf/em lifecycle.

    Hope this help.

    Albert.
  • brelph
    brelph
    2 Posts

    Re: Hibernate 3.5.6.final

    ‏2011-02-08T23:02:30Z  
    • leealber
    • ‏2011-02-08T21:43:52Z
    Mixed use of JPA 1 and 2 application in WAS 7 is a tricky business. It is mainly due to classloading resolution of different versions of JPA API.

    From your posted stack, it looks like you are using container managed persistence (I may be wrong) and the container tried to resolve the JPA 2.0 API but it can only use the 1.0 API that it loaded from the WAS installation.

    From what I understand, if you want to use WAS 7 without loading the JPA 2.0 FeP, you will need to package your JPA 2.0 API/provider in a certain fashion plus with some limitations:
    • package the JPA 2.0 API in a share library for your application and make sure to set the shared library's classloader to PARENT_LAST or use isolated mode.
    • package the Hibernate provider and its depending packages either in your application or an application shared library with PARENT_LAST or isolated classloader.
    • Only JSE mode access is allowed. I.e no container managed persistence/injection. You will have to use Persistence bootstrap class to obtain your emf and manage the emf/em lifecycle.

    Hope this help.

    Albert.
    Thanks for your tips, I was able to solve my problem:

    • I was confused by the stack trace, because it indicated the WAS was parsing my persistence.xml ... but I actually use Spring to instantiate my emf. After searching around, I realized that J2EE 5 containers automatically find "META-INF/persistence.xml" - so i just renamed mine to "jpa-persistence.xml" and adjusted my Spring config.

    • After that, I was able to switch both the application(ear) and module(war) classloaders to PARENT_LAST, and my packaged jpa 2.0 api was picked up.

    Thanks again, hope others find this useful.

    FYI, the reason why I don't want to use JPA 2 feature pack in WAS is because it is not integrated into the CIM. The CIM was an exciting proposition in moving from 6.1 to 7. It is also a bit frustrating to have to do EXTRA work to deploy my same application on WAS 7 (WAS 6.1 accepted my application without any changes).