Sunday, March 31, 2013

GAE No connectivity to local dev MySQL instance with data nucleus

I am trying to get a Development Google App Engine app working with JPA, Google Cloud SQL, and a local MySQL database. I am using the GAE eclipse plugin. I have signed up for a Google cloud SQL instance. Configured the app engine settings on the project to use Google Cloud SQL and put in the connectivity info for the local MySQL database and for the cloud SQL instance.

The data nucleus enhancers picks up my 57 classes and I see the log with the classes successfully optimized. I run my application within Eclipse and the dev environment fires up successfully and I can get to my app through the browser. I copied the mysql driver jar file to the lib of the app engine sdk.

The issue is that the data in the database cannot be retrieved through from the JPA calls. I don't see any errors in the application output. I run through the debugger and the JPA calls run successfully without throwing an exception in my app source code. I get an empty list from retrieval. Checked the datanucleus.log file. The only thing I see is the optimization output.

My guess is that there is something failing but the error could be swallowed or maybe a restriction. I also tried changing the JPA calls by using criteria builder and then using straight up JPQL. Still get the same results.

Checked the arguments to the local GAE dev server and I see the arguments that are being used from the configuration that I typed in for the local mysql server. I did some digging around and enabled the mysql general logging and I don't see anything written to the log for queries that should be created from datanucleus. I also do not see a connection when I connect with MySQL workbench and look at the active connections in the administration section. I know the connectivity information that I entered for the google cloud sql local mysql instance is correct, because I went back and changed the port and I got an error when I applied the changes. I changed back to the right port and the changes accepted successfully.

Any help would be appreciated. Not sure where to go from here. I have researched online for quite some time and I am tired and frustrated.

Persistence.xml - (with only 2 classes for testing)

<persistence-unit name="iberis-jpa">      <provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>      <class>com.bizznetworxonline.iberis.core.SystemArea</class>      <class>com.bizznetworxonline.iberis.core.SystemUnit</class>        <exclude-unlisted-classes>true</exclude-unlisted-classes>        <properties>          <property name="datanucleus.NontransactionalRead" value="true"/>          <property name="datanucleus.NontransactionalWrite" value="true"/>          <property name="datanucleus.ConnectionURL" value="appengine"/>      </properties>  </persistence-unit>


JPA Call:

public List<?> findAll(Class<?> entityClass)   {        EntityManager em = JPA_EMF.get().createEntityManager();        javax.persistence.Query q = em.createQuery("SELECT o FROM " + entityClass.getSimpleName() + " o",entityClass);        List<?> results = q.getResultList();        return results;  }

Console Output:


Mar 30, 2013 9:49:06 PM com.google.apphosting.utils.config.AppEngineWebXmlReader    readAppEngineWebXml    INFO: Successfully processed /home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-INF/appengine-web.xml    Mar 30, 2013 9:49:06 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml    INFO: Successfully processed /home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-INF/web.xml    Mar 30, 2013 9:49:06 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties    INFO: Overwriting system property key 'java.util.logging.config.file', value '/home/user/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/com.google.appengine.eclipse.sdkbundle_1.7.6/appengine-java-sdk-1.7.6/config/sdk/logging.properties' with value 'WEB-INF/logging.properties' from '/home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-INF/appengine-web.xml'    Mar 30, 2013 9:49:07 PM com.google.apphosting.utils.jetty.JettyLogger info  INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger    Mar 30, 2013 9:49:07 PM com.google.apphosting.utils.jetty.JettyLogger info  INFO: jetty-6.1.x    Mar 30, 2013 9:49:10 PM com.sun.faces.config.ConfigureListener contextInitialized  INFO: Initializing Mojarra 2.1.12 ( 20120814-1522) for context ''    Mar 30, 2013 9:49:13 PM com.sun.faces.spi.InjectionProviderFactory createInstance  INFO: JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.    Mar 30, 2013 9:49:21 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent  INFO: Running on PrimeFaces 3.5    Mar 30, 2013 9:49:21 PM org.primefaces.extensions.application.PostConstructApplicationEventListener processEvent  INFO: Running on PrimeFaces Extensions 0.6.3    Mar 30, 2013 9:49:22 PM com.google.apphosting.utils.jetty.JettyLogger info  INFO: Started SelectChannelConnector@127.0.0.1:8888    Mar 30, 2013 9:49:22 PM com.google.appengine.tools.development.AbstractServer startup  INFO: Server default is running at http://localhost:8888/    Mar 30, 2013 9:49:22 PM com.google.appengine.tools.development.AbstractServer startup  INFO: The admin console is running at http://localhost:8888/_ah/admin    Mar 30, 2013 9:49:22 PM com.google.appengine.tools.development.DevAppServerImpl start  INFO: Dev App Server is now running    Mar 30, 2013 9:49:35 PM com.google.appengine.api.datastore.dev.LocalDatastoreService init  INFO: Local Datastore initialized:   Type: High Replication  Storage: /home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-INF/appengine-generated/local_db.bin    Mar 30, 2013 9:49:35 PM com.google.appengine.api.datastore.dev.LocalDatastoreService load  INFO: The backing store, /home/user/Documents/eclipse-workspace/IberisAdmin/war/WEB-   INF/appengine-generated/local_db.bin, does not exist. It will be created.    Mar 30, 2013 9:49:37 PM com.google.apphosting.utils.jetty.JettyLogger warn


--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment