[SOLVED] Deploying to Glassfish, getting "uses a non-entity" error [message #765734] |
Wed, 14 December 2011 15:43 |
John Manko Messages: 6 Registered: December 2011 |
Junior Member |
|
|
Running Oracle GlassFish Server 3.1.1 (build 12).
I'm modifying an entity class to add an additional reference, and I'm getting a "uses a non-entity" error. First, I should point out that my initial project was a standard WAR file with the entity classes in a seperate JAR library. I've since put the persistence.xml into it's own JAR library, and bundled it and the WAR into an EAR. This was needed for our design to swap out ejb libraries base on client. Everything worked fine after changing to an EAR package, prior to adding new entity classes. The problem I get now is that I'm trying to add a new entity with a relationship to an existing entity. I get the following error (but I shouldn't):
SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
SEVERE: Exception while invoking class org.glassfish.javaee.full.deployment.EarDeployer prepare method
SEVERE: Exception while preparing the app
SEVERE: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [MyCompPU] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class com.mycompany.entity.Policy] uses a non-entity [class com.mycompany.entity.RDCoverage] as target entity in the relationship attribute [field coverageRD].
org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [MyCompPU] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class com.mycompany.entity.Policy] uses a non-entity [class com.mycompany.entity.RDCoverage] as target entity in the relationship attribute [field coverageRD].
at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:166)
The Policy class looks like:
@Entity
@NamedQueries(......)
public class Policy implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/* THIS DOESN'T ERROR */
@OneToOne(cascade = CascadeType.ALL, mappedBy = "policy")
private ARCoverage coverageAR;
/* THIS DOESN'T ERROR */
@OneToOne(cascade = CascadeType.ALL, mappedBy = "policy")
private WWCoverage coverageWW;
/* THIS _DOES_ ERROR */
@OneToOne(cascade = CascadeType.ALL, mappedBy = "policy")
private RDCoverage coverageRD;
Here is RDCoverage:
@Entity
public class RDCoverage implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToOne
@JoinColumn(name = "POLICY_ID_fk", nullable = false)
private Policy policy;
For comparison, here is ARCoverage:
@Entity
public class ARCoverage implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToOne
@JoinColumn(name = "POLICY_ID_fk", nullable = false)
private Policy policy;
You'll notice that the relationship to Policy are defined the same way for all entity classes. I'm able to deploy the EAR after removing the RDCoverage reference from Policy (and thus Policy from RDCoverage). All entity classes are in persistence.xml. Additionally, removing the reference but keeping RDCoverage in persistence.xml does create the table as expected. So, it's can't be a problem with the ORM mapping.
Again, ARCoverage and WWCoverage, along with their Policy relationship, existed BEFORE I moved to an EAR packaging. I wonder if this is a caching issue where the new entity classes are not added to the PU correctly prior to entity validation. I've even deleted the <domain>/generated directory and the JDBC reference in Glassfish.
Is there another cache that should be deleted?
[Updated on: Wed, 14 December 2011 17:22] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04407 seconds