L'erreur est indiquée ci-dessous. Le problème est, se produisant comme ci-dessous, ce XmlWebApplicationContext n'a pas besoin de se produire, car il injecte à nouveau le bean. Comment l'éviter?
org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Initializing Spring root WebApplicationContext
Sep 08, 2015 12:40:44 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Sep 08, 2015 12:40:44 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Tue Sep 08 12:40:44 IST 2015]; root of context hierarchy
Sep 08, 2015 12:40:44 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/context/PersistenceManagerContext.xml]
Sep 08, 2015 12:40:44 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/context/ServiceApiContext.xml]
Sep 08, 2015 12:40:44 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/context/RuleEngineContext.xml]
Sep 08, 2015 12:40:44 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/context/applicationContext.xml]
Sep 08, 2015 12:40:44 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/context/CacheContext.xml]
Sep 08, 2015 12:40:45 PM org.springframework.web.context.support.XmlWebApplicationContext refresh
WARNING: Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl] for bean with name 'MemberPointSummaryDAOImpl' defined in ServletContext resource [/WEB-INF/context/PersistenceManagerContext.xml]; nested exception is Java.lang.ClassNotFoundException: com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.Java:1351)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.Java:628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.Java:597)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.Java:1444)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.Java:974)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.Java:752)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:834)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.Java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.Java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.Java:107)
at org.Apache.catalina.core.StandardContext.listenerStart(StandardContext.Java:4729)
at org.Apache.catalina.core.StandardContext.startInternal(StandardContext.Java:5167)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:150)
at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1408)
at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1398)
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)
Caused by: Java.lang.ClassNotFoundException: com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl
at org.Apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.Java:1313)
at org.Apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.Java:1164)
at org.springframework.util.ClassUtils.forName(ClassUtils.Java:250)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.Java:394)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.Java:1396)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.Java:1343)
... 19 more
Sep 08, 2015 12:40:45 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl] for bean with name 'MemberPointSummaryDAOImpl' defined in ServletContext resource [/WEB-INF/context/PersistenceManagerContext.xml]; nested exception is Java.lang.ClassNotFoundException: com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.Java:1351)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.Java:628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.Java:597)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.Java:1444)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.Java:974)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.Java:752)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:834)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.Java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.Java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.Java:107)
at org.Apache.catalina.core.StandardContext.listenerStart(StandardContext.Java:4729)
at org.Apache.catalina.core.StandardContext.startInternal(StandardContext.Java:5167)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:150)
at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1408)
at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1398)
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)
Caused by: Java.lang.ClassNotFoundException: com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl
at org.Apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.Java:1313)
at org.Apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.Java:1164)
at org.springframework.util.ClassUtils.forName(ClassUtils.Java:250)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.Java:394)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.Java:1396)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.Java:1343)
... 19 more
Sep 08, 2015 12:40:45 PM org.Apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl] for bean with name 'MemberPointSummaryDAOImpl' defined in ServletContext resource [/WEB-INF/context/PersistenceManagerContext.xml]; nested exception is Java.lang.ClassNotFoundException: com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.Java:1351)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.Java:628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.Java:597)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.Java:1444)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.Java:974)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.Java:752)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:834)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.Java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.Java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.Java:107)
at org.Apache.catalina.core.StandardContext.listenerStart(StandardContext.Java:4729)
at org.Apache.catalina.core.StandardContext.startInternal(StandardContext.Java:5167)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:150)
at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1408)
at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1398)
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)
Caused by: Java.lang.ClassNotFoundException: com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl
at org.Apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.Java:1313)
at org.Apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.Java:1164)
at org.springframework.util.ClassUtils.forName(ClassUtils.Java:250)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.Java:394)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.Java:1396)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.Java:1343)
... 19 more
Web.xml
<!-- USing the dispatcher servlet -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- The pattern is /* -->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- Looking for beans in *Context.xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context/*Context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Dispatcher-Servlet.xml
<!-- <import resource="/WEB-INF/context/*Context.xml"></import> -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
Ensuite, nous avons un tas de xml de contexte disponibles dans le dossier "CONTEXT".
PersistenceManager a cette classe:
[![PersistenceManager is in the war][2]][2]
C'était ma stupidité, mais une stupidité qui n'était pas facile à identifier :).
Problème:
Si vous déployez manuellement sur votre serveur, assurez-vous que votre Java_HOME, JDK_HOME pointe vers le JDK correct que vous avez utilisé pour compiler le projet et construire la guerre.
Si vous n'aimez pas changer Java_HOME, JDK_HOME, vous pouvez toujours changer Java_HOME et JDK_HOME dans catalina.bat (pour le serveur Tomcat) et cela vous facilitera la vie!
La partie importante est la suivante:
Cannot find class [com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl] for bean with name 'MemberPointSummaryDAOImpl' defined in ServletContext resource [/WEB-INF/context/PersistenceManagerContext.xml];
en raison de:
nested exception is Java.lang.ClassNotFoundException: com.rakuten.points.persistence.manager.MemberPointSummaryDAOImpl
Selon ce journal, Spring n'a pas pu trouver votre classe MemberPointSummaryDAOImpl
.
Dans mon cas, j'utilise j-hipster et je devais faire ./mvnw clean
pour surmonter cet avertissement.