1

I get the following error when i try to deploy my application on glassfish 4.1:

[class com.sample.model.Profile] uses a non-entity [class com.sample.model.ProfileEventMapping] as target entity in the relationship attribute [field events].

The tables for both entities are getting created in the database.

Profile:

@Entity
public class Profile
...
@OneToMany(mappedBy = "profile", orphanRemoval = true)
private Set<ProfileEventMapping> events = new HashSet<>();

ProfileEventMapping:

@Entity
public class ProfileEventMapping
...
@NotNull
@ManyToOne
private Profile profile;

and in my persistence.xml i choose to include all entities:

<exclude-unlisted-classes>false</exclude-unlisted-classes>

anybody an idea?

perotom
  • 851
  • 13
  • 33
  • Not sure if this is relevant to the issue but I just noticed that Profile in ProfileEventMapping is annotated with OneToOne, this should be ManyToOne. – Petros Splinakis Apr 02 '15 at 08:54
  • thanks i copied it wrong. has nothing to do with the error. – perotom Apr 02 '15 at 08:57
  • please try removing from persistence.xml. container will anyway pick annotated entities – Prasad Kharkar Apr 02 '15 at 09:05
  • tried it does´t change anything. still getting the error. the persistence.xml is generated from netbeans – perotom Apr 02 '15 at 09:13
  • How do you have the entities packaged? Check that both classfiles are available in the same location relative to the persistence.xml file being used, especially if within a jar. – Chris Apr 02 '15 at 15:26
  • yes they are. the strange thing is that it says there was an error in deploying persistence unit but the name of the unit is totally different than the persistence unit in my persistence.xml (no i don´t have any other persistence.xml file in my project). Is there any file to say glass fish which persistence.xml to use? – perotom Apr 02 '15 at 17:56

1 Answers1

0

I renamed the hole project with just find and replace. The problem was that in the ear project was a dependency to an old .war file which had an persistence.xml in it. Just deleted the old dependency and BOOM. Now i just need to fix the other error messages ("com.Profile[id = null] is not a known entity type")

perotom
  • 851
  • 13
  • 33