NutzCN Logo
问答 Nutz入门helloworld,用jetty插件启动报Error scanning file MainModule.class错误,怎么解决
发布于 1759天前 作者 自律 1830 次浏览 复制 上一个帖子 下一个帖子
标签:
C:\Java9\bin\java -Dmaven.multiModuleProjectDirectory=D:\nutzProjects\helloworld -DarchetypeCatalog=internal -Dmaven.home=D:\developmaven\apache-maven-3.5.2 -Dclassworlds.conf=D:\developmaven\apache-maven-3.5.2\bin\m2.conf "-javaagent:D:\developwindow\IDEA\IntelliJ IDEA 2017.3.2\lib\idea_rt.jar=6144:D:\developwindow\IDEA\IntelliJ IDEA 2017.3.2\bin" -Dfile.encoding=UTF-8 -classpath D:\developmaven\apache-maven-3.5.2\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version=2017.3.2 -s D:\developmaven\apache-maven-3.5.2\conf\settings.xml org.eclipse.jetty:jetty-maven-plugin:9.4.3.v20170317:run
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> jetty-maven-plugin:9.4.3.v20170317:run (default-cli) > test-compile @ helloworld >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\nutzProjects\helloworld\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ helloworld ---
[INFO] No sources to compile
[INFO] 
[INFO] <<< jetty-maven-plugin:9.4.3.v20170317:run (default-cli) < test-compile @ helloworld <<<
[INFO] 
[INFO] 
[INFO] --- jetty-maven-plugin:9.4.3.v20170317:run (default-cli) @ helloworld ---
[INFO] Configuring Jetty for project: helloworld Maven Webapp
[INFO] webAppSourceDirectory not set. Trying src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = D:\nutzProjects\helloworld\target\classes
[INFO] Logging initialized @8252ms to org.eclipse.jetty.util.log.Slf4jLog
[INFO] Context path = /
[INFO] Tmp directory = D:\nutzProjects\helloworld\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = file:///D:/nutzProjects/helloworld/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = D:\nutzProjects\helloworld\src\main\webapp
[INFO] jetty-9.4.3.v20170317
[INFO] Scanning elapsed time=459ms
[WARNING] Failed startup of context o.e.j.m.p.JettyWebAppContext@3bd6ba24{/,file:///D:/nutzProjects/helloworld/src/main/webapp/,UNAVAILABLE}{file:///D:/nutzProjects/helloworld/src/main/webapp/}
java.lang.RuntimeException: Error scanning file MainModule.class
    at org.eclipse.jetty.annotations.AnnotationParser.parseDir (AnnotationParser.java:712)
    at org.eclipse.jetty.annotations.AnnotationParser.parseDir (AnnotationParser.java:689)
    at org.eclipse.jetty.annotations.AnnotationParser.parseDir (AnnotationParser.java:689)
    at org.eclipse.jetty.annotations.AnnotationParser.parse (AnnotationParser.java:830)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call (AnnotationConfiguration.java:159)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run (AnnotationConfiguration.java:464)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:672)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run (QueuedThreadPool.java:590)
    at java.lang.Thread.run (Thread.java:844)
Caused by: java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init> (Unknown Source)
    at org.objectweb.asm.ClassReader.<init> (Unknown Source)
    at org.objectweb.asm.ClassReader.<init> (Unknown Source)
    at org.eclipse.jetty.annotations.AnnotationParser.scanClass (AnnotationParser.java:959)
    at org.eclipse.jetty.annotations.AnnotationParser.parseDir (AnnotationParser.java:705)
    at org.eclipse.jetty.annotations.AnnotationParser.parseDir (AnnotationParser.java:689)
    at org.eclipse.jetty.annotations.AnnotationParser.parseDir (AnnotationParser.java:689)
    at org.eclipse.jetty.annotations.AnnotationParser.parse (AnnotationParser.java:830)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call (AnnotationConfiguration.java:159)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run (AnnotationConfiguration.java:464)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:672)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run (QueuedThreadPool.java:590)
    at java.lang.Thread.run (Thread.java:844)
[INFO] Started ServerConnector@6824b913{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @9325ms
[INFO] Started Jetty Server

下面是web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <display-name>helloworld</display-name>
  <filter>
    <filter-name>nutz</filter-name>
    <filter-class>org.nutz.mvc.NutFilter</filter-class>
    <init-param>
      <param-name>modules</param-name>
      <param-value>demo.hello.MainModule</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>nutz</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>
</web-app>

public class MainModule {
    @At("/hello")
    @Ok("jsp:jsp.hello")
    public String doHello() {
        return "Hello Nutz";
    }
}
3 回复

jetty插件版本低,无法与你的jdk匹配,换最新版好了

大佬我用的是jdk9,
jetty的依赖是
org.eclipse.jetty
jetty-maven-plugin
9.4.3.v20170317

不知道支持jdk9的jetty版本号,求告知,网上没有搜到

谢谢大佬,告诉我错误的原因,支持jdk9的,jetty插件版本号找到了

添加回复
请先登陆
回到顶部