2015-02-09 61 views
2

我想給RestEasy的有如下彈簧4集成:RestEasy的Spring集成錯誤

的web.xml


<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
        version="3.0"> 
    <display-name>RestEasy Webapp</display-name> 
    <listener> 
     <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> 
    </listener> 
    <listener> 
     <listener-class>org.jboss.resteasy.plugins.server.SpringContextLoaderListener</listener-class> 
    </listener> 
    <servlet> 
     <servlet-name>Resteasy</servlet-name> 
     <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> 
</servlet> 
<servlet-mapping> 
    <servlet-name>Resteasy</servlet-name> 
    <url-pattern>/rest/*</url-pattern> 
</servlet-mapping> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath:applicationContext.xml</param-value> 
</context-param> 
<context-param> 
    <param-name>resteasy.servlet.mapping.prefix</param-name> 
    <param-value>/rest</param-value> 
</context-param> 
<context-param> 
    <param-name>resteasy.scan</param-name> 
    <param-value>false</param-value> 
</context-param> 
</web-app> 

的applicationContext.xml


<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans.xsd 
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context.xsd"> 
       <context:annotation-config/> 
       <context:component-scan base-package="lesson.resteasy"/> 
</beans> 

我的依賴配置如下:有幾個更多的依賴關係。

<dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-spring</artifactId> 
     <version>3.0.9.Final</version> 
     <exclusions> 
      <exclusion> 
       <artifactId>commons-logging</artifactId> 
       <groupId>commons-logging</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>jaxb-impl</artifactId> 
       <groupId>com.sun.xml.bind</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>sjsxp</artifactId> 
       <groupId>com.sun.xml.stream</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>jsr250-api</artifactId> 
       <groupId>javax.annotation</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>activation</artifactId> 
       <groupId>javax.activation</groupId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

在乾淨的構建之後將其部署到Tomcat時,出現以下錯誤。

SEVERE: Error configuring application listener of class org.jboss.resteasy.plugins.server.SpringContextLoaderListener 
java.lang.ClassNotFoundException: org.jboss.resteasy.plugins.server.SpringContextLoaderListener 
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) 
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) 
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532) 
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514) 
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142) 
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4854) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at java.lang.Thread.run(Thread.java:745) 

Feb 09, 2015 10:47:14 AM org.apache.catalina.core.StandardContext listenerStart 
SEVERE: Skipped installing application listeners due to previous error(s) 
Feb 09, 2015 10:47:14 AM org.apache.catalina.core.StandardContext startInternal 
SEVERE: Error listenerStart 

你能幫我解決這個問題嗎?

回答

1

應該

org.jboss.resteasy.plugins.spring.SpringContextLoaderListener 

org.jboss.resteasy.plugins.server.SpringContextLoaderListener 

因此ClassNotFoundException

+0

謝謝@peeskillet,這解決了這一問題。儘管我必須添加更多的依賴關係。再次感謝你。 – Mouli 2015-02-09 06:01:26