简体   繁体   中英

Error while integrating mongo db with spring

I am trying to integrate mongo db with spring and getting this error,

    WARNING: Exception thrown from LifecycleProcessor on context close
    java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Wed Jul 29 15:07:09 IST 2015]; root of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:350)
        at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1033)
        at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:988)
        at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:578)
        at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
        at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831)
        at 
org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
        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(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

It is probably because of a bug in the DI algorithm as outlined in this ticket on Spring.io . Also refer to this ticket . I also hit the same exception using Spring 4.1.7.RELEASE with spring-data-mongodb-1.7.1.RELEASE. This issue seems to occur whenever spring tries to create a bean that depends on spring-data-mongodb. Your best bet is to wait for Spring 4.2 release tomorrow (July, 30, 2015), as the issue is supposedly fixed in Spring 4.2...we'll just have to see.

I've googled and looked for workarounds to no avail. If someone knows a fix, please let us know!


Update * just tried again with Spring 4.2.0.RELEASE and Spring-data-mongodb:1.7.2.RELEASE. This issue is fixed! :)

Try to use spring version 4.0 as below shown and for more details i have used [ http://www.datastapler.com/mongodb-with-spring-data-rest-webservice.php][1]

<properties>
        <java-version>1.6</java-version>
        <org.springframework-version>4.0.0.RELEASE</org.springframework-version>
        <org.aspectj-version>1.7.4</org.aspectj-version>
        <org.slf4j-version>1.7.5</org.slf4j-version>
        <jackson.databind-version>2.2.3</jackson.databind-version>
    </properties>

<!-- mongodb java driver -->
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>2.11.0</version>
        </dependency>

        <!-- Spring data mongodb -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>1.2.0.RELEASE</version>
        </dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM