spring java.lang.IllegalStateException: LifecycleProcessor 未初始化 - 在通过上下文调用生命周期方法之前调用“刷新”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6716087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 04:34:53  来源:igfitidea点击:

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context

hibernatespring

提问by Rajkumar

I'm using maven_spring 3.1.M2 + hibernate 3.5. Once I put the line <tx:annotation-driven />in my applicationcontex xml file, the follwoing error will occur:

我正在使用 maven_spring 3.1.M2 + 休眠 3.5。一旦我将该行<tx:annotation-driven />放入我的 applicationcontex xml 文件中,就会发生以下错误:

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 [Sat Jul 16 13:00:52 IST 2011]; 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:534)
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4721)
    at org.apache.catalina.core.StandardContext.call(StandardContext.java:5423)
        at org.apache.catalina.core.StandardContext.call(StandardContext.java:5402)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

What should I do to fix this?

我该怎么做才能解决这个问题?

回答by ChrLipp

Do you have AspectJ in your pom.xml or in your lib-directory?

你的 pom.xml 或 lib 目录中有 AspectJ 吗?

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aspects</artifactId>
    <version>3.1.0.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>${aspectj.version}</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>${aspectj.version}</version>
</dependency>

I had the same error and this solved my problem.

我有同样的错误,这解决了我的问题。

回答by AmitG

I had the same issue, And solution is the Spring jars Now it depends on person to person which spring jar his project is using and actually which one is missing. For me it happened 3-4 times when I created project. Sometime I had all Spring jar but not the Spring.jar Next time Spring Aspect jar was missing. while some other time I had make sure of all but missed security. But I always fixed it by carefully placing the Spring jars. No need to look for any other reason.

我遇到了同样的问题,解决方案是 Spring jars 现在这取决于人与人之间他的项目正在使用哪个 spring jar 以及实际上缺少哪个 spring jar。对我来说,当我创建项目时它发生了 3-4 次。有时我拥有所有 Spring jar 但没有 Spring.jar 下次 Spring Aspect jar 丢失时。而其他时候,我已经确定了所有但错过了安全性。但我总是通过小心地放置弹簧罐来修复它。无需寻找任何其他原因。

Hope that help and focus on only Spring jars and not others. Happy Coding guys!!

希望帮助和专注于 Spring jars 而不是其他。快乐的编码家伙!!

回答by jai

I faced this issue when using both jersey-spring3and spring-core. The jersey-spring3.jar, uses its own version for Spring libraries, so to use the ones you want, you need to exclude these libraries manually.

我在同时使用jersey-spring3和时遇到了这个问题spring-core。jersey-spring3.jar 使用自己的 Spring 库版本,因此要使用您想要的库,您需要手动排除这些库。

<dependency>
        <groupId>org.glassfish.jersey.ext</groupId>
        <artifactId>jersey-spring3</artifactId>
        <version>2.22.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>bean-validator</artifactId>
                <groupId>org.glassfish.hk2.external</groupId>
            </exclusion>
        </exclusions>
    </dependency>

回答by Alireza Alallah

resolve conflict version the spring dependencies in pom.xml, may be in various version change class name or add feature that in other dependencies has incompatibility.

解决Spring依赖中的冲突版本pom.xml,可能在各个版本中更改类名或添加其他依赖中不兼容的特性。