【发布时间】:2020-03-20 11:28:25
【问题描述】:
我尝试在 Weblogic 12.2.1.3.0 上部署一个 ear 文件两次。应用程序与上下文根的期望相同。
他们有:
- 相同的 JPA 模型
- 相同的persistance.xml(具有相同的持久性单元名称)
- 当我部署“第二只”耳朵并尝试从第一个耳朵访问数据库时,我收到一个
java.lang.ClassCastException: com.myApplication.models.entityOne 无法转换为 com.myApplication.models.entityOne
好像第一只耳朵用的是自己的模型,第二只耳朵的EntityManager。
我的 ear 文件的结构是这样的:
/
- lib
- jar-with-my-models.jar
- jar-with-persistance.jar
Persistence.xml 定义如下:
<persistence-unit name="my-persistance-unit" transaction-type="JTA">
<jar-file>jar-with-my-models.jar</jar-file>
</persistence-unit>
Weblogic.xml 定义如下:
<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>
我部署了两次 ear 文件,因为我想复制在 WebLogic 中并行部署期间收到的问题
编辑 1
我注意到@PersistenceContext 注入的实体管理器在应用程序之间是相同的
第一个应用程序的请求em:com.sun.proxy.$Proxy523
请求第二个应用程序em: com.sun.proxy.$Proxy523
【问题讨论】:
标签: java jpa weblogic eclipselink java-ee-7