2
votes

I am using IBM Mobilefirst Platform foundation 7.0 development environment

I am trying to add library hibernate-jpa-2.1-api-1.0.0.Final.jar for one of module in my project is using this library.

when I add it to the build path MF gives me following error:

[WARNING ] Exception encountered during context initialization - cancelling refresh attempt
Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
[ERROR   ] FWLST0003E: ========= Failed starting project /MYAPP_Mobile [project MYAPP_Mobile]
Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
[ERROR   ] Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
[ERROR   ] MYAPP_Mobile: worklight///172.25.16.55: 2015-04-29T09:08:21.260Z: Error creating bean with name 'ssoExpiredLoginContextsCleanupTask' defined in URL [wsjar:file:/Users/admin/Documents/Development7.0/MYAPP/MobileFirstServerConfig/shared/resources/worklight-jee-library-7.0.0.jar!/conf/core.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of com/ibm/ws/classloading/internal/ThreadContextClassLoader) previously initiated loading for a different type with name "javax/persistence/FlushModeType"
3
Where are you adding this file in your project? Add reproduction steps. If you've placed this .jar file in a Java adapter's folder it should work. If you've placed it somewhere else it will cause problems with server-supplied .jar files used by the platform.Idan Adar

3 Answers

0
votes

You did not specify in the question where did you place this .jar file. That said, it is likely that you've added it to the runtime .war file.

This will for sure create a conflict, because MFP uses openJPA, and you're trying to add JPA...
Because OpenJPA is already uses and available, it is suggest then for you to use OpenJPA instead as it has the same purpose as Hibernate JPA.

0
votes

Where are you putting jar?

If you have multiple java adapters, referring to same jar file. you should add jar file in 'lib' folder of 'server'. If you need specific jar for single adapter, you should put jar into 'lib' folder of your java adapter. one point should be taken into notice that if same jar is present in both adapter and server's lib folder. jar from adapter will be taken for built.

0
votes

Got some good news regarding this issue. APAR PI59031 is now available that will address the issue of using Hibernate as the JPA implementation in an adapter. If you are using MobileFirst 7.0 or above, please upgrade to a fix level later than 2016-03-21 for MobileFirst 7.0 and 2016-04-02 for MobileFirst 7.1

If you're using the Developer Edition of Studio, fixes can be obtained from the Eclipse MarketPlace. If you're a licensed MobileFirst customer, fixes can be obtained from FixCentral.