开发者

Unknown entity exception when Entities are in multiple jars

开发者 https://www.devze.com 2023-02-10 07:56 出处:网络
I am getting this exception while running maven test. ERROR - Application could not be deployed:classpath.ear

I am getting this exception while running maven test.

ERROR - Application could not be deployed: classpath.ear org.apache.openejb.OpenEJBException: Creating application failed: classpath.ear: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on net.atos.wlp.cns.core.record.ClearingRecord.clearingBatch references an unknown entity: net.atos.wlp.cns.core.batch.ClearingBatch: @OneToOne or @ManyToOne on net.atos.wlp.cns.core.record.ClearingRecord.clearingBatch references an unknown entity: net.atos.wlp.cns.core.batch.ClearingBatch 开发者_如何学Go at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:658)

I tried with & option in persistence.xml file, still the error exists.

Please help me out if anyone face the similar issue.


I had a similar problem - by having my entities spread across multiple jar files. I also used maven...

at first I was able to get it to run by extracting the jar file into classes. In the end the solution was to specify the jar files of the dependency in the persitence.xml:

    ...
    <persistence-unit ...
    <provider>...</provider>
    <jar-file>WEB-INF/lib/my-jar-file-0.0.1-SNAPSHOT.jar</jar-file>
    <properties>
    ...


If you have two classes, with the same name and same package in the same classloader, the result is a non-consistent behavior (in the sense that it may behave differently based on the combination of JVM/Application Server you choose). You may want to do some research on what would be the expected behavior for your JVM / Application Server, but the ideal solution is not to have the same class (in the same package) in two jars. If you have to do that, I'd say that you have an architecture problem that must be solved ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消