ClassNotFoundException:com.google.gwt.dev.shell.jetty.JettyNullLogger

时间:2015-02-02 06:33:00

标签: java gwt jboss jetty errai

我正在使用GWT 2.7,Errai 3.1.1 Final。我想用Eclipse的Dev模式运行Errai + GWT示例项目。我将程序参数添加为-server org.jboss.errai.cdi.server.gwt.JettyLauncher

我的pom.xml文件是从here引用的。当我跑步时,我的控制台出现以下错误。

Unable to load server class 'org.jboss.errai.cdi.server.gwt.JettyLauncher'java.lang.ClassNotFoundException: org.jboss.errai.cdi.server.gwt.JettyLauncher
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at com.google.gwt.dev.DevMode$ArgHandlerServer.setString(DevMode.java:177)
at com.google.gwt.util.tools.ArgHandlerString.handle(ArgHandlerString.java:26)
at com.google.gwt.util.tools.ToolBase.processArgs(ToolBase.java:250)
at com.google.gwt.dev.ArgProcessorBase.processArgs(ArgProcessorBase.java:30)
at com.google.gwt.dev.DevMode.main(DevMode.java:412)
Google Web Toolkit 2.7.0
DevMode [-[no]startServer] [-port port-number | "auto"] [-whitelist whitelist-string] [-blacklist blacklist-string] [-logdir directory] [-logLevel level] [-gen dir] [-bindAddress host-name-or-address] [-codeServerPort port-number | "auto"] [-[no]superDevMode] [-server servletContainerLauncher[:args]] [-startupUrl url] [-war dir] [-deploy dir] [-extra dir] [-modulePathPrefix ] [-workDir dir] [-XmethodNameDisplayMode NONE | ONLY_METHOD_NAME | ABBREVIATED | FULL] [-sourceLevel [auto, 1.6, 1.7]] [-XjsInteropMode [NONE, JS, CLOSURE]] [-[no]incremental] module[s]

<小时/> 修改:现在我添加以下依赖项来修复它

    <dependency>  
     <groupId>org.jboss.errai</groupId>  
     <artifactId>errai-cdi-jetty</artifactId>
     <version>2.4.5.Final</version>
    </dependency>

但是另一个错误出现如下

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gwt/dev/shell/jetty/JettyNullLogger
at org.jboss.errai.cdi.server.gwt.JettyLauncher.<clinit>(JettyLauncher.java:558)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at com.google.gwt.dev.DevMode$ArgHandlerServer.setString(DevMode.java:177)
at com.google.gwt.util.tools.ArgHandlerString.handle(ArgHandlerString.java:26)
at com.google.gwt.util.tools.ToolBase.processArgs(ToolBase.java:250)
at com.google.gwt.dev.ArgProcessorBase.processArgs(ArgProcessorBase.java:30)
at com.google.gwt.dev.DevMode.main(DevMode.java:412)
Caused by: java.lang.ClassNotFoundException: com.google.gwt.dev.shell.jetty.JettyNullLogger
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 8 more

我不知道这是什么以及如何解决它。

1 个答案:

答案 0 :(得分:0)

我只是在我的工作区中实现了缺少的类public class JettyNullLogger implements org.mortbay.log.Logger(假设一个空记录器不应该做太多...),它似乎已经解决了。

后续例外是java.lang.IllegalStateException: No such servlet: javax.ws.rs.core.Application。 所以我将jetty的javax.ws.rs.core.Application的默认实现添加到了web.xml:

<servlet>
    <servlet-name>Rest</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Rest</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

这需要添加

compile 'com.sun.jersey:jersey-core:1.+'
compile 'com.sun.jersey:jersey-server:1.+'
compile 'com.sun.jersey:jersey-servlet:1.+'

到类路径。