7

I am using Google App Engine (appengine-java-sdk-1.6.6) for an application using JDO and maven (maven-gae-plugin) for the project structure and build. The build is successful along with enhancing my domain classes with DataNucleus Enhancer.

When running the application, I am facing this issue:Class org.datanucleus.api.jdo.PersistenceManagerFactoryClass was not found. Could anyone please advise. Thanks

PS: I have done a grep (on linux) to find the PersistenceManagerFactoryClass in the APP Engine SDK folder, I could not find it.

Could not instantiate bean class [com.peerbuccoss.apps.mtp.dao.impl.CommonDaoImpl]:  Constructor threw exception; nested exception is javax.jdo.JDOFatalUserException: Class     org.datanucleus.api.jdo.PersistenceManagerFactoryClass was not found.
NestedThrowables:
java.lang.ClassNotFoundException:     org.datanucleus.api.jdo.PersistenceManagerFactoryClass:
java.lang.ClassNotFoundException: org.datanucleus.api.jdo.PersistenceManagerFactoryClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at javax.jdo.JDOHelper$18.run(JDOHelper.java:2018)
at javax.jdo.JDOHelper$18.run(JDOHelper.java:2017)
at java.security.AccessController.doPrivileged(Native Method)
at javax.jdo.JDOHelper.forName(JDOHelper.java:2015)
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1162)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:808)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1093)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:919)
shameem_z
  • 71
  • 2
  • 6
  • 1
    I have change the property javax.jdo.PersistenceManagerFactoryClass with the value org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory and it works fine. – shameem_z Jun 22 '12 at 04:27
  • So you're using v1 of the GAE JDO plugin. Obviously that is ancient so will likely hit problems later. Better to use v2 of that plugin – DataNucleus Jun 22 '12 at 05:34
  • @DataNucleus Thanks for your response. I have migrated from v1 to v2 and using the configuration from Google (https://developers.google.com/appengine/docs/java/datastore/jdo/overview-dn2#Creating_the_jdoconfig_xml_File), am having the same issue "Class org.datanucleus.api.jdo.PersistenceManagerFactoryClass was not found". – shameem_z Jun 22 '12 at 11:16
  • 3
    Googles notes are wrong/incomplete. You need to follow http://code.google.com/p/datanucleus-appengine/wiki/UpgradingToVersionTwo Why they haven't included complete instructions you'd have to ask them ... – DataNucleus Jun 22 '12 at 11:21
  • @DataNucleus I will go through it and post an update when I'm done. Thanks – shameem_z Jun 22 '12 at 11:24
  • @DataNucleus I have been able to update my project dependencies and on my local machine it's running fine. No issue. I have deploy my application on the Google App Engine Server, I am facing this issue Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/datanucleus/jpa/exceptions/NoPersistenceXmlException. Did i miss some other jars that i need to bundle together before doing the deployment? Thanks. – shameem_z Jun 22 '12 at 16:09
  • If you have that you've got unnecessary/incorrect jars in the CLASSPATH. datanucleus-api-jpa, datanucleus-api-jdo, datanucleus-core, datanucleus-appengine are the only ones containing the name "datanucleus" that are required ... as per that wiki page. – DataNucleus Jun 22 '12 at 16:19
  • Thanks for your help. By the way. do i need to add datanucleus-api-jpa in my CLASSPATH, even though I am using JDO? – shameem_z Jun 22 '12 at 16:34
  • I have added the jars datanucleus-jpa and it is now working fine.. Thanks a lot for your help. – shameem_z Jun 22 '12 at 16:59
  • No, don't add "datanucleus-jpa" ... as is said in all DN docs, that is for v1 and v2 of DataNucleus. You are using v3. I said datanucleus-api-jpa ... and that is if you are using JPA, or using JPA metadata with JDO – DataNucleus Jun 22 '12 at 17:05
  • i have added only datanucleus-api-jpa. and my application is up and running on google engine server. Thanks for your assistance. – shameem_z Jun 22 '12 at 19:35

1 Answers1

3

In my case I was using datanucleus-appengine-2.1.2 instead of datanucleus-appengine-1.0.10. With version 2.1.2 you must update your jdconfig.xml with the following PersistenceManagerFactoryClass:

<property name="javax.jdo.PersistenceManagerFactoryClass"
       value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>

My jdconfig.xml is:

<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">

   <persistence-manager-factory name="transactions-optional">
       <property name="javax.jdo.PersistenceManagerFactoryClass"
           value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
       <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
       <property name="javax.jdo.option.NontransactionalRead" value="true"/>
       <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
       <property name="javax.jdo.option.RetainValues" value="true"/>
       <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
       <property name="datanucleus.appengine.singletonPMFForName" value="true"/>
   </persistence-manager-factory>
</jdoconfig>
Juan Diego
  • 31
  • 2