Note: I fixed the "down level" entity by updating the version of openjpa used by the enhancer. Exception remains, though.
Rick, if you want me to send you the whole project offline, I'd be happy to. -matthew On Thu, Mar 15, 2012 at 8:39 AM, Matthew Adams <[email protected]> wrote: > Sure thing. I just noticed something suspicious: "A down level > Entity was detected and logged". Could that have something to do with > the problem? > > 19:00:31,348 INFO ClassPathXmlApplicationContext:495 - Refreshing > org.springframework.context.support.ClassPathXmlApplicationContext@2f833eca: > startup date [Wed Mar 14 19:00:31 CDT 2012]; root of context hierarchy > 19:00:31,417 INFO XmlBeanDefinitionReader:315 - Loading XML bean > definitions from file > [/home/matthew/dev/statthing/statthing/backend/model/target/classes/META-INF/spring/applicationContext.xml] > 19:00:31,964 INFO PropertySourcesPlaceholderConfigurer:177 - Loading > properties file from file > [/home/matthew/dev/statthing/statthing/backend/model/target/classes/META-INF/spring/database.properties] > 19:00:31,985 INFO DefaultListableBeanFactory:557 - Pre-instantiating > singletons in > org.springframework.beans.factory.support.DefaultListableBeanFactory@11dfc8a0: > defining beans > [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,org.springframework.context.config.internalBeanConfigurerAspect,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,transactionManager,org.springframework.transaction.config.internalTransactionAspect,dataSource,entityManagerFactory,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; > root of factory hierarchy > 19:00:32,146 INFO LocalContainerEntityManagerFactoryBean:253 - > Building JPA container EntityManagerFactory for persistence unit > 'persistenceUnit' > 20 persistenceUnit WARN [main] openjpa.Runtime - An error occurred > while registering a ClassTransformer with PersistenceUnitInfo: name > 'persistenceUnit', root URL > [file:/home/matthew/dev/statthing/statthing/backend/model/target/classes/]. > The error has been consumed. To see it, set your openjpa.Runtime log > level to TRACE. Load-time class transformation will not be available. > 82 persistenceUnit INFO [main] openjpa.Runtime - OpenJPA > dynamically loaded a validation provider. > 156 persistenceUnit INFO [main] openjpa.Runtime - Starting OpenJPA 2.2.0 > 187 persistenceUnit INFO [main] openjpa.jdbc.JDBC - Using > dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary". > 1087 persistenceUnit INFO [main] openjpa.Runtime - The Entity > "com.statthing.model.volleyball.FloorRegionList" was enhanced at level > "1,055,128", but the current level of enhancement is "1,241,207". > 1090 persistenceUnit INFO [main] openjpa.Runtime - A down level > Entity was detected and logged. Please enable RUNTIME trace to see all > down level Entities. > Exception in thread "main" > org.springframework.orm.jpa.JpaSystemException: The transaction has > been rolled back. See the nested exceptions for details on the errors > that occurred.; nested exception is <openjpa-2.2.0-r422266:1244990 > 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.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:326) > at > org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:120) > at > org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:516) > at > org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754) > at > org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723) > at > org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393) > at > org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$afterReturning$org_springframework_transaction_aspectj_AbstractTransactionAspect$3$2a73e96c(AbstractTransactionAspect.aj:78) > at > com.statthing.model.volleyball.FloorConfiguration_Roo_Jpa_ActiveRecord.ajc$interMethod$com_statthing_model_volleyball_FloorConfiguration_Roo_Jpa_ActiveRecord$com_statthing_model_volleyball_FloorConfiguration$persist(FloorConfiguration_Roo_Jpa_ActiveRecord.aj:44) > at > com.statthing.model.volleyball.FloorConfiguration.persist(FloorConfiguration.java:1) > at > com.statthing.model.volleyball.FloorConfiguration_Roo_Jpa_ActiveRecord.ajc$interMethodDispatch1$com_statthing_model_volleyball_FloorConfiguration_Roo_Jpa_ActiveRecord$com_statthing_model_volleyball_FloorConfiguration$persist(FloorConfiguration_Roo_Jpa_ActiveRecord.aj) > at com.statthing.model.volleyball.seeder.Seeder.seed(Seeder.java:78) > at > com.statthing.model.volleyball.seeder.Seeder$1.doInJpa(Seeder.java:43) > at > org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:187) > at > org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:150) > at com.statthing.model.volleyball.seeder.Seeder.execute(Seeder.java:38) > at com.statthing.model.volleyball.seeder.Seeder.main(Seeder.java:24) > Caused by: <openjpa-2.2.0-r422266:1244990 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:2337) > at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2174) > at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2072) > at > org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1990) > at > org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81) > at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1514) > at > org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:933) > at > org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:570) > at > org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:512) > ... 13 more > Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error> > org.apache.openjpa.persistence.InvalidStateException: Attempt to set > column "FloorRegion.version" to two different values: (null)"null", > (class java.lang.Integer)"1" This can occur when you fail to set both > sides of a two-sided relation between objects, or when you map > different fields to the same column, but you do not keep the values of > these fields in synch. > at > org.apache.openjpa.jdbc.sql.PrimaryRow.setObject(PrimaryRow.java:344) > at org.apache.openjpa.jdbc.sql.RowImpl.setObject(RowImpl.java:510) > at > org.apache.openjpa.jdbc.meta.strats.ColumnVersionStrategy.insert(ColumnVersionStrategy.java:192) > at org.apache.openjpa.jdbc.meta.Version.insert(Version.java:293) > at > org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.insert(AbstractUpdateManager.java:236) > at > org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:162) > at > org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:95) > at > org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76) > at > org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:713) > at > org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131) > ... 21 more > > > On Thu, Mar 15, 2012 at 8:09 AM, Rick Curtis <[email protected]> wrote: >> Matthew- >> >> Could you post the full exception stack? >> >> Thanks, >> Rick >> >> On Wed, Mar 14, 2012 at 7:19 PM, Matthew Adams >> <[email protected]>wrote: >> >>> Hi all, >>> >>> Vitals: Maven 3.0.3, Roo 1.2.1.RELEASE, OpenJPA 2.2.0, MySQL 5.1.x, >>> Ubuntu 11.10 64-bit, JDK 6 (1.6.0_30) 64-bit >>> >>> I'm getting an error with OpenJPA 2.2.0 that seems to have popped up a >>> fair bit with other folks out on the Internet over the years. Can >>> anyone see anything in my mappings that is either wrong or would cause >>> this exception? I've been struggling with this for hours, trying all >>> sorts of different mappings and nothing seems to help! >>> >>> Here's the exception snippet: >>> ===== >>> <openjpa-2.2.0-r422266:1244990 fatal user error> >>> org.apache.openjpa.persistence.InvalidStateException: Attempt to set >>> column "FloorRegion.version" to two different values: (null)"null", >>> (class java.lang.Integer)"1" This can occur when you fail to set both >>> sides of a two-sided relation between objects, or when you map >>> different fields to the same column, but you do not keep the values of >>> these fields in synch. >>> ===== >>> >>> The class in question, FloorRegion, is the target of a unidirectional >>> one-to-many relationship, owned by class FloorRegionList. Here's the >>> relevant part of FloorRegionList: >>> ===== >>> @Table(name = "FloorRegionList") >>> public class FloorRegionList implements HasCourtSize { >>> >>> @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.DETACH, >>> CascadeType.MERGE, CascadeType.REFRESH }) >>> // unidirectional one-to-many using join column >>> @JoinColumn(name = "owner", referencedColumnName = "id", nullable = >>> true) >>> protected List<FloorRegion> regions = new ArrayList<FloorRegion>(); >>> ===== >>> >>> The FloorRegion class doesn't know anything whatsoever about >>> FloorRegionList; it just has a couple of ints and five embedded >>> FloorPoint instances: >>> ===== >>> @Table(name = "FloorRegion") >>> public class FloorRegion implements HasCourtSize { >>> >>> @Column(nullable = false) >>> protected int width; >>> >>> @Column(nullable = false) >>> protected int length; >>> >>> @Embedded >>> @AttributeOverrides({ >>> @AttributeOverride(name = "w", column = @Column(name = >>> "lfw", nullable = false)), >>> @AttributeOverride(name = "l", column = @Column(name = >>> "lfl", nullable = false)) }) >>> protected FloorPoint leftFront; >>> >>> @Embedded >>> @AttributeOverrides({ >>> @AttributeOverride(name = "w", column = @Column(name = >>> "lbw", nullable = false)), >>> @AttributeOverride(name = "l", column = @Column(name = >>> "lbl", nullable = false)) }) >>> protected FloorPoint leftBack; >>> >>> @Embedded >>> @AttributeOverrides({ >>> @AttributeOverride(name = "w", column = @Column(name = >>> "rfw", nullable = false)), >>> @AttributeOverride(name = "l", column = @Column(name = >>> "rfl", nullable = false)) }) >>> protected FloorPoint rightFront; >>> >>> @Embedded >>> @AttributeOverrides({ >>> @AttributeOverride(name = "w", column = @Column(name = >>> "rbw", nullable = false)), >>> @AttributeOverride(name = "l", column = @Column(name = >>> "rbl", nullable = false)) }) >>> protected FloorPoint rightBack; >>> >>> @Embedded >>> @AttributeOverrides({ >>> @AttributeOverride(name = "w", column = @Column(name = >>> "cw", nullable = false)), >>> @AttributeOverride(name = "l", column = @Column(name = >>> "cl", nullable = false)) }) >>> protected FloorPoint center; >>> ===== >>> >>> Here's my persistence.xml (note addition of foreign key constraints): >>> ===== >>> <?xml version="1.0" encoding="UTF-8" standalone="no"?> >>> <persistence >>> xmlns="http://java.sun.com/xml/ns/persistence" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> version="2.0" >>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence >>> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> >>> <persistence-unit >>> name="persistenceUnit" >>> transaction-type="RESOURCE_LOCAL"> >>> >>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> >>> <properties> >>> <property >>> name="openjpa.jdbc.DBDictionary" >>> value="org.apache.openjpa.jdbc.sql.MySQLDictionary" /> >>> <!-- value="buildSchema" to runtime forward map the DDL SQL; >>> value="validate" makes no changes to the database --> >>> <property >>> name="openjpa.jdbc.SynchronizeMappings" >>> value="validate" /> >>> <property >>> name="openjpa.RuntimeUnenhancedClasses" >>> value="unsupported" /> >>> <property >>> name="openjpa.jdbc.MappingDefaults" >>> value="ForeignKeyDeleteAction=restrict, >>> JoinForeignKeyDeleteAction=restrict" /> >>> </properties> >>> </persistence-unit> >>> </persistence> >>> ===== >>> >>> Here's a snippet from my pom.xml that has to do with OpenJPA >>> enhancement. It enhances, generates a clean schema DDL file, a >>> differential one, connects to the database & refreshes it (during the >>> process-classes phase), and then during the post-integration-test >>> phase, runs a main class that seeds the database with an initial set >>> of entities. >>> ===== >>> <plugin> >>> <groupId>org.codehaus.mojo</groupId> >>> <artifactId>openjpa-maven-plugin</artifactId> >>> <version>1.2</version> >>> <executions> >>> <execution> >>> <id>enhance-classes</id> >>> <phase>process-classes</phase> >>> <goals> >>> <goal>enhance</goal> >>> </goals> >>> <configuration> >>> >>> <includes>${statthing.entities.ant.pathspec}</includes> >>> <excludes>**/*_Roo_*.class</excludes> >>> >>> <addDefaultConstructor>true</addDefaultConstructor> >>> </configuration> >>> </execution> >>> <execution> >>> <id>generate-ddl-file-complete</id> >>> <phase>process-classes</phase> >>> <goals> >>> <goal>sql</goal> >>> </goals> >>> <configuration> >>> >>> <includes>${statthing.entities.ant.pathspec}</includes> >>> <excludes>**/*_Roo_*.class</excludes> >>> <sqlAction>build</sqlAction> >>> <foreignKeys>true</foreignKeys> >>> >>> <sqlFile>${statthing.db.ddl.file.complete}</sqlFile> >>> </configuration> >>> </execution> >>> <execution> >>> <id>generate-ddl-file-diff</id> >>> <phase>process-classes</phase> >>> <goals> >>> <goal>sql</goal> >>> </goals> >>> <configuration> >>> >>> <includes>${statthing.entities.ant.pathspec}</includes> >>> <excludes>**/*_Roo_*.class</excludes> >>> <sqlAction>refresh</sqlAction> >>> <foreignKeys>true</foreignKeys> >>> <sqlFile>${statthing.db.ddl.file.diff}</sqlFile> >>> >>> <connectionDriverName>${statthing.db.connection.driver.name >>> }</connectionDriverName> >>> >>> >>> <connectionDriverName>com.mchange.v2.c3p0.ComboPooledDataSource</connectionDriverName> >>> >>> >>> <connectionProperties>${statthing.db.connection.properties}</connectionProperties> >>> </configuration> >>> </execution> >>> <execution> >>> <id>generate-ddl-db</id> >>> <phase>process-classes</phase> >>> <goals> >>> <goal>sql</goal> >>> </goals> >>> <configuration> >>> >>> <includes>${statthing.entities.ant.pathspec}</includes> >>> <excludes>**/*_Roo_*.class</excludes> >>> <sqlAction>refresh</sqlAction> >>> <foreignKeys>true</foreignKeys> >>> <modifyDatabase>true</modifyDatabase> >>> >>> <connectionDriverName>${statthing.db.connection.driver.name >>> }</connectionDriverName> >>> >>> >>> <connectionDriverName>com.mchange.v2.c3p0.ComboPooledDataSource</connectionDriverName> >>> >>> >>> <connectionProperties>${statthing.db.connection.properties}</connectionProperties> >>> </configuration> >>> </execution> >>> </executions> >>> <dependencies> >>> <dependency> >>> <groupId>org.apache.openjpa</groupId> >>> <artifactId>openjpa</artifactId> >>> <version>2.1.1</version> >>> <exclusions> >>> <exclusion> >>> <groupId>commons-logging</groupId> >>> <artifactId>commons-logging</artifactId> >>> </exclusion> >>> <exclusion> >>> <groupId>org.apache.geronimo.specs</groupId> >>> >>> <artifactId>geronimo-jms_1.1_spec</artifactId> >>> </exclusion> >>> </exclusions> >>> </dependency> >>> </dependencies> >>> </plugin> >>> <plugin> >>> <groupId>org.codehaus.mojo</groupId> >>> <artifactId>exec-maven-plugin</artifactId> >>> <version>1.2.1</version> >>> <executions> >>> <execution> >>> <id>seed-database</id> >>> <goals> >>> <goal>exec</goal> >>> </goals> >>> <phase>post-integration-test</phase> >>> </execution> >>> </executions> >>> <configuration> >>> <executable>java</executable> >>> <classpathScope>test</classpathScope> >>> <arguments> >>> <argument>-Xdebug</argument> >>> >>> >>> <argument>-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005</argument> >>> <argument>-classpath</argument> >>> <classpath /> >>> >>> <argument>com.statthing.model.volleyball.seeder.Seeder</argument> >>> </arguments> >>> </configuration> >>> </plugin> >>> >>> ===== >>> >>> Thanks, >>> Matthew >>> >>> -- >>> @matthewadams12 >>> mailto:[email protected] >>> skype:matthewadams12 >>> yahoo:matthewadams >>> aol:matthewadams12 >>> google-talk:[email protected] >>> msn:[email protected] >>> http://matthewadams.me >>> http://www.linkedin.com/in/matthewadams >>> >> >> >> >> -- >> *Rick Curtis* > > > > -- > @matthewadams12 > mailto:[email protected] > skype:matthewadams12 > yahoo:matthewadams > aol:matthewadams12 > google-talk:[email protected] > msn:[email protected] > http://matthewadams.me > http://www.linkedin.com/in/matthewadams -- @matthewadams12 mailto:[email protected] skype:matthewadams12 yahoo:matthewadams aol:matthewadams12 google-talk:[email protected] msn:[email protected] http://matthewadams.me http://www.linkedin.com/in/matthewadams
