【发布时间】:2013-03-18 10:11:52
【问题描述】:
我收到此错误:
java.lang.NoClassDefFoundError: java.net.URLStreamHandler 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:51)
at com.gargoylesoftware.htmlunit.protocol.javascript.Handler.<init>(Handler.java:50)
at com.gargoylesoftware.htmlunit.WebClient.<clinit>(WebClient.java:144)
运行我的 GAE 应用程序时,错误出现在此代码块内:
// Setup the headless browser
webClient = new WebClient();
webClient.setWebConnection(new UrlFetchWebConnection(webClient));
我的应用配置了:
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.13-SNAPSHOT</version>
</dependency>
我相信HTMLUnit 有一个补丁可以让它在 GAE 环境中工作,我可能缺少什么?
【问题讨论】:
-
这个例外对我来说很清楚。您不能使用 java.net.URLStreamHandler 并且 HTMLUnit 正在使用它。您应该将测试与 GAE 环境隔离。
-
因为 URLStreamHandler 在白名单中我认为developers.google.com/appengine/docs/java/jrewhitelist
-
@DiogoSantana 我能够使它与 2.13-SNAPSHOT 一起使用
标签: java google-app-engine http servlets