web-dev-qa-db-fra.com

AVERTISSEMENT: exception rencontrée lors de l'initialisation du contexte - annulation de la tentative de rafraîchissement

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".

Pom: This is my pom

PersistenceManager a cette classe:

[![PersistenceManager is in the war][2]][2]
6
Pavanraotk

C'était ma stupidité, mais une stupidité qui n'était pas facile à identifier :).

Problème:

  1. Mon code est compilé sur Jdk 1.8.
  2. Mon Eclipse, avait JDK 1.8 comme compilateur.
  3. Mon Tomcat dans Eclipse utilisait Java 1.7 pour son conteneur, il n'a donc pas pu comprendre les fichiers .class qui ont été compilés à l'aide de 1.8.
  4. Pour éviter le problème, assurez-vous dans votre Eclipse, double-cliquez sur votre serveur -> Configuration de lancement ouvert -> Classpath -> Bibliothèque système JRE -> Donnez le JDK/JRE de la version compilée de Java classe, dans mon cas, il devait être JDK 1.8
    1. Publiez ceci, nettoyez le serveur, construisez et redéployez, démarrez le Tomcat.

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!

10
Pavanraotk

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.

2
Gergely Bacso

Dans mon cas, j'utilise j-hipster et je devais faire ./mvnw clean pour surmonter cet avertissement.

0
BaDr Amer