1

我试图将使用 REASTEasy 2.0.1.GA 的 Web 应用程序更新到 2.3.0.GA 或更高版本。我遇到了加载问题org.jboss.resteasy.plugins.spring.SpringContextLoaderListener

我猜失败不会加载我的spring bean,因此我遇到了找不到org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter 的类的问题。该类位于类路径中(来自 spring-orm-3.0.6.RELEASE.jar),所以我认为还有其他事情发生。有任何想法吗?下面是我的 web.xml 和堆栈跟踪。

Tomcat 7 启动:

 INFO: Initializing Spring root WebApplicationContext
    Dec 7, 2012 2:12:57 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [${jpa.vendor.adapter}] for bean with name 'jpaVendorAdapter' defined in class path resource [spring/gen2-context-api.xml]; nested exception is java.lang.ClassNotFoundException: ${jpa.vendor.adapter}
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1261)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1330)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:317)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:396)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:390)
        at org.jboss.resteasy.plugins.spring.SpringBeanProcessor.findResteasyRegistrations(SpringBeanProcessor.java:283)
        at org.jboss.resteasy.plugins.spring.SpringBeanProcessor.postProcessBeanFactory(SpringBeanProcessor.java:220)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:603)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
        at org.jboss.resteasy.plugins.spring.SpringContextLoaderListener.contextInitialized(SpringContextLoaderListener.java:44)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:559)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1399)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
        at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
        at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:849)
        at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:351)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
        at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ClassNotFoundException: ${jpa.vendor.adapter}
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1282)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1253)
        ... 47 more
    Dec 7, 2012 2:13:06 PM org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    Dec 7, 2012 2:13:06 PM org.apache.catalina.core.ApplicationContext log
    INFO: Shutting down log4j

网页.xml:

//Listeners and servlets only
 <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>   
    <listener>
        <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
    </listener>
    <listener>
        <listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</listener-class>
    </listener>
    <!-- newly added -->
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</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>/consumer/rest-api/*</url-pattern>
    </servlet-mapping>   
4

1 回答 1

0

RestEasy 有问题SpringContextListener。它不处理属性占位符 -${...}请参阅RESTEASY-787

Caused by: java.lang.ClassNotFoundException: ${jpa.vendor.adapter}

${jpa.vendor.adapter}应该用一些类定义替换。

您必须将 RestEasy 替换SpringContextListener为默认值org.springframework.web.context.ContextLoaderListener,并在您的 spring XML 配置中声明 bean,如下所示:

<bean class="org.jboss.resteasy.plugins.spring.SpringBeanProcessorServletAware"/>

然后它应该工作。

于 2014-03-12T00:13:30.233 回答