DataNucleus Enhancer flakey? - google-app-engine

I'm creating a GWT app in Google App Engine, and using Google data store. Does anybody else have the problem of the DataNucleus being flakey as all get out?
I can save a class, and DataNucleus will do it's thing just fine. If I change ANYTHING in the class (even adding whitespace) and then save, I get the following error:
DataNucleus Enhancer completed with
success for 0 classes. Timings :
input=37 ms, enhance=0 ms, total=37
ms. Consult the log for full details
DataNucleus Enhancer completed and no
classes were enhanced. Consult the log
for full details
Once I clean my project, DataNucleus is happy again.
Is this common when using eclipse? Is there a workaround?

The DataNucleus Enhancer is invoked by Google's Eclipse plugin. It is their plugin that causes the enhancement. The enhancer itself just does its job, enhancing the classes it is provided with. Nothing "flaky" about the enhancer ...
If you instead use the DataNucleus Eclipse plugin then you can do "on-demand" enhancement, enhancing just before deploy for example.
--Andy (DataNucleus)

I have had a few similar experiences, and needed to clean the project as well. Its not all the time, but I think it happened once or twice a day, when I was regularly using Eclipse with the Google plugins.

I was getting the error "Persistent class x does not seem to have been enhanced" and realized that I changed package names and the GAE plug in is set to enhance only certain classes.
You can change the list of classes that need enhancement in your project properties..Google...App Engine...ORM.

I had the same problem with the eclipse GAE plugin not "always" enhancing my classes so I installed the DataNucleus plugin to force it but I ran into a problem with the autogeneration of SerialVersionUIDs. I got an error saying "errors during build" but there were no compile errors. Uninstalled DataNucleus plugin and I was back to normal. They don't play well together, it seems.
I'm using GAE v1.3.3.1 and I installed DataNucleus eclipse plugin v2.0.2
Cleaning the project works, even if it's not the most elegant solution.

I had the same problem. checking the log file on Eclipse get this message:
Caused by: org.datanucleus.exceptions.NucleusException: Plugin (Bundle)
org.datanucleus.store.appengine" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/Users/mmangar/projects/rga/google_sandbox/Sandbox/war/WEB-INF/lib/datanucleus-appengine-1.0.10.final.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/opt/springsource-tool-suite-2.8.0.RELEASE-e3.7.1-macosx-carbon/springsource/sts-2.8.0.RELEASE/plugins/com.google.appengine.eclipse.sdkbundle_1.6.3.v201202290255r37/appengine-java-sdk-1.6.3/lib/user/orm/datanucleus-appengine-1.0.10.final.jar."
I had the same class trying to be loaded twice.
Removing one of the JAR file from my classpath it worked fine.

Related

Google Endpoints V2 and Maven plugin version?

We have a multi-module (war-packaged) project that uses com.google.appengine - appengine-maven-plugin target being ear file.
We have migrated succesfully to Java8 and EndpointsV2. It builds and runs fine in Cloud. However the following requirement is still a bit questionmark in the migration instructions. What is the reason behind this incompatibility and requirement? Or is it just related to for example "discovery docs" that we are not using anyway?
The old App Engine Maven plugin, with group com.google.appengine, is incompatible with the Endpoints Framework plugin. You must use the new version shown above
https://cloud.google.com/endpoints/docs/frameworks/java/migrating
If you aren't using discovery docs or generated client libraries and are only using Endpoints as a library dependency, you can remove the Endpoints plugin and the error should go away.

NoClassDefFoundError: Could not initialize OauthRawGcsServiceFactory on production environment

