Hi Rajeev,

Great questions...

First, I'm using JPA (my understanding is that JPA actually uses JDO
under the covers -- hence the JDO references in my errors).  Per the
documentation, I'm loading an EntityManager like it's done on this
page (http://code.google.com/appengine/docs/java/datastore/
usingjpa.html).  You'll notice that the EMF class is static, which
means it is statically initialized when the JRE virtual machine is
started up (before any code gets run).  This is where the error was
occurring (the static initializer was unable to link-in my JUnit test
classes when the JRE loaded up -- hence, my obfuscated error).  I
think this is happening because my JUnit test classes "import" a DAO
class that "imports" the EMF class.  So, this is probably why the
error was happening in conjuntino with the statically initialized
EntityManagerFactory (EMF) class.

In reality, it would be nice to *not* have my JUnit test classes and
junit.jar deployed to the HostedMode browser or AppEngine -- after
all, I don't actually run JUnit tests on the server.  However, I
haven't taken the time to filter out my junit tests when the appengine
WAR gets assembled (I'm not actually certain how I would do that -- is
there an easy way to say what goes into the WAR and what doesn't?).

With regard to your second question, I'm not sure what changed between
pre and post-upgrade.  All I know is that I didn't have this error
before I upgraded, and it showed up post-upgrade, and it only involved
jar files in "web-inf/lib" (the error only shows up on the server).
My guess is that I probably put the JUnit.jar file into the "web-inf/
lib" directory long ago, and the upgrade must have deleted all jars
and only added back the appengine jars (I recognize that's
contradictory to expected appgengine upgrade behavior, so possibly
there's another explanation -- though it seems like lots of people
have had similar errors to mine, especially with this latest eclipse
upgrade).

Hope that helps!

David

On Aug 14, 3:25 pm, Rajeev Dayal <rda...@google.com> wrote:
> Hi David,
> I'm sorry that you had to go through all of this trouble to get everything
> working. I'm trying to understand the problem here, so that we can guide
> other users away from it. Did the test code that you had make use of JDO at
> all? I can understand why a classloading error might occur (since junit.jar
> was not part of your war/WEB-INF/lib directory), but I do not understand why
> any of your test classes would need to be loaded during the course of
> running your application.
>
> Also, you mentioned that the junit.jar file went missing from your
> war/WEB-INF/lib folder when you upgraded to App Engine? Do you recall if it
> was just the SDK switch that caused this problem, or could it have been
> removed by some other means? I ask because an SDK switch should not remove
> any non-SDK jars.
>
> Thanks,
> Rajeev
>
> On Thu, Aug 13, 2009 at 1:39 PM, David Fuelling <sappe...@gmail.com> wrote:
>
> > Ok -- I solved my problem.
>
> > In a nutshell, I have some JUnit tests that are part of my project in
> > Eclipse (I'm not using Maven).  These JUnit tests are included in the
> > generated WAR file that is deployed to appengine since they're a
> > regular part of my project structure.  For whatever reason, when I
> > upgraded to the appengine eclipse 1.2.2 plugin, the JUnit.jar file was
> > still in my *eclipse build path*, but was no longer in the "war/WEB-
> > INF/lib" folder.  So, in eclipse everything appeared to be working
> > fine (no errors).  However, once I ran the app in appengine (Hosted
> > and real) and the app tried to initialize the EntityManagerFactory
> > (via: EntityManagerFactory emfInstance =
> > Persistence.createEntityManagerFactory("transactions-
> > optional");).....I would get this error:
>
> > java.lang.ExceptionInInitializerError
> > CAUSED BY: javax.persistence.PersistenceException: Provider error.
> > Provider:
> > org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider
> > CAUSED BY: org.datanucleus.exceptions.NucleusUserException: Class
> > "transactions-optional" found to be part of persistence-unit "{1}" so
> > loading it in case it is persistable
>
> > This led me to think something was amiss with my PersistenceProvider
> > config.  However, after digging deeper through my debug output, I was
> > able to stick a breakpoint on line 250 of the class
> > "org.datanucleusJDOClassLoaderResolver".  On line 249, the "msg"
> > variable does some translation to get an actual error message.  My
> > error message was saying that certain classes (that I created) were
> > not found on the classpath.  Digging even deeper, I was able to
> > isolate that each of the "not found" classes extended the the
> > "TestCase" JUnit class.
>
> > Anyway, since that jar (junit.jar) had been removed from my "war/WEB-
> > INF/lib" folder, it was causing my EMF utility class to barf during
> > instantiation, which then caused the PersistenceManager to not be able
> > to load.
>
> > All in all, some interesting errors that were rather concealed by the
> > fact that my WAR file was missing some jar files (yet Eclipse seemed
> > to be perfectly happy).  My advice to anyone with this issue is to
> > ensure that any classes in the Eclipse Build Path are also included in
> > the "war/WEB-INF/lib" folder just to be safe, or else only add classes
> > to the eclipse build path that are inside of "war/WEB-INF/lib".
>
> > On Aug 13, 4:01 pm, David Fuelling <sappe...@gmail.com> wrote:
> > > Just an update, I'm getting the following error when I try to
> > > instantiate my EMF class (per the documentation and per Max's updates,
> > > the EMF class just calls: Persistence.createEntityManagerFactory
> > > ("transactions-optional")):
>
> > > The Error is:
>
> > > java.lang.ExceptionInInitializerError
> > > CAUSED BY: javax.persistence.PersistenceException: Provider error.
> > > Provider:
> > > org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider
> > > CAUSED BY: org.datanucleus.exceptions.NucleusUserException: Class
> > > "transactions-optional" found to be part of persistence-unit "{1}" so
> > > loading it in case it is persistable
>
> > > This occurs in the Hosted browser as well as inside of appengine
> > > itself.
>
> > > On Aug 13, 3:38 pm, David Fuelling <sappe...@gmail.com> wrote:
>
> > > > I'm in the exact same boat as Geoff.  Tried all the fixes, but am
> > > > getting the same error after an Eclipse-based update to appengine (to
> > > > 1.2.2).  Any other ideas here?
>
> > > > On Jul 29, 1:52 am, Geoff Denning <gdenn...@gmail.com> wrote:
>
> > > > > Hi Rajeev, thanks for the reply.
>
> > > > > No enhancement errors after a clean build:
> > > > > DataNucleus Enhancer (version 1.1.4) : Enhancement of classes
> > > > > DataNucleus Enhancer completed with success for 4 classes. Timings :
> > > > > input=344 ms, enhance=78 ms, total=422 ms. Consult the log for full
> > > > > details
>
> > > > > Java build path contains the following (under libraries):
> > > > > gwt-gears.jar - TaskPath/war/WEB-INF/lib
> > > > > App Engine SDK [App Engine (1) - 1.2.2]
> > > > > GWT SDK [GWT (1) - 1.7.0]
> > > > > JRE System Library [jre1.6.0_14]
>
> > > > > war/WEB-INF/lib folder contains the following:
> > > > > appengine-api-1.0-sdk-1.2.2.jar
> > > > > datanucleus-appengine-1.0.2.final.jar
> > > > > datanucleus-core-1.1.4-gae.jar
> > > > > datanucleus-jpa-1.1.4.jar
> > > > > geronimo-jpa_3.0_spec-1.1.1.jar
> > > > > geronimo-jta_1.1_spec-1.1.1.jar
> > > > > gwt-gears.jar
> > > > > gwt-servlet.jar
> > > > > jdo2-api-2.3-ea.jar
> > > > > xercesImpl.jar
>
> > > > > On Jul 28, 3:49 pm, Rajeev Dayal <rda...@google.com> wrote:
>
> > > > > > Open up your console view, and select the console corresponding to
> > > > > > "Datanucleus Enhancement". When you do a clean build, are there any
> > > > > > enhancement errors? How many classes does it say were actually
> > enhanced?
> > > > > > Also, can you tell me what's listed on your Java build path and in
> > your
> > > > > > war/WEB-INF/lib folder? There is an issue with switching App Engine
> > SDKs
> > > > > > that causes the existing entries to remain on your build path,
> > which can
> > > > > > cause problems with the enhancer.
>
> > > > > > On Tue, Jul 28, 2009 at 1:19 AM, Geoff Denning <gdenn...@gmail.com>
> > wrote:
>
> > > > > > > I am also encountering this problem, and none of the suggestions
> > > > > > > listed so far have fixed it for me.  GWT is throwing the
> > > > > > > java.lang.ExceptionInInitializerError exception, followed
> > immediately
> > > > > > > by a java.lang.NoClassDefFoundError exception in theclassthat
> > calls
> > > > > > > JDOHelper.getPersistenceManagerFactory("transactions-optional").
> >  The
> > > > > > > error occurs in both the hosted browser and on Google App Engine,
> > and
> > > > > > > it started occurring immediately after Eclipse upgraded the
> > Google App
> > > > > > > Engine Java SDK from 1.2.1 to 1.2.2 and the Google Web Toolkit
> > SDK
> > > > > > > from 1.6.4 to 1.7.0.  My stack trace is the same as the one
> > posted by
> > > > > > > Clint in the first message in this thread.
>
> > > > > > > I've tried to fix the problem using all of the suggestions listed
> > > > > > > above, including:
> > > > > > > * Cleaning and re-deploying the solution.
> > > > > > > * Manually editing the files, resaving, and re-deploying.
> > > > > > > * Reverting my Eclipse configuration to it's state before the
> > upgrade
> > > > > > > (this doesn't appear to work at all).
> > > > > > > * Verified that src/META-INF/jdoconfig.xml is being successfully
> > > > > > > copied over to war/WEB-INF/classes/META-INF.
> > > > > > > * Verified that Window --> Preferences --> Java --> Compiler -->
> > > > > > > Building, "Filtered Resources" list does not contain *.xml (it
> > only
> > > > > > > contains *.launch).
>
> > > > > > > Does anyone have any other suggestions for attempting to fix
> > this, and/
> > > > > > > or is anyone else still experiencing this issue?
>
> > > > > > > On Jul 17, 8:19 am, Rajeev Dayal <rda...@google.com> wrote:
> > > > > > > > I'm glad it's working. Maybe when you changed theclass, it
> > cause Eclipse
> > > > > > > to
> > > > > > > > recompile it and copy it over to war/WEB-INF/classes. This can
> > happen if
> > > > > > > you
> > > > > > > > change Java code outside of Eclipse and you don't refresh your
> > workspace
> > > > > > > -
> > > > > > > > the change will not be picked up.
>
> > > > > > > > On Thu, Jul 16, 2009 at 3:38 AM, Richard Le Mesurier <
>
> > > > > > > > richard.lemesur...@gmail.com> wrote:
>
> > > > > > > > > How embarassed I am!
>
> > > > > > > > > Problem solved. I had set a breakpoint on the "suspend" line.
> > And not
> > > > > > > > > knowing Eclipse, I didn't realise I had set it.
>
> > > > > > > > > I still don't know how my stack trace changed from broken to
> > fixed,
> > > > > > > > > but the point is that most of the long post above is an ID 10
> > T error
> > > > > > > > > (ID 10 T = idiot).
>
> > > > > > > > > Apologies again for wasting community time, and forum
> > space...
> > > > > > > > > Richard
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to