openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Moving from OpenJPA 2.0.1 to 2.3.0: fields not found
Date Mon, 06 Oct 2014 20:42:30 GMT
Lionel,
Nothing is jumping out at me, but I do have a couple of observations and
questions...

>  I had a working project using OpenJPA 2.0.1
>  We had to change the project to a maven build so we are now enhancing the
>  classes this way:

How did you perform entity enhancement in 2.0.1?  Why did moving to Maven
require a change in the method of entity enhancement?

>
<provider>com.axway.passport.persistence.providers.jpa.PassportPersistenceProvider</provider>

What is this?  You must be extending OpenJPA in some manner...  Have you
tried specifying the OpenJPA provider or just removing this element?

Maybe the answers to these questions will shed more light for me or others
to help with this question.

Kevin



On Fri, Oct 3, 2014 at 3:52 AM, Lionel <lsavouillan@axway.com> wrote:

> Hello,
>
> I had a working project using OpenJPA 2.0.1
> We had to change the project to a maven build so we are now enhancing the
> classes this way:
>             <plugin>
>                 <groupId>org.apache.openjpa</groupId>
>                 <artifactId>openjpa-maven-plugin</artifactId>
>                 <version>2.3.0</version>
>                 <configuration>
>
>
> <persistenceXmlFile>${project.basedir}/src/main/configuration/META-INF/persistence.xml</persistenceXmlFile>
>                     <addDefaultConstructor>true</addDefaultConstructor>
>
> <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
>                 </configuration>
>                 <executions>
>                     <execution>
>                         <id>enhancer</id>
>                         <phase>process-classes</phase>
>                         <goals>
>                             <goal>enhance</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>                 <dependencies>
>                     <dependency>
>                         <groupId>org.apache.openjpa</groupId>
>                         <artifactId>openjpa</artifactId>
>                         <version>2.3.0</version>
>                     </dependency>
>                 </dependencies>
>             </plugin>
>
> The problem occurs at runtime during the commit for classes that have
> inheritance:
> <openjpa-2.3.0-r422266:1540826 fatal general error>
> org.apache.openjpa.persistence.PersistenceException: The transaction has
> been rolled back.  See the nested exceptions for details on the errors that
> occurred.
>         at
>
> org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2370)
>         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2207)
>         at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2105)
>         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1876)
>         at
> org.apache.openjpa.kernel.QueryImpl.isInMemory(QueryImpl.java:973)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:853)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
>         at
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
>         at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:275)
>         at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:291)
>         at
>
> com.axway.passport.schema.AbstractObject.getByPrimaryKey(AbstractObject.java:323)
>         at
>
> com.axway.passport.schema.common.Organization.getOrganization(Organization.java:715)
>         at
>
> com.axway.passport.upgrade.am.DataInitializer.createDefaultOrganizations(DataInitializer.java:138)
>         at
>
> com.axway.passport.upgrade.am.DataInitializer.execute(DataInitializer.java:334)
>         at
>
> com.axway.passport.persistence.upgrade.DataInitExecuter.executeInit(DataInitExecuter.java:80)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.initData(SchemaInstaller.java:205)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.installSchema(SchemaInstaller.java:101)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.installSchema(SchemaInstaller.java:71)
>         at
>
> com.axway.passport.service.PassportStartupThread.startCoreServices(PassportStartupThread.java:124)
>         at
>
> com.axway.passport.service.PassportStartupThread.primRun(PassportStartupThread.java:84)
>         at com.axway.passport.util.EventedThread.run(EventedThread.java:66)
> Caused by: <openjpa-2.3.0-r422266:1540826 fatal user error>
> org.apache.openjpa.persistence.ArgumentException:
> "com.axway.passport.schema.pki.Entity.certificateAliases" declared that it
> is mapped by "parent", but that is a not a field of the related type.
>         at
>
> org.apache.openjpa.meta.FieldMetaData.getMappedByMetaData(FieldMetaData.java:867)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.getMapField(RelationFieldStrategy.java:341)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.setMapKey(RelationFieldStrategy.java:304)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.insert(RelationFieldStrategy.java:294)
>         at
> org.apache.openjpa.jdbc.meta.FieldMapping.insert(FieldMapping.java:623)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.insert(AbstractUpdateManager.java:238)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:165)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:96)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:77)
>         at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:732)
>         at
>
> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
>         at
>
> org.apache.openjpa.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:661)
>         at
>
> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
>         ... 20 more
> NestedThrowables:
> <openjpa-2.3.0-r422266:1540826 fatal user error>
> org.apache.openjpa.persistence.ArgumentException:
> "com.axway.passport.schema.common.Domain.caServices" declared that it is
> mapped by "domains", but that is a not a field of the related type.
>         at
>
> org.apache.openjpa.meta.FieldMetaData.getMappedByMetaData(FieldMetaData.java:867)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.getMapField(RelationFieldStrategy.java:341)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.setMapKey(RelationFieldStrategy.java:304)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.insert(RelationFieldStrategy.java:294)
>         at
> org.apache.openjpa.jdbc.meta.FieldMapping.insert(FieldMapping.java:623)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.insert(AbstractUpdateManager.java:238)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:165)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:96)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:77)
>         at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:732)
>         at
>
> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
>         at
>
> org.apache.openjpa.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:661)
>         at
>
> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
>         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2207)
>         at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2105)
>         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1876)
>         at
> org.apache.openjpa.kernel.QueryImpl.isInMemory(QueryImpl.java:973)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:853)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
>         at
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
>         at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:275)
>         at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:291)
>         at
>
> com.axway.passport.schema.AbstractObject.getByPrimaryKey(AbstractObject.java:323)
>         at
>
> com.axway.passport.schema.common.Organization.getOrganization(Organization.java:715)
>         at
>
> com.axway.passport.upgrade.am.DataInitializer.createDefaultOrganizations(DataInitializer.java:138)
>         at
>
> com.axway.passport.upgrade.am.DataInitializer.execute(DataInitializer.java:334)
>         at
>
> com.axway.passport.persistence.upgrade.DataInitExecuter.executeInit(DataInitExecuter.java:80)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.initData(SchemaInstaller.java:205)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.installSchema(SchemaInstaller.java:101)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.installSchema(SchemaInstaller.java:71)
>         at
>
> com.axway.passport.service.PassportStartupThread.startCoreServices(PassportStartupThread.java:124)
>         at
>
> com.axway.passport.service.PassportStartupThread.primRun(PassportStartupThread.java:84)
>         at com.axway.passport.util.EventedThread.run(EventedThread.java:66)
> <openjpa-2.3.0-r422266:1540826 fatal user error>
> org.apache.openjpa.persistence.ArgumentException:
> "com.axway.passport.schema.common.Domain.caServices" declared that it is
> mapped by "domains", but that is a not a field of the related type.
>         at
>
> org.apache.openjpa.meta.FieldMetaData.getMappedByMetaData(FieldMetaData.java:867)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.getMapField(RelationFieldStrategy.java:341)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.setMapKey(RelationFieldStrategy.java:304)
>         at
>
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.insert(RelationFieldStrategy.java:294)
>         at
> org.apache.openjpa.jdbc.meta.FieldMapping.insert(FieldMapping.java:623)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.insert(AbstractUpdateManager.java:238)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:165)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:96)
>         at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:77)
>         at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:732)
>         at
>
> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
>         at
>
> org.apache.openjpa.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:661)
>         at
>
> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
>         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2207)
>         at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2105)
>         at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1876)
>         at
> org.apache.openjpa.kernel.QueryImpl.isInMemory(QueryImpl.java:973)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:853)
>         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
>         at
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
>         at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:275)
>         at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:291)
>         at
>
> com.axway.passport.schema.AbstractObject.getByPrimaryKey(AbstractObject.java:323)
>         at
>
> com.axway.passport.schema.common.Organization.getOrganization(Organization.java:715)
>         at
>
> com.axway.passport.upgrade.am.DataInitializer.createDefaultOrganizations(DataInitializer.java:138)
>         at
>
> com.axway.passport.upgrade.am.DataInitializer.execute(DataInitializer.java:334)
>         at
>
> com.axway.passport.persistence.upgrade.DataInitExecuter.executeInit(DataInitExecuter.java:80)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.initData(SchemaInstaller.java:205)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.installSchema(SchemaInstaller.java:101)
>         at
>
> com.axway.passport.persistence.upgrade.SchemaInstaller.installSchema(SchemaInstaller.java:71)
>         at
>
> com.axway.passport.service.PassportStartupThread.startCoreServices(PassportStartupThread.java:124)
>         at
>
> com.axway.passport.service.PassportStartupThread.primRun(PassportStartupThread.java:84)
>         at com.axway.passport.util.EventedThread.run(EventedThread.java:66)
>
>
>
>
> And here is the classes and mapping that we have:
> 1) for the nested throwable
> @MappedSuperclass
> public abstract class AbstractObject implements IAbstractObject,
> IProvisioningObject
> {
>     @Column(name = SchemaConstants.ABSTRACTOBJECT_OID_COLUMN)
>     @Id
>     @GeneratedValue
>     private long id;
>     public static final String _idFieldName = "id";
> ...
> }
>
> @MappedSuperclass
> public abstract class ExtendedAbstractObject extends AbstractObject
> implements IExtendedAbstractObject
> {
> ...
> }
>
> @Table(name = SchemaConstants.DOMAIN_TABLE)
> public class Domain extends ExtendedAbstractObject implements
> IAbstractObject, Comparable<Domain>
> {
>     @ManyToMany(mappedBy = CAService._domainFieldName, fetch =
> FetchType.LAZY, cascade = {CascadeType.REFRESH}, targetEntity =
> CAService.class)
>     private Collection<CAService> caServices = new ArrayList<CAService>();
> ...
> }
>
> @javax.persistence.Entity
> @Table(name = SchemaConstants.CASERVICE_TABLE)
> public class CAService extends AbstractObject implements
> Comparable<CAService>, CertificateVersionContainer
> {
>     @ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE,
> CascadeType.REFRESH})
>     @JoinTable(name = SchemaConstants.CASERVICE_DOMAIN_JOIN_TABLE,
>                      joinColumns = {@JoinColumn(name =
> SchemaConstants.CASERVICE_DOMAIN_INVERSE_JOIN_COLUMN, referencedColumnName
> =
> SchemaConstants.ABSTRACTOBJECT_OID_COLUMN)},
>             inverseJoinColumns = {@JoinColumn(name =
> SchemaConstants.CASERVICE_DOMAIN_JOIN_COLUMN, referencedColumnName =
> SchemaConstants.ABSTRACTOBJECT_OID_COLUMN)})
>     private Collection<Domain> domains = new ArrayList<Domain>();
>     public static final String _domainFieldName = "domains";
> ...
> }
>
> 2) for the exception itself:
> @javax.persistence.Entity
> @Table(name = ENTITY_TABLE)
> public class Entity extends AbstractObject implements Comparable<Entity>,
> PublicKeyContainer
> {
>     @OneToMany(targetEntity =
> CertificateAlias.EntityCertificateAlias.class,
> mappedBy = CertificateAlias.EntityCertificateAlias._entityFieldName, fetch
> =
> FetchType.LAZY, cascade = {CascadeType.ALL})
>     @ElementDependent
>     private Collection<CertificateAlias> certificateAliases = new
> ArrayList<CertificateAlias>();
>     public static final String _certAliasListFieldName =
> "certificateAliases";
>     ...
> }
>
> @javax.persistence.Entity
> @Table(name = CERTALIAS_TABLE)
> @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
> @DiscriminatorColumn(name =
>
> com.axway.passport.schema.pki.SchemaConstants.CERTALIAS_DISCRIMINATOR_COLUMN,
> discriminatorType = DiscriminatorType.STRING)
> public abstract class CertificateAlias extends AbstractObject implements
> Comparable<CertificateAlias>, CertificateVersionContainer
> {
>
>     @javax.persistence.Entity
>
>
> @DiscriminatorValue(com.axway.passport.schema.pki.SchemaConstants.DISCRIMINATOR_ENTITY)
>     public static class EntityCertificateAlias extends CertificateAlias
>     {
>         @ManyToOne(fetch = FetchType.EAGER, cascade =
> {CascadeType.REFRESH})
>         @JoinColumn(name = CERTALIAS_PARENT_JOIN_COLUMN,
> referencedColumnName =
> com.axway.passport.schema.common.SchemaConstants.ABSTRACTOBJECT_OID_COLUMN)
>         private Entity parent;
>         public static final String _entityFieldName = "parent";
>         ...
>     }
>     ...
> }
>
>
> And finally the persistence.xml (don't know if this is important or not...)
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
>         <persistence-unit name="passport">
>
>
>
> <provider>com.axway.passport.persistence.providers.jpa.PassportPersistenceProvider</provider>
>
>
>                 <class>com.axway.passport.schema.AbstractObject</class>
>
> <class>com.axway.passport.schema.common.ExtendedAbstractObject</class>
>         <class>com.axway.passport.schema.common.Domain</class>
>         <class>com.axway.passport.schema.pki.Entity</class>
>         <class>com.axway.passport.schema.pki.CertificateAlias</class>
>
>
> <class>com.axway.passport.schema.pki.CertificateAlias$EntityCertificateAlias</class>
>         <class>com.axway.passport.schema.pki.CAService</class>
>         </persistence-unit>
> </persistence>
>
>
> As I found on some thread this advice, I can confirm that we have no method
> "final" (getter or setter).
>
> I didn't manage to figure out why when classes are read the first time, the
> fields are well found but second time during the commit, something goes
> wrong and they are not in the map.
> Does anyone has an idea that could help us?
> Maybe more data are needed... You can also contact me directly by email if
> needed.
> Thanks a lot in advance for you help.
>
> Just to let you know, I also run the test to just replace the openjpa lib
> on
> a working running environment and I had the same issue (so it's probably
> not
> link to the way we enhance the classes)
>
> Lionel.
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Moving-from-OpenJPA-2-0-1-to-2-3-0-fields-not-found-tp7587168.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message