I'm using appengine-sdk 1.9.3.
In devserver, works in Eclipse and Ant normally.
When I deploy (update) to appengine (production environment), I get this error:
event.getResults(): [<pre>Error for /p7/formPanelServlet
java.lang.NoClassDefFoundError: Could not initialize class
com.google.appengine.tools.cloudstorage.oauth.OauthRawGcsServiceFactory
at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createRawGcsService(GcsServiceFactory.java:42)
at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService(GcsServiceFactory.java:34)
at com.bitvisio.p7.server.FormPanelServlet.<init>(FormPanelServlet.java:27)
At FormPanelServlet.java:27, the code is:
private final GcsService gcsService = GcsServiceFactory
.createGcsService(new RetryParams.Builder()
.initialRetryDelayMillis(10)
.retryMaxAttempts(10)
.totalRetryPeriodMillis(15000)
.build());
I put the lib appengine-gcs-client-0.3.9.jar in war/WEB-INF/lib. I think there is a problem with this lib.
Thanks for help.
Always use tools like Maven or Ivy to resolve dependencies for you. Copying JARs to war/WEB-INF/lib/ directory and editing .classpath file manually will be painful and may not help you always. If you use Eclipse & Google App Engine plugin, use Add Google APIs... as mentioned here - Google Plugin for Eclipse. In my case, adding Cloud Storage API via Google Plugin for Eclipse helped resolve this NoClassDefFoundError.
I had the same problem. I use Ivy to resolve dependencies and always get the latest.integration (with Maven use RELEASE) for revisions.
However I usually ignore transitive libraries. It looks like Google is expanding the API family - at least splitting out discrete functionality.
There are now quite a few transitive dependencies and it seems they released a new version of the GCS client around the same time as 1.9.3.
Getting all dependencies and packaging them in my deployment fixed my issue. I did not have the issue in development which made it more confusing.
You are facing this issue because you are not adding the some of the jar like
google-api-services-storage-v1-rev78-1.22.0.jar download link
joda-time-2.94.jar download link
guava-19.0.jar link to download
you can use the different version of jar according to your appengine-gcs-client jar file.
Note : Add all these jar and build path with the project and problem will get solve.

DataNucleus libraries and maven-gae-plugin

I'm using maven-gae-plugin to manage a Google AppEngine project but I don't know how to include the libraries required to use JPA.
Google's documentation says:
The classpath must contain the JARs 'datanucleus-core-*.jar', 'datanucleus-jpa-*', 'datanucleus-enhancer-*.jar', 'asm-*.jar', and 'geronimo-jpa-*.jar' (where * is the appropriate version number of each JAR) from the 'appengine-java-sdk/lib/tools/' directory, as well as all of your data classes.
How can I tell the plugin to put all the jars in the classpath?
So far I just edited the pom.xml file setting gae.version to 1.7.3 (Leaving datanucleus.version to 1.1.5 and I run mvn gae:unpack but I cannot get it to work.
First, I have problems with javax.persistance that is not found. Do I have to add it manually to pom.xml?
If I do it, the development server starts, but I cannot work with the storage: I get the following error:
SEVERE: Found Meta-Data for class com.sharecost.entities.User but this class is not enhanced!! Please enhance the class before running DataNucleus.
I found a solution to the second part of my question. Looking at the POM.xml file I discovered that the all entities are supposed to be in a **/model package.
I still don't know if the manual inclusion of the javax.persistence dependency is actually required.

DataNucleus Enhancer doesn't work

I'm writing a web app using Google AppEngine and Spring MVC. I carefully upgraded to the v2 of the DataNucleus pluging by following these steps: http://code.google.com/p/datanucleus-appengine/wiki/UpgradingToVersionTwo (I use Eclipse).
When I try to run the Enhancer Tool I get following error:
Exception in thread "main" Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL
"file:/.../eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.6.4.v201203300216r37/appengine-java-sdk-1.6.4/lib/opt/user/datanucleus/v2/datanucleus-core-3.0.6.jar" is already registered, and you are trying to register an identical plugin located at URL
"file:/.../eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.6.4.v201203300216r37/appengine-java-sdk-1.6.4/lib/opt/tools/datanucleus/v2/datanucleus-core-3.0.6.jar."
I formatted the message so that you could see the tiny difference, one jar is loaded from "user" directory, the other one from "tools" directory. I don't understand why. In the project build path, there is only the one from "user" and to the DataNucleus configuration I added the one from "tools", just like the howto above suggested.
In other cases I've seen around this message was mostly caused by conflicting versions of datanucleus plugin but it doesn't apply to me. I guess it's just some stupid thing in my case... so what am I doing wrong?
So after all, I didn't read the instructions as carefully as I thought. The problem was really that the jars were there twice, one in the project build path, one in the datanucleus configuration. It shouldn't be in the project build path (or in fact, it shouldn't be in one of them, doesn't matter which one). I added it there automatically when I copied libs to the war directory and I assumed it had to be done. But the instructions clearly say that only jdo-api needs to be in the project build path.
One thing I don't understand though. In one step of the instructions I had to uncheck "use project classpath when running tools" in the DataNuclues configuration. So how is it possible that the plugin was still using the libs configured in the project build path?

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?
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.

Resources