Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » strange Persistence exception with a List type
strange Persistence exception with a List type [message #790178] Fri, 03 February 2012 22:53 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
My code runs into the following exception:
-----------------------------------------------------------------------
Internal Exception: Exception [EclipseLink-7203] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The mapping element [communities] for the class [class edu.northwestern.at.teams.persistence.Person] has an unsupported collection type [class java.util.List]. Only Set, List, Map and Collection are supported.
------------------------------------------------------------------------
when the Persistence unit is being loaded. The class in question has a field as follows:

/** A list of communities a person participates in */
@OneToMany
@JoinTable
(
name="person_community",
joinColumns= @JoinColumn(name="personId", referencedColumnName="id"),
inverseJoinColumns= @JoinColumn(name="communityId", referencedColumnName="id")
)
private List<Community> communities;

Where both Person and Community are Entity types. Why is the exception being thrown, given that I am using a List<Community> type, and List is supposed to be a supported type, as even the error message suggests?
Re: strange Persistence exception with a List type [message #791372 is a reply to message #790178] Sun, 05 February 2012 18:19 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Any reason you are using Eclipselink 2.0? I seem to recall an issue with generics so you can try a later version or removing it from your collection to see if that is the issue.

Best regards
Chris
Re: strange Persistence exception with a List type [message #791373 is a reply to message #790178] Sun, 05 February 2012 18:19 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Any reason you are using Eclipselink 2.0? I seem to recall an issue with generics so you can try a later version or removing it from your collection to see if that is the issue.

Best regards
Chris
Re: strange Persistence exception with a List type [message #792148 is a reply to message #791373] Mon, 06 February 2012 17:09 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Hi Chris,
Thanks for responding. Actually, there is no particular reason for using 2.0.0 (just happened to be what I had downloaded a long time ago and was still using). I'm going to try it out with the current version instead.
BTW, I did not understand what you meant by 'you can try out removing it from your collection to see if that's the issue'. Not sure if I was clear, but given the exception I get, the persistence unit does not get loaded at all.
Thanks,
-Patricia
Re: strange Persistence exception with a List type [message #792150 is a reply to message #791372] Mon, 06 February 2012 17:09 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Hi Chris,
Thanks for responding. Actually, there is no particular reason for using 2.0.0 (just happened to be what I had downloaded a long time ago and was still using). I'm going to try it out with the current version instead.
BTW, I did not understand what you meant by 'you can try out removing it from your collection to see if that's the issue'. Not sure if I was clear, but given the exception I get, the persistence unit does not get loaded at all.
Thanks,
-Patricia
Re: strange Persistence exception with a List type [message #792234 is a reply to message #792148] Mon, 06 February 2012 19:39 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Sorry for the redundancy, but I just submitted another reply and I don't see it posted here, so I am resending it.

The summary is that after upgrading to the latest version of eclipselink, I am still getting the same type of exception when the persistence unit is being loaded.
Exception Stack is as follows:

--------------------------------
Caused by: Exception [EclipseLink-7203] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The mapping element [owners] for the class [class edu.northwestern.at.teams.persistence.Community] has an unsupported collection type [class java.util.List]. Only Set, List, Map and Collection are supported.
at org.eclipse.persistence.exceptions.ValidationException.invalidCollectionTypeForRelationship(ValidationException.java:1138)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.CollectionAccessor.process(CollectionAccessor.java:569)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.OneToManyAccessor.process(OneToManyAccessor.java:132)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1450)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1685)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:535)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:526)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1337)
... 142 more
2012-02-06 12:40:52,477 INFO edu.northwestern.at.teams.persistence.PersistenceService - About to load teams persistence unit: TeamsDevelopment
2012-02-06 12:40:53,058 ERROR edu.northwestern.at.teams.persistence.PersistenceService - Exception while creating EntityManagerFactory
Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@33d6f122

Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [TeamsDevelopment] failed.

----------------------------------------

Please advise. Thanks!
/** This community's owners */
@OneToMany
@JoinTable
(
name="nwu_community_person",
joinColumns= @JoinColumn(name="communityId", referencedColumnName="id"),
inverseJoinColumns= @JoinColumn(name="ownerId", referencedColumnName="id")
)
public List<Person> owners;
Re: strange Persistence exception with a List type [message #792236 is a reply to message #792148] Mon, 06 February 2012 19:39 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Sorry for the redundancy, but I just submitted another reply and I don't see it posted here, so I am resending it.

The summary is that after upgrading to the latest version of eclipselink, I am still getting the same type of exception when the persistence unit is being loaded.
Exception Stack is as follows:

--------------------------------
Caused by: Exception [EclipseLink-7203] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The mapping element [owners] for the class [class edu.northwestern.at.teams.persistence.Community] has an unsupported collection type [class java.util.List]. Only Set, List, Map and Collection are supported.
at org.eclipse.persistence.exceptions.ValidationException.invalidCollectionTypeForRelationship(ValidationException.java:1138)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.CollectionAccessor.process(CollectionAccessor.java:569)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.OneToManyAccessor.process(OneToManyAccessor.java:132)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1450)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1685)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:535)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:526)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1337)
... 142 more
2012-02-06 12:40:52,477 INFO edu.northwestern.at.teams.persistence.PersistenceService - About to load teams persistence unit: TeamsDevelopment
2012-02-06 12:40:53,058 ERROR edu.northwestern.at.teams.persistence.PersistenceService - Exception while creating EntityManagerFactory
Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
mailto:org.apache.catalina.loader.StandardClassLoader@33d6f122

Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [TeamsDevelopment] failed.

