Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datanucleus using wrong enhancer in Google App Engine 1.7

I'm having difficulty in getting Datanucleus 2 to work properly with enhancing classes on GAE 1.7.0 in Eclipse using the Datanucleus plugin. This worked fine in older versions of GAE when I'd follow the manual steps here:

http://www.datanucleus.org/products/accessplatform/guides/eclipse/index.html

But since upgrading, GAE now includes these libs (newer versions of them it looks like), and also GAE has a new "enhancer" flag you can set. I can't find anyway to set this flag in Eclipse though. It appears that GAE is still including the v1 libs when I want the V2 libs and Datanucleus is having conflicts according to this error:

Jul 1, 2012 5:59:55 PM org.datanucleus.enhancer.DataNucleusEnhancer <init>
INFO: DataNucleus Enhancer : Using ClassEnhancer "ASM" for API "JPA"
Exception in thread "main" java.lang.NoSuchFieldError: NUCLEUS_CONTEXT_LOADER
    at org.datanucleus.NucleusContext.<clinit>(NucleusContext.java:73)
    at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:171)
    at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1265)

I've tried many different things. I've tried using all the defaults. I've tried adding the v2 libs to the Datanucleus runtime Classpath Entries. I've tried deleting the v1 libs in the GAE 1.7.0 SDK in both the src and libs. But somehow GAE is still pulling over (or trying to pull over the V1 libs. I've even tried the older method of manually setting up the configuration as specified by the link above. It's a little frustrating as it seems like I'm now in a situation where I can't use these libs at all. At least with older versions of GAE I could manually set it up to work. Nothing seems to work now. Any suggestions?

like image 635
DavidB Avatar asked Jul 01 '12 22:07

DavidB


1 Answers

I hit this same error and was able to resolve it in my project by:

  • Doing what DavidB suggested in the comments, without modifying the DataNucleus JPA settings in the preferences.
  • Deleting all of the "V1" jars from the war/WEB-INF/lib

To clarify DavidB's suggestion, open the directory that holds your project. There will be a folder named ".settings", open this and edit com.google.appengine.eclipse.core.prefs. Just change the third line from gaeDatanucleusVersion=v1 to gaeDatanucleusVersion=v2

Once you have done this, remove the following jars from you war/WEB-INF/lib directory:

  • datanucleus-appengine-1.0.10.final.jar
  • datanucleus-core-1.1.5.jar
  • datanucleus-jpa-1.1.5.jar
  • geronimo-jpa_3.0_spec-1.1.1.jar
  • geronimo-jta_1.1_spec-1.1.1.jar
  • jdo2-api-2.3-eb.jar

Restart eclipse and you should be good to go.

like image 151
Jed Avatar answered Sep 26 '22 05:09

Jed