5

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?

DavidB
  • 2,064
  • 3
  • 17
  • 17
  • What "DataNucleus 2"? DataNucleus is currently at version 3.0 and 3.1. Googles plugin is at v 2.0.1.1 (using DataNucleus v3.0.x) – DataNucleus Jul 02 '12 at 17:59
  • Ahh right. Yes the version of DataNucleus included is v3.0.x. I was able to get it to work by manually deleting the v1 libs from src and lib in GAE version 1.7.0 so that GAE stopped trying to put them into WEB-INF/lib. I was getting conflicts with both v3 and v1 DataNucleus libs on the classpath. GAE states that you can add an enhancer flag to tell it which versions to use, but I can't see how to use that flag with Eclipse to stop it from copying those libs over. So the workaround seems to work for me. It's not ideal but it will work. – DavidB Jul 03 '12 at 00:58
  • @DataNucleus When I browse the appengine 1.7 folder, the Datanucleus jars are datanucleus-core-1.1.5.jar, datanucleus-jpa-1.1.5, etc. What do you mean by Google plugin using Datanucleus v3.0.x? – quarks Jul 04 '12 at 11:38
  • @DataNucleus Ah yes, there's the v2 folder, however how to force Google plugin to use v2? – quarks Jul 04 '12 at 11:48
  • Its always using the v1, do I have to delete the v1 folder? – quarks Jul 04 '12 at 11:48
  • 2
    Ok got it working without needing to hack up the version of GAE. I found the flag in the .settings folder for eclipse in the file com.google.appengine.eclipse.core.prefs and changed this flag to use v2. gaeDatanucleusVersion=v2 Then after starting eclipse. under window-preferences-DataNucleus under JPA, I added asm-3.x.x.jar and datanucleus-enhancer-3.x.x.jar from appengine-java-sdk-1.7.x/lib/opt/tools/datanucleus/v2. Now it's using the correct enhancer and finding the correct enhancer classes for that version. – DavidB Jul 05 '12 at 01:36

1 Answers1

8

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.

Jed
  • 8,022
  • 3
  • 19
  • 19
  • Also check the build path libraries. In my case there were two App Engine SDK libaries... one with v1 and the other with v2. – Rori Stumpf Oct 24 '12 at 04:02
  • 2
    I stumbled on this very same problem in GAE 1.7.2 and I had to delete the 'filesCopiedToWebInfLib' line..... filesCopiedToWebInfLib=appengine-api-labs.jar|appengine-endpoints.jar|appengine-jsr107cache-1.7.2.1.jar|jsr107cache-1.1.jar|appengine-api-1.0-sdk-1.7.2.1.jar|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 – Santthosh Oct 28 '12 at 19:54
  • 1
    I had an issue where eclipse started all of a sudden to look for geronimo-jpa_3.0_spec-1.1.1.jar under v1. deleting v1 under the GAE SDK plugin folder solved it. – AsafK Dec 11 '13 at 15:08