- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用谷歌应用引擎制作一个网络应用程序。我以前没有使用 GWT。但出于某种原因,现在我想使用 Window.Location.getHref()。我添加了 GWT SDK 和所有 gwt jars 文件。但是现在当我调用 Window.Location.getHref() 时,我得到了 java.lang.ExceptionInInitializerError。这是日志:
2011-08-23 01:17:22.193 /indexpage 500 543ms 1423cpu_ms 0kb Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
90.230.245.85 - - [23/Aug/2011:01:17:22 -0700] "GET /indexpage HTTP/1.1" 500 0 "http://runnotest.appspot.com/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1" "runnotest.appspot.com" ms=544 cpu_ms=1423 api_cpu_ms=0 cpm_usd=0.039580 instance=00c61b117c2bd11a01e44ceafe4dc9ee198fb4
W 2011-08-23 01:17:22.183
Error for /indexpage
java.lang.ExceptionInInitializerError
at com.google.gwt.user.client.Window$Location.getHash(Window.java:172)
at com.eplinovo.runno3test.mahmood.action.IndexPageServlet.doGet(IndexPageServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:262)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:9819)
at com.google.net.rpc.impl.RpcUtil.handleRequest(RpcUtil.java:445)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:414)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:579)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:454)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:694)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:332)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:324)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:452)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code! It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:92)
at com.google.gwt.user.client.Window.<clinit>(Window.java:508)
... 38 more
W 2011-08-23 01:17:22.185
Nested in java.lang.ExceptionInInitializerError:
java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code! It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:92)
at com.google.gwt.user.client.Window.<clinit>(Window.java:508)
at com.google.gwt.user.client.Window$Location.getHash(Window.java:172)
at com.eplinovo.runno3test.mahmood.action.IndexPageServlet.doGet(IndexPageServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:262)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:9819)
at com.google.net.rpc.impl.RpcUtil.handleRequest(RpcUtil.java:445)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:414)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:579)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:454)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:694)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:332)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:324)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:452)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
C 2011-08-23 01:17:22.186
Uncaught exception from servlet
java.lang.ExceptionInInitializerError
at com.google.gwt.user.client.Window$Location.getHash(Window.java:172)
at com.eplinovo.runno3test.mahmood.action.IndexPageServlet.doGet(IndexPageServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:262)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:9819)
at com.google.net.rpc.impl.RpcUtil.handleRequest(RpcUtil.java:445)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:414)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:579)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:454)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:694)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:332)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:324)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:452)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code! It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:92)
at com.google.gwt.user.client.Window.<clinit>(Window.java:508)
... 38 more
知道为什么我得到 java.lang.ExceptionInInitializerError 以及如何摆脱它吗?提前致谢。
代码如下:
public class IndexPageServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
PersistenceManager pm = PMF.get().getPersistenceManager();
try
{
String token = Window.Location.getHref();
out.println("Token: " + token);
// .... rest of the code
}
catch(Exception ex)
{
System.out.println("Error fetching runs: " + ex);
}
finally
{
pm.close();
}
}
}
最佳答案
在服务器上,您指的是在静态 block 中调用 GWT.create()
的类。你不能那样做。
您的代码中的问题是 Window.Location.getHref()
- 这在服务器上不可用。如果您想获取当前 url,请使用 serlvet api 中的 request.getRequestURL()
。
您无法访问服务器上的 anchor 参数 (#foo
)。它们不是从客户端发送的。您必须在客户端解析它们并将它们作为请求参数发送。
关于java - 为什么我得到 java.lang.ExceptionInInitializerError 以及如何摆脱它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7158181/
我在项目的不同领域遇到了以下异常。最糟糕的是我不知道它是什么......我的项目中没有 com.b.a.c.b 包。我尝试在网络上搜索,但仍然不明白是什么导致了此异常。 在从另一个 Activity
当我尝试单独运行 junit 测试时,出现此错误。当我尝试使用 Ant(它运行所有测试)运行它时,它运行良好。谁能告诉我可能的原因是什么? src 文件夹和 test 文件夹在同一层次结构中。我必须链
考虑以下类: sealed class Fruit(val id: String, val label: String) { object orange : Fruit("Citrus sinen
编译良好: static final Screen screen = Screen.getInstance(); static final InputListener listener = Input
我正在尝试读取 jar 包中的文件 (blip3.out)。我正在使用 getResourceAsStream 获取 url,然后尝试从中读取。我已经进行了多次尝试,并使用其他帖子中的解决方案,但仍然
我将一个项目导入到 eclipse 中并添加了依赖项(仅 oracle 驱动程序和 junit4)。但是当我尝试运行该项目时,我收到 ExceptionInInitializerError 。由于某种
当我尝试运行以下代码时,我收到 ExceptionInInitializerError 而不是空指针异常。为什么? static { String s= null; System.out.
我正在尝试使用 Class.forName 从我的对象调用方法,但出现 java.lang.ExceptionInInitializerError class MainClass(implicit v
我收到了ExceptionInInitializerError。我被告知“getException() 方法现在被称为原因,并且可以通过 Throwable.getCause() 方法以及前面提到的“
我是 Applet 编程新手,想要制作一个 Applet 放在网站上。那么我们开始吧。 这个项目的目标是,如果您单击该按钮,它将在浏览器顶部打开一个 JFrame。但在测试时,它给了我一个 java.
我使用 swing JFrame 作为我的应用程序的 MainFrame。我有一个按钮应该创建一个新窗口。但它会在初始化时崩溃,我不知道为什么。 public class Dialog { p
下面是我在运行服务器时从 netbeans IDE 得到的错误。正如错误所说 Uncompilable source code - Projects.ApplicationMenu is not ab
我正在使用兼容性类来构建用户代理字符串: public abstract class Compatibility { private static int sdkInt = 0; pr
编辑:已解决,但我不明白为什么 在 PokemonEnum 中我有这行 private PokemonEnum[ ] pokemon = PokemonEnum.values(); 我把它改为: pr
我正在尝试初始化 GL11,因为我在引用一个有 的方法时遇到了麻烦 GL11 gl 作为它的参数。我试图在我的渲染器类中初始化它,但它没有用,所以我认为它的初始化搞乱了渲染器并创建了一个新类来初始化。
我在一些论坛上搜索过,这似乎是一个常见问题。但是我找不到解决方案。我没有做任何疯狂的事情,所以发生这种情况似乎很奇怪。 @Override protected Scene onCreateScene(
我一定是在做一些非常愚蠢的事情,但是当我尝试在我的单例中实例化一个对象时,我得到了一个 ExceptionInInitializerError: class MySingleton { priva
请注意,我知道关于的规则 ExceptionInInitializerErrors 它说:任何静态 block 中抛出的异常被包装到ExceptionInInitializerError 然后抛出 E
我在尝试运行我的应用程序时意外遇到了 ExceptionInIntiialize 错误。我相信当用户点击快速聊天按钮时会提示错误。 10-09 18:27:08.450: E/AndroidRunti
当启动 JavaFX 应用程序(嵌入了 Swing 代码)作为 Webstart 时,会发生以下错误: java.lang.ExceptionInInitializerError at com
我是一名优秀的程序员,十分优秀!