acesso negado ("java.lang.RuntimePermission" "modifyThreadGroup")
Estou desenvolvendo um aplicativo de servidor usando o Google Appengine e o Goodle Cloud SQL. Tenho um problema ao tentar me conectar ao SQL da nuvem ao executar o servidor na minha máquina local. Eu recebo o erro:
java.security.AccessControlException: acesso negado ("java.lang.RuntimePermission" "modifyThreadGroup")
Aqui está o código do servlet:
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 the form to POST to this url");
}
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String url = null;
try {
if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
// Load the class that provides the 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 to 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 {
} finally {
conn.close();
}
} catch (SQLException e) {
out.append(e.getMessage());
e.printStackTrace();
}
}
}
Adicionei a seguinte linha ao arquivo java.policy:
permissão java.lang.RuntimePermission "modifyThreadGroup";
Mas isso não resolveu o problema.