【问题标题】:Weblogic 12c - Deploy an ear twiceWeblogic 12c - 部署耳朵两次
【发布时间】:2020-03-20 11:28:25
【问题描述】:

我尝试在 Weblogic 12.2.1.3.0 上部署一个 ear 文件两次。应用程序与上下文根的期望相同。

他们有:

  1. 相同的 JPA 模型
  2. 相同的persistance.xml(具有相同的持久性单元名称)
  3. 当我部署“第二只”耳朵并尝试从第一个耳朵访问数据库时,我收到一个

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


    【解决方案1】:

    如果您在同一个 Weblogic 托管服务器上部署两个应用程序,Weblogic 类加载器之间可能会出现问题(如果它们共享相同的 bean - 相同的包+类名)。

    我建议您为不同的应用程序创建不同的 Weblogic 托管服务器。 这样就没有问题了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-13
      • 1970-01-01
      • 2017-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多