----------------------------------------

Please advise. Thanks!
/** This community's owners */
@OneToMany
@JoinTable
(
name="nwu_community_person",
joinColumns= @JoinColumn(name="communityId", referencedColumnName="id"),
inverseJoinColumns= @JoinColumn(name="ownerId", referencedColumnName="id")
)
public List<Person> owners;
Re: strange Persistence exception with a List type [message #792884 is a reply to message #792236] Tue, 07 February 2012 14:30 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I was refering to generics on the collection. Try removing the generics and instead specify the targetEntity within the annotation:
@OneToMany(targetEntity=Person.class)
@JoinTable
(
name="nwu_community_person",
joinColumns= @JoinColumn(name="communityId", referencedColumnName="id"),
inverseJoinColumns= @JoinColumn(name="ownerId", referencedColumnName="id")
)
public List owners; 


This problem though is odd. Can you also try using java.util.Collection instead of List and see if that works?

Regards,
Chris
Re: strange Persistence exception with a List type [message #792885 is a reply to message #792236] Tue, 07 February 2012 14:30 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I was refering to generics on the collection. Try removing the generics and instead specify the targetEntity within the annotation:
@OneToMany(targetEntity=Person.class)
@JoinTable
(
name="nwu_community_person",
joinColumns= @JoinColumn(name="communityId", referencedColumnName="id"),
inverseJoinColumns= @JoinColumn(name="ownerId", referencedColumnName="id")
)
public List owners;

This problem though is odd. Can you also try using java.util.Collection instead of List and see if that works?

Regards,
Chris
Re: strange Persistence exception with a List type [message #793004 is a reply to message #792885] Tue, 07 February 2012 16:57 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Hi,
I just tried taking the generics out (experiment 1) and using List instead of List<Person>, plus adding the targetEntity attribute to the annotation. To my surprise, I got exactly the same exception as before. I am currently trying experiment #2, in which I'm replacing List with Collection. This one is pretty painful, as it requires hundreds of changes in my code just in order to make it compile Sad Sad. Will let you know how it goes,
-Patricia
Re: strange Persistence exception with a List type [message #793008 is a reply to message #792885] Tue, 07 February 2012 16:57 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Hi,
I just tried taking the generics out (experiment 1) and using List instead of List<Person>, plus adding the targetEntity attribute to the annotation. To my surprise, I got exactly the same exception as before. I am currently trying experiment #2, in which I'm replacing List with Collection. This one is pretty painful, as it requires hundreds of changes in my code just in order to make it compile :( :(. Will let you know how it goes,
-Patricia
Re: strange Persistence exception with a List type [message #793024 is a reply to message #792885] Tue, 07 February 2012 17:23 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
I've now tried experiment #2 (switching from a List<Entity> to a Collection<Entity>. The result of this painful experiment was to get rid of the exception pointing to my two unidirectional one-to-many relationships (that I had shown), but now it is throwing analogous exceptions for *all* the bidirectional relationships (which are all using List<some entity type>. Does this actually imply that eclipselink is not properly supporting List<some entity type> relationships? (at least on Oracle; I never had this problem when working with MySQL and h2 before, as I mentioned earlier). Please clarify whether this is a bug asap. Thanks!!
Re: strange Persistence exception with a List type [message #793027 is a reply to message #792885] Tue, 07 February 2012 17:23 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
I've now tried experiment #2 (switching from a List<Entity> to a Collection<Entity>. The result of this painful experiment was to get rid of the exception pointing to my two unidirectional one-to-many relationships (that I had shown), but now it is throwing analogous exceptions for *all* the bidirectional relationships (which are all using List<some entity type>. Does this actually imply that eclipselink is not properly supporting List<some entity type> relationships? (at least on Oracle; I never had this problem when working with MySQL and h2 before, as I mentioned earlier). Please clarify whether this is a bug asap. Thanks!!
Re: strange Persistence exception with a List type [message #793103 is a reply to message #793024] Tue, 07 February 2012 19:36 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

I don't think its related to the database platform being used - it is a strange error that seems related to the classloader and ASM. Without being able to reproduce it locally, I cannot tell what is causing it. Can you file a bug and include all the details required to reproduce it? Everything from the product versions involved to how the classpath is setup would be needed, in addition to the persistence settings (and hopefully a paired down JPA model and test case), so that someone can reproduce it locally and step through it to determine what is happening.

Best Regards,
Chris
Re: strange Persistence exception with a List type [message #793182 is a reply to message #793103] Tue, 07 February 2012 21:26 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Thanks Chris for replying. The problem is that I don't think there's an easy way (for me) to reproduce the problem outside of its current environment. Details: the code I wrote in the past (working with MySQL and h2) is now being merged into an existing extension for a course management system (Blackboard) -extensions are web applications that run in the same Tomcat instance as Blackboard itself-. This Blackboard instance uses Oracle for storage (and happens to be managed by a different department here in my institution). So I think it would be quite hard to get the details of the classpath setup in particular. Also, I currently have no local instance of Oracle that I could test the code in (independently of Blackboard). If I had access to one such instance -and things worked there-, I could at least try to rule out the specific choice of database platform, which would get us closer to concluding that it is definitely an issue with the classloader as you suggested. Hopefully this makes some sense ... If you think that providing one of you access to this Bb test server would work, let me know and I'll be glad to arrange that. In that case, I'll also be happy to come up with a paired down JPA model that we could use for further testing on that system.
Re: strange Persistence exception with a List type [message #795587 is a reply to message #793103] Fri, 10 February 2012 16:43 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Hi again,
Could you please point me to the issue tracker so I can file a bug report? Thanks in advance,
-Patricia
Re: strange Persistence exception with a List type [message #797497 is a reply to message #795587] Mon, 13 February 2012 15:11 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink

Best Regards,
Chris
Re: strange Persistence exception with a List type [message #810266 is a reply to message #797497] Wed, 29 February 2012 22:50 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 34
Registered: October 2010
Member
Just for the record, this issue has been filed as bug 371818
Previous Topic:JPQL: SIZE function causing strange exceptions
Next Topic:[SOLVED] Transform instruction SQL (PostgreSQL) to JPQL (@NamedQuery)
Goto Forum:
  


Current Time: Wed Nov 13 02:19:49 GMT 2024

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

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

Back to the top