Weblogic 12c-部署两次耳朵

问题描述 投票:1回答:1

我正在尝试在Weblogic 12.2.1.3.0上两次部署一个耳朵文件。这些应用程序对于上下文根是相同的期望。

他们有:

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

java.lang.ClassCastException:com.myApplication.models.entityOne无法转换为com.myApplication.models.entityOne

[似乎第一只耳朵使用了自己的模型,但是第二只耳朵使用了EntityManager。

我的耳朵锉的结构是这样的:

/
  - 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>

我要重复两次耳朵文件,因为我想复制在WebLogic中并行部署期间收到的问题

编辑1

我注意到@PersistenceContext注入的实体管理器在应用程序之间是相同的

对第一个应用程序的请求em:com.sun.proxy。$ Proxy523

第二个应用程序上的请求em:com.sun.proxy。$ Proxy523

java jpa weblogic eclipselink java-ee-7
1个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.