I have an application that I am trying to deploy as an EAR.
In the EAR I have:
1) One WAR file
2) One app.jar EJB file
3) One framework.jar EJB file
I have included the persistence.xml file in the EAR's META-INF directory. The application.xml file has both app.jar and framework.jar defined as an ejb module.
In the app.jar file I have an entity that has a @OneToOne relationship with another entity in the framework.jar file.
In app.jar, the Foo class looks like:
Code:
package app.model;
import javax.persistence.*;
import framework.model.Bar;
public class Foo {
@Id
@GeneratedValue
private Long id;
@OneToOne
@JoinColumn(name = "BARID")
private Bar bar;
public Foo() {
}
// getters and setters omitted
}
In framework.jar, I have:
Code:
package framework.model;
public class Bar {
@Id
@GeneratedValue
@Column(name = "BARID")
private Long id;
// Getters and setters omitted
}
When I try to deploy this EAR, all the @Entities in app.jar are recognized and binded, but none of the @Entities in framework.jar get binded (and hence, not managed by the EntityManagerFactory).
The exception I get is:
Code:
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on app.model.Foo.bar references an unknown entity: framework.model.Bar
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:56)
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1207)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:844)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:382)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
...
Does anyone have any ideas on what I would need to do to get this working?
Any advice would be greatly appreciated!
Thanks