Unknown entity exception when objects are in multiple jars

I get this exception while running the maven test.

ERROR - application could not be deployed: classpath.ear org.apache.openejb.OpenEJBException: Failed to create application: classpath.ear: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on net.atos.wlp.cns.core. record.ClearingRecord.clearingBatch refers to an unknown object: net.atos.wlp.cns.core.batch.ClearingBatch: @OneToOne or @ManyToOne on net.atos.wlp.cns.core.record.ClearingRecord.clearingBatch refers to an unknown object: net.atos.wlp.cns.core.batch.ClearingBatch on org.apache.openejb.assembler.classic.Assembler.createApplication (Assembler.java:658)

I tried with parameter in persistence.xml file and error still exists.

Please help me if someone encounters a similar problem.

+4
source share
2 answers

I had a similar problem - due to the fact that my objects were distributed across several jar files. I also used maven ...

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

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

If you have two classes with the same name and the same package in the same classloader, the result is inconsistent behavior (in the sense that it can behave differently based on the JVM / Application Server you choose), Maybe you you might want to do some research on what would be the expected behavior for your JVM / Application Server, but the ideal solution is not the same class (in the same package) in two banks. If you need to do this, I would say that you have an architecture problem that needs to be solved; -)

0
source

Source: https://habr.com/ru/post/1339802/


All Articles