Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-1625

JPA inheritence Eclipselink - classloader issue ?!

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Bug
    • None
    • None
    • JPA
    • None

    Description

      I have jar with packaged entities in it.

      I have package org.test.base where I have class like:

      BaseParameter.java
      package org.test.base;
      @Entity
      @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
      @DiscriminatorColumn(name = "TYPE")
      @Table(name = "PARAMETER")
      public abstract class BaseParameter implements Serializable {...
      
      	@Id
      	@SequenceGenerator(name = "ParameterIdGenerator", allocationSize = 1, sequenceName = "SEQ_PARAMETER_ID")
      	@GeneratedValue(generator = "ParameterIdGenerator", strategy = GenerationType.SEQUENCE)
      	@Column(name = "ID", nullable = false, precision = 20)
      	protected Long id;
      

      and another package org.test.operation in which I have concrete parameter for example:

      SubscriptionParameter.java
      package org.test.operation 
      @Entity
      @DiscriminatorValue("SUBSCRIPTION")
      public class SubscriptionParameter extends BaseParameter { .....
      

      I am using example from
      https://github.com/apache/aries/tree/trunk/jpa/examples
      to get to my entities using DS module but of course I modified it to fit my model.

      Commands I do are:
      install -s mvn:pl.orange.isep/my-model/0.1-SNAPSHOT -> OK
      install -s mvn:org.apache.aries.jpa.example/org.apache.aries.jpa.example.tasklist.model/3.0.0-SNAPSHOT

      and then the exception arises:

      Exception
      org.apache.aries.jpa/org.apache.aries.jpa.container/2.3.0]: Unexpected problem updating configuration org.apache.aries.jpa.tasklist
      javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.6.1.v20150916-55dc7c3): org.eclipse.persistence.exceptions.EntityManagerSetupException
      Exception Description: Predeployment of PersistenceUnit [tasklist] failed.
      Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.6.1.v20150916-55dc7c3): org.eclipse.persistence.exceptions.ValidationException
      Exception Description: Entity class [class org.test.operation.SubscriptionParameter] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
              at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:2035)[333:org.eclipse.persistence.jpa:2.6.1.v20150916-55dc7c3]
              at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2026)[333:org.eclipse.persistence.jpa:2.6.1.v20150916-55dc7c3]
              at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:347)[333:org.eclipse.persistence.jpa:2.6.1.v20150916-55dc7c3]
              at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:313)[333:org.eclipse.persistence.jpa:2.6.1.v20150916-55dc7c3]
              at org.apache.aries.jpa.eclipselink.adapter.EclipseLinkPersistenceProvider.createContainerEntityManagerFactory(EclipseLinkPersistenceProvider.java:52)[302:org.apache.aries.jpa.eclipselink.adapter:2.3.0]
              at org.apache.aries.jpa.container.impl.ManagedEMF.createAndPublishEMF(ManagedEMF.java:129)[164:org.apache.aries.jpa.container:2.3.0]
              at org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:125)[164:org.apache.aries.jpa.container:2.3.0]
              at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[3:org.apache.felix.configadmin:1.8.8]
              at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[3:org.apache.felix.configadmin:1.8.8]
      

      My assumption is that class BaseParameter is not seen by the eclipselink that validates entities.

      But surprisingly when I change the package for this two entities that they are in common package for example org.base then everything is loading fine and I can access my entities.
      Problem was happening with all my entities consecutively until I packed them all in one package, then it disappeared.

      My model is quite complex and I really dont want to have all entities mixed in one package. Do You have any idea why it happens?
      The examples from github (https://github.com/apache/aries/tree/trunk/jpa/examples) have no JPA inheritence and all the entities are in one package.

      I have my application configured correctly (persistence.xml etc.) because only package change makes a difference.

      Is it Karaf classloader issue or jpa-container one? Is there any workaroud other than putting all entities in one package?

      Attachments

        Activity

          People

            cschneider Christian Schneider
            maciekjira maciek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: