google app engine - access denied ("java.lang.RuntimePermission" "modifyThreadGroup") -
i'm developing server application using google appengine , goodle cloud sql. have problem when trying connect cloud sql when running server on local machine. error:
java.security.accesscontrolexception: access denied ("java.lang.runtimepermission" "modifythreadgroup")
here servlet code:
package com.example.example; import com.google.appengine.api.utils.systemproperty; import java.io.ioexception; import java.io.printwriter; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; import javax.servlet.http.*; public class myservlet extends httpservlet { @override public void doget(httpservletrequest req, httpservletresponse resp) throws ioexception { resp.setcontenttype("text/plain"); resp.getwriter().println("please use form post url"); } @override public void dopost(httpservletrequest req, httpservletresponse resp) throws ioexception { string url = null; try { if (systemproperty.environment.value() == systemproperty.environment.value.production) { // load class provides new "jdbc:google:mysql://" prefix. class.forname("com.mysql.jdbc.googledriver"); url = "jdbc:google:mysql://app_id:instance_id/data?user=root"; } else { // local mysql instance use during development. class.forname("com.mysql.jdbc.driver"); url = "jdbc:mysql://instance-ip:3306/data?user=root"; } } catch (exception e) { e.printstacktrace(); return; } printwriter out = resp.getwriter(); try { connection conn = drivermanager.getconnection(url); system.out.println("connection established"); out.println("connection established"); try { } { conn.close(); } } catch (sqlexception e) { out.append(e.getmessage()); e.printstacktrace(); } } }
i have added following line java.policy file:
permission java.lang.runtimepermission "modifythreadgroup";
but did not fix problem.
Comments
Post a Comment