Reputation: 489
I am attempting to connect my android app to my backend endpoints (in Google's App Engine) so that I can store my java objects in Google's datastore. However when I try to initialize the PersistenceManagerFactory
object, I get the error seen at the end of this post - The PersistenceManagerFactory class must define a static method
.
I am trying to initialize the object using the following code, and note: I do have the library in the classpath.
public static PersistenceManagerFactory InitializePersistanceManagerClass(){
Properties properties = new Properties();
properties.setProperty("javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
properties.setProperty("javax.jdo.option.ConnectionURL", "appengine");
properties.setProperty("javax.jdo.option.NontransactionalRead", "true");
properties.setProperty("javax.jdo.option.NontransactionalWrite", "true");
properties.setProperty("javax.jdo.option.RetainValues", "true");
properties.setProperty("datanucleus.appengine.autoCreateDatastoreTxns", "true");
properties.setProperty("datanucleus.appengine.singletonPMFForName", "true");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
return pmf;
}
There is no line number listed in the error, however I am 90% sure the problem lies in the code above, or the class that I am using for the persistenceManagerFactory
. The error when this code runs appears below. Any ideas? I really don't understand what the problem is....
08-23 09:10:31.826 7932-7932/com.myApp.myModule E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.myApp.myModule, PID: 7932
javax.jdo.JDOFatalInternalException: The PersistenceManagerFactory class must define a static method
PersistenceManagerFactory getPersistenceManagerFactory(Map props).
The class "org.datanucleus.jdo.JDOPersistenceManagerFactory"
defines a non-static getPersistenceManagerFactory(Map props) method.
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(Unknown Source)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(Unknown Source)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(Unknown Source)
at com.myApp.myModule.forStorage.PMF.<init>(Unknown Source)
at com.myApp.myModule.Login.onConnected(Unknown Source)
at wz.a(Unknown Source)
at rb.e(Unknown Source)
at rb.d(Unknown Source)
at rd.onConnected(Unknown Source)
at wz.a(Unknown Source)
at wz.a(Unknown Source)
at wy.a(Unknown Source)
at wy.a(Unknown Source)
at wv.b(Unknown Source)
at wu.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:668)
at dalvik.system.NativeStart.main(Native Method)
NestedThrowablesStackTrace:
java.lang.NullPointerException
at javax.jdo.JDOHelper.forName(Unknown Source)
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(Unknown Source)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(Unknown Source)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(Unknown Source)
at com.myApp.myModule.forStorage.PMF.<init>(Unknown Source)
at com.myApp.myModule.Login.onConnected(Unknown Source)
at wz.a(Unknown Source)
at rb.e(Unknown Source)
at rb.d(Unknown Source)
at rd.onConnected(Unknown Source)
at wz.a(Unknown Source)
at wz.a(Unknown Source)
at wy.a(Unknown Source)
at wy.a(Unknown Source)
at wv.b(Unknown Source)
at wu.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:668)
at dalvik.system.NativeStart.main(Native Method)
Upvotes: 1
Views: 483
Reputation: 271
From the javax/jdo/Bundle.properties
, we can see the below definition.
EXC_GetPMFNullPointerException
= The PersistenceManagerFactory
class must define a static methodPersistenceManagerFactory getPersistenceManagerFactory(Map props)
. The class "{0}" defines a non-static getPersistenceManagerFactory(Map props)
method.
From the javax.jdo.JDOHelper
source code, we can deduce that the below error message "The PersistenceManagerFactory
class must define a static method PersistenceManagerFactory getPersistenceManagerFactory(Map props)
. The class org.datanucleus.jdo.JDOPersistenceManagerFactory
defines a non-static getPersistenceManagerFactory(Map props)
method." is coming from the below code in invokeGetPersistenceManagerFactoryOnImplementation
method.
catch (NullPointerException e) {
throw new JDOFatalInternalException (msg.msg("EXC_GetPMFNullPointerException", pmfClassName), e);}
This is caused by java.lang.NullPointerException
at javax.jdo.JDOHelper.forName(Unknown Source)
, which is mostly probably coming form Class.forName(name, init, loader);
Anyway, you could modify the javax.jdo.JDOHelper.forName
method to add some more traces & print more exception info in it. It's not difficult.
If requried, you tell me the version for "jdo-api", then, I could provide one for you.
Upvotes: 1