我在web.xml中配置了Resteasy servlet和监听器
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this should be the same URL pattern as the servlet-mapping property -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
当我尝试在JBoss-as-web-7.0.0.Final上部署EAR时,我收到错误:
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap: java.lang.NoClassDefFoundError:javax / servlet / ServletContext
我的EAR里面包含war和EJB jar,如果它有意义的话。
答案 0 :(得分:1)
1)您需要在项目中使用servlet api依赖项,如下所示:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
OR
在类路径中添加javax.servlet-3.0.jar
文件。
2)转到<JBOSS-HOME>/standalone/configuration/standalone.xml
找到元素
<subsystem xmlns="urn:jboss:domain:ee:1.0" />
并将其替换为
<subsystem xmlns="urn:jboss:domain:ee:1.0">
<global-modules>
<module name="javaee.api" slot="main"/>
</global-modules>
</subsystem>`
3)转到
JBoss\jboss-eap-6.1\modules\system\layers\base\javax\servlet\api\main
包括JAR
jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar
我建议您仅使用Jboss AS 7.1.1.Final版本而不是7.0.0 Final。