Friday, December 28, 2012

Re: App Engine Cloud SQL project running locally on mySQL dev environment Access Denied


1) To correct the error: java.security.AccessControlException: access
denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc
Java VM has security permission that restrict the VM from running some
things that access local resources when running in a browser.  The
Java VM default is throw exception on anything sun.*
In your Java SDK directory you need to remove or modify these
permission.  Modify JDK1.7.0_05\jre\lib\security\java.security file as
below:
Change (remove the sun.,):
FROM
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
TO
package.access=com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.

Change (not totally necessary but to avoid other problems):
FROM
package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
to
package.definition=com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.

This may leave open other java programs sun.* calls to local access
but for dev purposes this is the quickest solution without knowing
specifically what the AppEngine Driver is doing locally and messing
with app signing and policy files.

2) To correct the error "java.lang.ClassNotFoundException:
com.mysql.jdbc.Driver while calling that function"
The docs say that the CLASSPATH gets added automatically by the
plugin.  This is not the case for the mySQL JDBC JAR driver that you
add to the Google Appengine mySQL settings.

Go to Windows -> Control Panel -> System -> Advanced Settings ->
Advanced Settings -> Environment Variables -> System Variables
Add a variable:  CLASSPATH with a value C:\Java\mySQL-JDBC  (or
wherever you stored your mySql JDBC jar mysql-connector-java-5.1.21-
bin.jar)

 
NOW the example guestbook app posted on the Google CloudSQL
documentation will work on a local mySQL instance thought Google
Eclipse Plugin on Windows.  There is NOW WAY it could have possibly
worked for anyone as posted for Eclipse with GPE under Windows,
although everyone who has posted an issue about this was simply
redirected to re-read the documentation.  I assume they just got
frustrated and must have gave up on it as no-one ever posted any
"thanks, it works now"

Thanks a lot John! I had troubles with the two exceptions mentioned above, but I solved thanks to your suggestions.

Best regards,
Saverio.

No comments:

Post a Comment