Hi, I don't know what I'm doing wrong but I can't seem to get OpenJPA to work in my project. I keep running into entity enhancement issues. The more methods I try, to more problem it seems to be causing.
*Using* - NetBeans 6.5.1 - Java jdk1.5.0_16 - OpenJPA 1.2.1 - Derby 10.5.1.1 *Structure* - MPSF - lib - apache-openjpa-1.2.1 - src - META-INF - mpsf - entities - build.xml If I leave 'RuntimeUnenhancedClasses' set to 'supported' I get the following error: ------------------------------------------------------------------------------------------------- 297 MPSFPU INFO [AWT-EventQueue-0] openjpa.Runtime - Starting OpenJPA 1.2.1 875 MPSFPU INFO [AWT-EventQueue-0] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.DerbyDictionary". 2187 MPSFPU INFO [AWT-EventQueue-0] openjpa.Enhance - Creating subclass for "[class mpsf.entities.SearchDetection, class mpsf.entities.RotationRate, class mpsf.entities.Weapon, class mpsf.entities.Sensor, class mpsf.entities.TrackDetection, class mpsf.entities.Environment, class mpsf.entities.Trainer, class mpsf.entities.EngagementRange, class mpsf.entities.KillProbability, class mpsf.entities.TimeOfFlight, class mpsf.entities.Threat]". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead. May 18, 2009 3:57:20 PM org.jdesktop.application.Application$1 run SEVERE: Application class mpsf.MPSFApp failed to launch <openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.persistence.ArgumentException: Errors encountered while resolving metadata. See nested exceptions for details. at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:563) at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308) at org.apache.openjpa.enhance.ManagedClassSubclasser.configureMetaData(ManagedClassSubclasser.java:209) at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:165) at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:310) at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:228) at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:190) at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56) at mpsf.MPSFView.initComponents(MPSFView.java:181) at mpsf.MPSFView.<init>(MPSFView.java:47) at mpsf.MPSFApp.startup(MPSFApp.java:21) at org.jdesktop.application.Application$1.run(Application.java:171) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:461) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Caused by: <openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.persistence.ArgumentException: The type "class mpsf.entities.SearchDetectionPK" has not been enhanced. at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1652) at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1626) at org.apache.openjpa.meta.ValueMetaDataImpl.resolve(ValueMetaDataImpl.java:417) at org.apache.openjpa.jdbc.meta.ValueMappingImpl.resolve(ValueMappingImpl.java:470) at org.apache.openjpa.meta.FieldMetaData.resolve(FieldMetaData.java:1674) at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:416) at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1691) at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1626) at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:717) at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:616) at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:541) ... 21 more NestedThrowables: <openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type "mpsf.entities.Environment" due to previous errors resolving related type "mpsf.entities.SearchDetection". at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731) at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:616) at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:541) at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308) at org.apache.openjpa.enhance.ManagedClassSubclasser.configureMetaData(ManagedClassSubclasser.java:209) at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:165) at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:310) at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:228) at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:190) at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56) at mpsf.MPSFView.initComponents(MPSFView.java:181) at mpsf.MPSFView.<init>(MPSFView.java:47) at mpsf.MPSFApp.startup(MPSFApp.java:21) at org.jdesktop.application.Application$1.run(Application.java:171) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:461) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) <openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type "mpsf.entities.RotationRate" due to previous errors resolving related type "mpsf.entities.SearchDetection". at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731) at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:616) at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:541) at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308) at org.apache.openjpa.enhance.ManagedClassSubclasser.configureMetaData(ManagedClassSubclasser.java:209) at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:165) at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:310) at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:228) at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:190) at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56) at mpsf.MPSFView.initComponents(MPSFView.java:181) at mpsf.MPSFView.<init>(MPSFView.java:47) at mpsf.MPSFApp.startup(MPSFApp.java:21) at org.jdesktop.application.Application$1.run(Application.java:171) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:461) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class mpsf.MPSFApp failed to launch at org.jdesktop.application.Application$1.run(Application.java:177) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:461) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Caused by: <openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.persistence.ArgumentException: Errors encountered while resolving metadata. See nested exceptions for details. at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:563) at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308) at org.apache.openjpa.enhance.ManagedClassSubclasser.configureMetaData(ManagedClassSubclasser.java:209) at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:165) at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:310) at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:228) at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:190) at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56) at mpsf.MPSFView.initComponents(MPSFView.java:181) at mpsf.MPSFView.<init>(MPSFView.java:47) at mpsf.MPSFApp.startup(MPSFApp.java:21) at org.jdesktop.application.Application$1.run(Application.java:171) ... 7 more Caused by: <openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.persistence.ArgumentException: The type "class mpsf.entities.SearchDetectionPK" has not been enhanced. at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1652) at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1626) at org.apache.openjpa.meta.ValueMetaDataImpl.resolve(ValueMetaDataImpl.java:417) at org.apache.openjpa.jdbc.meta.ValueMappingImpl.resolve(ValueMappingImpl.java:470) at org.apache.openjpa.meta.FieldMetaData.resolve(FieldMetaData.java:1674) at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:416) at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1691) at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1626) at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:717) at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:616) at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:541) ... 21 more ------------------------------------------------------------------------------------------------- Why do I get errors like 'The type "class mpsf.entities.SearchDetectionPK" has not been enhanced.' while OpenJPA is supposed to be subclassing the lot? Because I want to have the entities enhanced on a later stage anyway I decided to deal with that right away in the hope to get things to work in the first place. I set 'RuntimeUnenhancedClasses' to 'warn' and tried the enhance at build time using ANT approaches. At least this got my program to run in the first place but things are going wrong as soon as I try to actually access the db. I'm always getting the following error using different ANT configuration ways: ------------------------------------------------------------------------------------------------- 16 MPSFPU INFO [RunnableQueue-1] openjpa.Runtime - Starting OpenJPA 1.2.1 16 MPSFPU INFO [RunnableQueue-1] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.DerbyDictionary". 31 MPSFPU WARN [RunnableQueue-1] openjpa.Enhance - This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "[class mpsf.entities.SearchDetection, class mpsf.entities.RotationRate, class mpsf.entities.Weapon, class mpsf.entities.Sensor, class mpsf.entities.TrackDetection, class mpsf.entities.Environment, class mpsf.entities.Trainer, class mpsf.entities.EngagementRange, class mpsf.entities.KillProbability, class mpsf.entities.TimeOfFlight, class mpsf.entities.Threat]". <openjpa-1.2.1-r752877:753278 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "SELECT d FROM mpsf.Entities.Threat d". Error message: The name "mpsf.Entities.Threat" is not a recognized entity or identifier. Known entity names: [] at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:180) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:150) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756) at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56) at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:153) at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658) at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639) at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605) at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667) at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492) at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at mpsf.AddDeviceTool.getDeviceList(AddDeviceTool.java:182) at mpsf.AddDeviceTool.access$400(AddDeviceTool.java:29) at mpsf.AddDeviceTool$1.run(AddDeviceTool.java:70) at org.apache.batik.util.RunnableQueue.run(Unknown Source) at java.lang.Thread.run(Thread.java:595) ------------------------------------------------------------------------------------------------- The entity I try to use is 'Threat'. In the error above it states 'mpsf.Entities.Threat'. I tried both 'Threat' and 'mpsf.Entities.Threat', the latter incase I had to specify the packages but it didn't make any difference. First attempt in build.xml: ------------------------------------------------------------------------------------------------- <target name="enhance"> <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask"/> <openjpac> <fileset dir="."> <include name="**/entities/*.java" /> </fileset> </openjpac> </target> ------------------------------------------------------------------------------------------------- After some reading up [1] I got to the following with different inbetween attempts in the hope to get a cleaner result then this: ------------------------------------------------------------------------------------------------- <path id="jpa.enhancement.classpath"> <pathelement location="bin"/> <fileset dir="lib/apache-openjpa-1.2.1"> <include name="**/*.jar"/> </fileset> </path> <target name="enhance"> <copy includeemptydirs="false" todir="bin"> <fileset dir="src" excludes="**/*.launch, **/*.java"/> </copy> <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask"> <classpath refid="jpa.enhancement.classpath"/> </taskdef> <openjpac> <classpath refid="jpa.enhancement.classpath"/> </openjpac> </target> ------------------------------------------------------------------------------------------------- All attempts just result in the same: none of the entities get enhanced, never are there any known entity names. The mentioned website does include an additional 'depends="build"' attribute in the target element but doing so results in a different error: 'Target "build" does not exist in the project "MPSF". It is used from target "enhance".' What is it that I keep doing wrong? What does it take to get the entities enhanced? I hope you can help me out. Yours, Age Bosma P.s. As you might have figured, I'm new to JPA and ANT. [1] http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html -- View this message in context: http://n2.nabble.com/Enhancing-entities%3A-getting-desperate-tp2937944p2937944.html Sent from the OpenJPA Users mailing list archive at Nabble.com.