Hi, The NPE is happening in the code where OpenJPA is attempting to enhance a getter method. It looks like OpenJPA is assuming that the metadata associated with a field (attribute) is available, but for some reason it is not. So, either the POJO doesn't contain all of the required getter/setter methods. Or, some field is being marked as being persistent, but doesn't have the required getter/setter methods.
Granted, an NPE is not good. But, we would need to understand the scenario a bit more before resolving that issue. My guess is that even if we resolved the NPE, there is something else wrong with the environment, POJO, or configuration that will prevent the enhancement from completing as expected. If you can re-create this issue with a simple junit, then that would help with deciphering the real error and hopefully figure out proper resolution. Just curious... What version of Java are you using? Java 7 threw in some wrinkles that didn't get resolved until OpenJPA 2.2.x. But, you claimed this also didn't work with 2.2.x, so maybe Java 7 is not in the picture. Thanks, Kevin On Thu, Feb 7, 2013 at 7:31 AM, Krishnaprasad Subbarao < krishnapras...@in.ibm.com> wrote: > Hello, > > I am using OpenJPA 2.0.1 in a project and trying to enhance the POJO > classes during build time. Following is the error I am getting from > enhancer. > > [openjpac] <openjpa-2.0.1-r422266:989424 nonfatal general error> > org.apache.openjpa.util.GeneralException: An error occurred while > enhancing test.NewParty. Exception message: null > [openjpac] at > org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:549) > [openjpac] at > org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4654) > [openjpac] at > org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:89) > [openjpac] at > org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:171) > [openjpac] at > org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) > [openjpac] at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown > Source) > [openjpac] at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) > [openjpac] at java.lang.reflect.Method.invoke(Method.java:611) > [openjpac] at > org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) > [openjpac] at org.apache.tools.ant.Task.perform(Task.java:348) > [openjpac] at org.apache.tools.ant.Target.execute(Target.java:357) > [openjpac] at > org.apache.tools.ant.Target.performTasks(Target.java:385) > [openjpac] at > org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) > [openjpac] at > > org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38) > [openjpac] at > org.apache.tools.ant.Project.executeTargets(Project.java:1189) > [openjpac] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416) > [openjpac] at > org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105) > [openjpac] at > org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) > [openjpac] at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown > Source) > [openjpac] at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) > [openjpac] at java.lang.reflect.Method.invoke(Method.java:611) > [openjpac] at > org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) > [openjpac] at org.apache.tools.ant.Task.perform(Task.java:348) > [openjpac] at org.apache.tools.ant.Target.execute(Target.java:357) > [openjpac] at > org.apache.tools.ant.Target.performTasks(Target.java:385) > [openjpac] at > org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) > [openjpac] at > org.apache.tools.ant.Project.executeTarget(Project.java:1306) > [openjpac] at > > org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) > [openjpac] at > org.apache.tools.ant.Project.executeTargets(Project.java:1189) > [openjpac] at org.apache.tools.ant.Main.runBuild(Main.java:758) > [openjpac] at org.apache.tools.ant.Main.startAnt(Main.java:217) > [openjpac] at > org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) > [openjpac] at > org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) > [openjpac] Caused by: java.lang.NullPointerException > [openjpac] at > org.apache.openjpa.enhance.PCEnhancer.createGetMethod(PCEnhancer.java:4420) > [openjpac] at > org.apache.openjpa.enhance.PCEnhancer.addGetMethod(PCEnhancer.java:3639) > [openjpac] at > org.apache.openjpa.enhance.PCEnhancer.addAccessors(PCEnhancer.java:3536) > [openjpac] at > org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:535) > [openjpac] ... 32 more > > The build.xml defines the ant target for enhancement like this, > > <target name="enhance" depends="copy-resources.files"> > <!-- define the openjpac task; this can be done at the > top of the --> > <!-- build.xml file, so it will be available for all > targets --> > <taskdef name="openjpac" classname= > "org.apache.openjpa.ant.PCEnhancerTask" classpathref="enhancer.path"/> > > <!-- invoke enhancer on all .java files below the model > directory --> > <openjpac> > <config propertiesFile= > "${wdp.src.dir}/META-INF/persistence.xml"/> > <classpath> > <pathelement location= > "${wdp.target.dir}/classes"/> > <pathelement location= > "${wdp.target.dir}/classes/META-INF"/> > </classpath> > <fileset dir="${wdp.target.dir}/classes"> > <include name="**/entity/New*.class" /> > </fileset> > </openjpac> > </target> > > The error occurs while enhancing different class while running multiple > times. I see some warnings like below > > [openjpac] 649 bss WARN [main] openjpa.MetaData - Found duplicate > metadata or mapping for test.NewParty. > > The same error occurs if I use OpenJPA 2.2.1 > > Is this an error in the POJO or some error in mapping or persistence.xml? > > I request all to help on this. > > Thanks and Regards, > > KRISHNAPRASAD SUBBARAO >