我在jboss服务器中运行了一个应用程序,并且实际上正在使用hibernate-jpa-2.0,当我尝试在Weblogic上运行该应用程序时,我从eclipselink中看到有关JPA批注的错误。我认为在这种情况下有两个选择,将我的应用程序更改为eclipselink或在weblogic中使用休眠模式。问题是,如何在我的weblogic-application.xml / weblogic.xml中声明使用休眠而不是eclipselink。这个有可能 ?发生的错误如下:
替换为缺少的类Exception [EclipseLink-7298](Eclipse 持久性服务-2.6.5.v20170607-b3d05bd)- org.eclipse.persistence.exceptions.ValidationException异常 说明:来自嵌入式ID类[class]的映射[associado] br.com.project.web.model.associate.pk.AssociateMaintainPK]是 此类的无效映射。使用的可嵌入类 带有嵌入式ID规范(属性[.AssociateMaintainPK] 从来源[类 br.com.project.web.model.associate.AssociateMaintain])可以 仅包含基本映射。删除非基本映射或 更改要嵌入的源上的嵌入ID规范。
答案 0 :(得分:0)
您将需要从weblogic部署描述符(如果捆绑包为war
的weblogic.xml或ear
的weblogic-application.xml)中引用休眠库。如果与同一Weblogic实例上部署的多个应用程序一起使用,则可以将与您的应用程序位于同一位置的库或作为一组共享库来部署(这是我使用的解决方案)。这样,WLS将使用引用的库而不是与weblogic捆绑在一起的默认实现(EclipseLink for JPA api)。
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.8/weblogic-web-app.xsd">
... config stuff
<!-- hibernate orm -->
<library-ref>
<library-name>hibernate-core</library-name>
</library-ref>
<library-ref>
<library-name>hibernate-entitymanager</library-name>
</library-ref>
<library-ref>
<library-name>hibernate-envers</library-name>
</library-ref>
<library-ref>
<library-name>hibernate-jpa-2.1-api</library-name>
</library-ref>
<!-- hibernate orm deps -->
<library-ref>
<library-name>dom4j</library-name>
</library-ref>
<library-ref>
<library-name>hibernate-commons-annotations</library-name>
</library-ref>
<library-ref>
<library-name>jboss-logging</library-name>
</library-ref>
<library-ref>
<library-name>jboss-logging-annotations</library-name>
</library-ref>
<library-ref>
<library-name>jandex</library-name>
</library-ref>
<library-ref>
<library-name>javassist</library-name>
</library-ref>