Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Weblogic 12c-部署一个ear两次_Java_Jpa_Weblogic_Eclipselink_Java Ee 7 - Fatal编程技术网

Java Weblogic 12c-部署一个ear两次

Java Weblogic 12c-部署一个ear两次,java,jpa,weblogic,eclipselink,java-ee-7,Java,Jpa,Weblogic,Eclipselink,Java Ee 7,我试图在Weblogic 12.2.1.3.0上两次部署ear文件。这些应用程序与上下文根的应用程序相同 它们有: 相同的JPA型号 相同persistence.xml(具有相同的持久性单元名称) 当我部署“第二个”ear并尝试从第一个ear访问DB时,我收到一个 java.lang.ClassCastException:com.myApplication.models.entityOne 无法强制转换为com.myApplication.models.entityOne 第一只耳朵似乎使用了自

我试图在Weblogic 12.2.1.3.0上两次部署ear文件。这些应用程序与上下文根的应用程序相同

它们有:

  • 相同的JPA型号
  • 相同persistence.xml(具有相同的持久性单元名称)
  • 当我部署“第二个”ear并尝试从第一个ear访问DB时,我收到一个
  • java.lang.ClassCastException:com.myApplication.models.entityOne 无法强制转换为com.myApplication.models.entityOne

    第一只耳朵似乎使用了自己的模型,而第二只耳朵则使用了整个管理器

    我的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>
    
    
    jar-with-my-models.jar
    
    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>
    
    
    /控制台
    真的
    假的
    antlr*
    记忆
    真的
    
    我部署了两次ear文件,因为我想复制在WebLogic中并行部署期间收到的问题

    编辑1

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

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


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

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

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