Vaadin + GAE + Eclipse = Error?

Hello!

Another bit of strangeness when trying to use Vaadin with Google App Engine…

The following Exception occurs in a project that combines Eclipse with the Vaadin plugin and the Google App Engine plugin where it needs to run the DataNucleus enhancer to post-process classes for persistence.

In my investigations of the error, it seems it may be related to the “Web App Libraries” library that gets added to the project by Vaadin that includes the “datanucleus-appengine-1.0.3.jar” jar mentioned in the Exception. And, in fact, if I remove this library, the DataNucleus enhancer runs as expected… (although, clearly there are other problems in that case)

Thanks!
Scott

java.lang.RuntimeException: Unexpected exception
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:59)
at com.google.appengine.tools.enhancer.Enhance.(Enhance.java:60)
at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:41)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:57)
… 2 more
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:/Applications/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.2.6.v200910131704/appengine-java-sdk-1.2.6/lib/user/orm/datanucleus-appengine-1.0.3.jar” is already registered, and you are trying to register an identical plugin located at URL “file:/Users/sganyo/dev/workspace/pt/war/WEB-INF/lib/datanucleus-appengine-1.0.3.jar.”
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:434)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:340)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:222)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoints(NonManagedPluginRegistry.java:153)
at org.datanucleus.plugin.PluginManager.registerExtensionPoints(PluginManager.java:82)
at org.datanucleus.OMFContext.(OMFContext.java:160)
at org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:172)
at org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:150)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1157)
… 7 more

I ran into this the over the weekend and resolved it the same way you did.

Note that the “Web App Libraries” is not an actual library, it’s just the contents of your war/WEB-INF/lib directory. I just tried this with a dummy project, and the GAE plugin adds that jar to the dir. Perhaps the Vaadin plugin needs to uninclude that jar when setting up the web application project?

Also note that the JDO/JPA support in GAE is not very robust at the moment; for example
this problem
makes it impossible to use inheritance in your entities. I was forced to use a flat entity structure, but this leads to very bad cases of copy&paste code and annoying kludges in the business layer.

Thanks, Henri!

It’s good to know there may be other potential issues lying in wait as well…

Regarding “resolving” this issue, though… did you actually resolve it? I tried removing that jar from the lib dir as you suggested, but if I do so the application fails during runtime with this error:

javax.jdo.JDOFatalUserException: Class org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory was not found.
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1168)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:803)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1086)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:914)

Did you address this somehow as well?

Best,
Scott

Hi Scott,

I’m using JPA instead of JDO and removing that jar did resolve my problem. However, I just tested JDO and got that second exception too.

A solution is to remove the “Web App Libraries” from build path, and add any non-GAE jars (including Vaadin jar) to build path separately. This way the entity enhancer won’t see the second copy of the abovementioned jar.

I wrote a quick app to test this, and it
seems to work
(
sources
).

A second approach for the problem is to run the enhancer by hand when required using the
provided Ant script
and ignore the error while developing your app. I recommend using the Ant script anyway, it caches your password so GAE deployment is even easier than with the toolbar button.

Hope this helps,
Henri

Thanks, Henri. I can verify that yes, using the ant script does work.

But hopefully at some point the Vaadin plugin will play nice with the Google one…

Best,
Scott

Created a
ticket
about this.

The ticket
#3649
already existed for this issue, marked the new ticket as duplicate.

The problem is that the Vaadin Eclipse plugin is designed to follow the Eclipse Web Tools Project (WTP) practices and conventions, whereas the Google plugin is not.

WTP automatically and implicitly adds all JARs in WEB-INF/lib to the classpath, whereas the Google plugin assumes they need to be added explicitly, one by one. Having the same JAR twice in the classpath then causes problems for some reason.

Just commenting that this issue is still out there. The workaround worked for me, although it took me quite a while to figure out what was going on. I’m using Eclipse Helios SR1.