I'm trying to deploy an ear file twice on Weblogic 12.2.1.3.0. The applications are the same expect for context-root.
They have:
java.lang.ClassCastException: com.myApplication.models.entityOne cannot be cast to com.myApplication.models.entityOne
It seems that the first ear uses its own models but the EntityManager of second one ear.
Structure of my ear file is something like that:
/
- lib
- jar-with-my-models.jar
- jar-with-persistance.jar
Persistence.xml is defined as following:
<persistence-unit name="my-persistance-unit" transaction-type="JTA">
<jar-file>jar-with-my-models.jar</jar-file>
</persistence-unit>
Weblogic.xml is defined as follows:
<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/90">
<context-root>/console</context-root>
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<prefer-application-packages>
<package-name>antlr.*</package-name>
</prefer-application-packages>
</container-descriptor>
<session-descriptor>
<persistent-store-type>memory</persistent-store-type>
<sharing-enabled>true</sharing-enabled>
</session-descriptor>
</weblogic-web-app>
I'm deploying twice my ear file because I want to replicate an issue that I received during parallel deploy in WebLogic
EDIT 1
I noticed that entity manager inject by @PersistenceContext is the same between applications
Request on first application em: com.sun.proxy.$Proxy523
Request on second application em: com.sun.proxy.$Proxy523
probably there is a problem between Weblogic class loader if you deploy two applications on the same Weblogic Managed Server (if they share same beans - same package+class name).
I suggest you to create differents Weblogic Managed Servers for differents applications. In this way you won't have problem.