连接到 SQLite 数据库时出现 GAE 限制 class 错误
GAE restricted class error when connecting to SQLite database
我正在使用 Eclipse Neon、GWT 和 sqlite 编写 Web 应用程序。我的 webapp 在某个点连接到位于 war
目录中的数据库(为了使数据库对服务器可用是必需的)。当我尝试创建连接时,严格以读取模式:
Properties config = new Properties();
config.setProperty("open_mode", "1");
Class.forName("org.sqlite.JDBC");
return DriverManager.getConnection("jdbc:sqlite:db.db");
控制台出现以下异常堆栈:
java.lang.NoClassDefFoundError: java.io.FileOutputStream is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:52)
at org.sqlite.SQLiteJDBCLoader.extractAndLoadLibraryFile(SQLiteJDBCLoader.java:165)
at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:290)
at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:65)
at org.sqlite.core.NativeDB.load(NativeDB.java:53)
at org.sqlite.core.CoreConnection.open(CoreConnection.java:211)
at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:24)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:23)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
at org.sqlite.JDBC.createConnection(JDBC.java:114)
at org.sqlite.JDBC.connect(JDBC.java:88)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
[...]
我实际上只是打开了一个到数据库的连接。日志被转发到控制台,因此没有打开文件来存储它们,我也没有创建文件。错误源自 GAE 和 JDBC 加载器,我无法控制它们。
我做错了什么?
我会回答我自己的问题...答案是,我不需要 GAE,所以我不得不禁用它。我从 war/WEB-INF/lib 中删除了所有 GoogleAppEngine jar,并通过在 Eclipse 上导航禁用了 AppEngine:
RightClick on project -> Google -> AppEngine Settings... -> detick "Use Google AppEngine"
希望对其他人有所帮助。
我正在使用 Eclipse Neon、GWT 和 sqlite 编写 Web 应用程序。我的 webapp 在某个点连接到位于 war
目录中的数据库(为了使数据库对服务器可用是必需的)。当我尝试创建连接时,严格以读取模式:
Properties config = new Properties();
config.setProperty("open_mode", "1");
Class.forName("org.sqlite.JDBC");
return DriverManager.getConnection("jdbc:sqlite:db.db");
控制台出现以下异常堆栈:
java.lang.NoClassDefFoundError: java.io.FileOutputStream is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:52)
at org.sqlite.SQLiteJDBCLoader.extractAndLoadLibraryFile(SQLiteJDBCLoader.java:165)
at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:290)
at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:65)
at org.sqlite.core.NativeDB.load(NativeDB.java:53)
at org.sqlite.core.CoreConnection.open(CoreConnection.java:211)
at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:24)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:23)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
at org.sqlite.JDBC.createConnection(JDBC.java:114)
at org.sqlite.JDBC.connect(JDBC.java:88)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
[...]
我实际上只是打开了一个到数据库的连接。日志被转发到控制台,因此没有打开文件来存储它们,我也没有创建文件。错误源自 GAE 和 JDBC 加载器,我无法控制它们。
我做错了什么?
我会回答我自己的问题...答案是,我不需要 GAE,所以我不得不禁用它。我从 war/WEB-INF/lib 中删除了所有 GoogleAppEngine jar,并通过在 Eclipse 上导航禁用了 AppEngine:
RightClick on project -> Google -> AppEngine Settings... -> detick "Use Google AppEngine"
希望对其他人有所帮助。