2015-03-30 4 views
0

У меня есть 100% -ное рабочее решение в Tomcat 8.0.20, упакованное как WAR с использованием Spring restful services и весенних базовых библиотек.Весна @ Подходит для классов @Service для Tomcat, но не для смолы

Когда я беру одну и ту же WAR и бросаю ее в Resin 4.0.36 (а также 4.0.43), мои @Autowired @Services не распознаются вообще.

Это заставляет меня полагать, что существует разница в окружающей среде между Tomcat и Resin. Должен ли я установить какое-либо свойство или ссылаться на что-то явно, чтобы заставить WAR работать с Resin?

2015-03-30 17:26:25 WARN XmlWebApplicationContext:487 - Exception  
encountered during context initialization - cancelling refresh attempt 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userInfoWebService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ca.abcc.service.user.UserService ca.abcc.controller.webservice.UserInfo.UserInfoWebService.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ca.abcc.service.user.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) 
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663) 
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629) 
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677) 
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548) 
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489) 
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
at javax.servlet.GenericServlet.init(GenericServlet.java:70) 
at com.caucho.server.dispatch.ServletConfigImpl.createServletImpl(ServletConfigImpl.java:1358) 
at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:1254) 
at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:1205) 
at com.caucho.server.dispatch.ServletManager.init(ServletManager.java:251) 
at com.caucho.server.webapp.WebApp.startImpl(WebApp.java:3777) 
at com.caucho.server.webapp.WebApp.access$700(WebApp.java:208) 
at com.caucho.server.webapp.WebApp$StartupTask.run(WebApp.java:5297) 
at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173) 
at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118) 
Caused by: org.springframework.beans.factory.BeanCreationException: Could 
not autowire field: private ca.abcc.service.user.UserService 
ca.abcc.controller.webservice.UserInfo.UserInfoWebService.userService; 
nested exception is 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No 
qualifying bean of type [ca.abcc.service.user.UserService] found for 
dependency: expected at least 1 bean which qualifies as autowire candidate 
for this dependency. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Autowired(required=true)} 
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostPr 
ocessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561) 
at 
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) 
... 26 more 
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:  
No qualifying bean of type [ca.abcc.service.user.UserService] found 
for dependency: expected at least 1 bean which qualifies as autowire 
candidate for this dependency. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Autowired(required=true)} 
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533) 
... 28 more 
2015-03-30 17:26:25 ERROR DispatcherServlet:497 - Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userInfoWebService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ca.abcc.service.user.UserService ca.abcc.controller.webservice.UserInfo.UserInfoWebService.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ca.abcc.service.user.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202) 
{resin-50} WebApp[production/webapp/default/Impact.Auto.Online.Buyer.Portal] fail 
[15-03-30 17:26:25.294] {resin-15} org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ca.impactauto.service.user.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301) 
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047) 
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942) 
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533) 
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) 
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) 
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202) 
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) 
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) 
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) 
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) 
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) 
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) 
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) 
        at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663) 
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629) 
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677) 
        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548) 
        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489) 
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
        at javax.servlet.GenericServlet.init(GenericServlet.java:70) 
        at com.caucho.server.dispatch.ServletConfigImpl.createServletImpl(ServletConfigImpl.java:1358) 
        at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:1254) 
        at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:1205) 
        at com.caucho.server.dispatch.ServletManager.init(ServletManager.java:251) 
        at com.caucho.server.webapp.WebApp.startImpl(WebApp.java:3777) 
        at com.caucho.server.webapp.WebApp.access$700(WebApp.java:208) 
        at com.caucho.server.webapp.WebApp$StartupTask.run(WebApp.java:5297) 
        at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173) 
        at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118) 

Dispatcher Servlet:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:p="http://www.springframework.org/schema/p" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-4.0.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd 
"> 

<mvc:annotation-driven /> 
<!-- <mvc:default-servlet-handler/>--> 
<!-- <context:annotation-config />--> 
<context:component-scan base-package="ca.xyz.controller" /> 
<context:annotation-config /> 

<bean id="viewResolver"  
class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
    <!-- <property name="viewClass" 
value="org.springframework.web.servlet.view.JstlView" />--> 
    <property name="prefix" value="/WEB-INF/jsp/" /> 
    <property name="suffix" value=".jsp" /> 
</bean> 

<bean id="messageSource" 
class="org.springframework.context.support.ResourceBundleMessageSource"> 
    <property name="basename" value="messages"/> 
</bean> 

<mvc:resources mapping="/resources/**" location="/resources/" /> 

<mvc:view-controller path="/" view-name="welcome"/> 

</beans> 
+0

Какую версию смолы вы используете? Не могли бы вы проверить, загружены ли весенние банки? –

+0

Я использую Resin 4.0.36, и я также попытался развернуть это на 4.0.43. Оба имеют одинаковый тракт стека. Кроме того, загружаются библиотеки Spring, что в конечном итоге приводит к сбою в аутсорсинге. – logixplayer

+0

ОК, можете ли вы включить конфигурацию контекста приложения? –

ответ

0

Пока не знаю, почему, но это в конечном итоге работает. Я должен был идентифицировать каждый файл контекст:

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath:service-context.xml classpath:data-context.xml</param-value> 
</context-param> 

вместо:

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath*:*-context.xml</param-value> 
</context-param> 

оригинальное (последнее) решение отлично работает в Tomcat с классами *: * муравьем стиль джокер поиском, но не так в смоле 4.0.42, 4.0.43 и 4.0.36.