基本上嘗試通過我的Eclipse的Java Web項目谷歌App Engine的Java中與崩潰 '的AccessControlException:訪問被拒絕......' 異常
清單
1) Updated my Google App Engine SDK to the latest 1.9.34 version
2) Updated my JDBC com.mysql.jdbc.Driver to the latest 5.1.38 version
3) Added the JDBC Driver to the build path
我連接到我的Cloud SQL資料庫根本無法連接到Google Cloud SQL,並因此出現此錯誤而崩潰:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:454)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
at java.lang.Thread.init(Thread.java:391)
at java.lang.Thread.init(Thread.java:349)
at java.lang.Thread.<init>(Thread.java:445)
at java.util.TimerThread.<init>(Timer.java:499)
at java.util.Timer.<init>(Timer.java:101)
at java.util.Timer.<init>(Timer.java:146)
at com.mysql.jdbc.ConnectionImpl.<clinit>(ConnectionImpl.java:208)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:65)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:233)
at com.dinuka.myapp.servlets.PlanServlet.doPost(PlanServlet.java:59)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
搜索整天,字面意思就是t通過Stackoverflow上的每個相關問題。我正要拉我的頭髮:D
這是我連接到我的數據庫的可笑的簡單代碼。不能相信我做錯了:
public class MyServlet extends HttpServlet {
@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();
}
}
}
請修復這個錯誤,Google團隊!同時,有人能幫我解決這個問題嗎?
什麼奇怪的,司機沒有涉及到'Timer'什麼的5.1.38版本的'ConnectionImpl.java:208' - https://開頭github上。 com/mysql/mysql-connector-j/blob/5.1.38/src/com/mysql/jdbc/ConnectionImpl.java#L208 你確定你使用合法的jar嗎? –
你能把我和合法的罐子聯繫起來嗎? @IgorArtamonov – Dinuka
試試這個http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.38 –