BeanFactory not initialized or already closed - call 'refresh' before accessing beans

前端 未结 7 1297
太阳男子
太阳男子 2021-01-03 23:09

I\'m trying to add spring security to a regular JSF application. After repeated tries and I\'m failing with the following error on tomcat bring-up.

Here is the entir

相关标签:
7条回答
  • 2021-01-03 23:48

    I had this issue until I removed the project in question from the server's deployments (in JBoss Dev Studio, right-click the server and "Remove" the project in the Servers view), then did the following:

    1. Restarted the JBoss EAP 6.1 server without any projects deployed.
    2. Once the server had started, I then added the project in question to the server.

    After this, just restart the server (in debug or run mode) by selecting the server, NOT the project itself.

    This seemed to flush any previous settings/states/memory/whatever that was causing the issue, and I no longer got the error.

    0 讨论(0)
  • 2021-01-03 23:49

    You need to add RequestContextListener to your web.xml what it does is namely bind the HTTP request object to the Thread that is servicing that request. This makes beans which are request- and session-scoped available further down the call chain.

    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    
    0 讨论(0)
  • 2021-01-03 23:54

    I had the same problem, and it turned out there's an issue with the maven spring dependency chain. Dependency org.springframework spring-context was imported with version 3.0.5, whereas the overall spring version I was using was 3.2.2. Explicitly adding the dependency in my pom.xml solved it.

    I detected the issue by using the -verbose:class jvm argument when running the server, and checking the jars classes in the XmlWebApplicationContext inheritance tree were loaded from.

    0 讨论(0)
  • 2021-01-03 23:56

    use this dependecy in your pom.xml

    <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${springframework.version}</version> </dependency>

    0 讨论(0)
  • 2021-01-03 23:59

    While removing the comments from a particular block in applicationcontext.xml, I missed out to remove --> "The end of comment". I didn't notice it and was as getting this error.

    Later removed it and all was working fine!!

    0 讨论(0)
  • 2021-01-04 00:01

    I see this code in applicationContext-security.xml:

    <beans:beans xmlns="http://www.springframework.org/schema/security"
                 xmlns:beans="http://www.springframework.org/schema/beans"
                 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-3.0.xsd
               http://www.springframework.org/schema/security
               http://www.springframework.org/schema/security/spring-security-3.0.xsd">
    

    You might be using incorrect spring version. For example, if you are using spring-xxx (spring-security-web.jar or spring-security-core.jar) version 3.1.xx in your library, this error will come out. Try change the code in applicationContext-security.xml from 3.0.xsd to 3.1.xsd (the version number in the code must match back to the version sit in the library folder).

    Hope this help.

    0 讨论(0)
提交回复
热议问题