我正在我的项目中开发一个新的Rest Web服务。但是当我点击 url 它的抛出错误时,下面我提到了我的网络.xml文件代码以及我得到的错误。提前谢谢。
我已写入 Web.xml 文件
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>6</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
17:01:03,026 INFO [com.sun.jersey.api.core.servlet.WebAppResourceConfig] (http--0.0.0.0-8080-1) Scanning for root resource and provider classes in the Web app resource paths:
/WEB-INF/lib
/WEB-INF/classes
17:01:03,030 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (http--0.0.0.0-8080-1) StandardWrapper.Throwable: java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.init(WebAppResourceConfig.java:102) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:89) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:74) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebComponent.getWebAppResourceConfig(WebComponent.java:672) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:415) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:582) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebServletConfig.getDefaultResourceConfig(WebServletConfig.java:87) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:703) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) [jersey-bundle-1.14.jar:1.14]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80-ea]
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassVisitor from [Module "deployment.TTKServices.ear.web.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 27 more
17:01:03,088 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/].[jersey-serlvet]] (http--0.0.0.0-8080-1) Allocate exception for servlet jersey-serlvet: java.lang.ClassNotFoundException: org.objectweb.asm.ClassVisitor from [Module "deployment.TTKServices.ear.web.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.init(WebAppResourceConfig.java:102) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:89) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:74) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebComponent.getWebAppResourceConfig(WebComponent.java:672) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:415) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:582) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebServletConfig.getDefaultResourceConfig(WebServletConfig.java:87) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:703) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) [jersey-bundle-1.14.jar:1.14]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) [jersey-bundle-1.14.jar:1.14]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80-ea]
怀疑:1 我可以使用哪些 jar 来开发 rest Web 服务。2 您能否建议我有关 rest 服务项目中的配置步骤。
你之所以java.lang.NoClassDefFoundError
,是因为你的pom中缺少一些依赖关系。
尝试将 asm 依赖项添加到您的项目 pom 中.xml
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
</dependency>