Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » [SOLVED] Deploying to Glassfish, getting "uses a non-entity" error
icon5.gif  [SOLVED] Deploying to Glassfish, getting "uses a non-entity" error [message #765734] Wed, 14 December 2011 15:43 Go to next message
John Manko is currently offline John MankoFriend
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

Re: Deploying to Glassfish, getting "uses a non-entity" error [message #765756 is a reply to message #765734] Wed, 14 December 2011 16:07 Go to previous messageGo to next message
John Manko is currently offline John MankoFriend
Messages: 6
Registered: December 2011
Junior Member
Ok, I just installed a fresh copy of Glassfish 3.1.1, and I'm getting the same error. So, it's not a cache issue. Any other thoughts?
Re: Deploying to Glassfish, getting "uses a non-entity" error [message #765787 is a reply to message #765756] Wed, 14 December 2011 17:22 Go to previous messageGo to next message
John Manko is currently offline John MankoFriend
Messages: 6
Registered: December 2011
Junior Member
The problem appears to have been Netbeans. It had a cache version of persistence.xml that it was using. I delete the ~/.netbeans/7.0/var/cache folder and all is fine now. Thanks.

[Updated on: Wed, 14 December 2011 17:22]

Report message to a moderator

Re: Deploying to Glassfish, getting &quot;uses a non-entity&quot; error [message #765788 is a reply to message #765756] Wed, 14 December 2011 17:22 Go to previous message
John Manko is currently offline John MankoFriend
Messages: 6
Registered: December 2011
Junior Member
The problem appears to have been Netbeans. It had a cache version of persistence.xml that it was using. I delete the ~/netbeans/7.0/var/cache folder and all is fine now. Thanks.
Previous Topic:[DELETED] duplicate thread
Next Topic:Zipped P2 Repository for Eclipselink
Goto Forum:
  


Current Time: Fri Nov 08 08:35:26 GMT 2024

Powered by FUDForum. Page generated in 0.04407 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top