Announcement Announcement Module
Collapse
No announcement yet.
when adding applicationContext I get no bean named 'entityMangerFactory' is defined Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • when adding applicationContext I get no bean named 'entityMangerFactory' is defined

    Yea, yea, yea - I know this post seems to be all over the place, but it seems in my situation that it works just fine until I add an applicationContext.xml file.

    Currently I am working with a spring roo application. Everything works well. I go through the tutorial for adding security and create an applicationContext-security.xml file and throw it in WEB-INF/spring. I worked through several issues and have come to identify this scenario. By default, there was an entry in the web.xml for contextConfigLocation, but is was pointing to META_INF/spring/applicationContext*.xml. I change this to WEB-INF..... and now I get the "no bean named 'entityManagerFactoryApp' is defined. Change it back and everything works fine. Right now for the security piece I do have the springSecurityFilterChain stuff commented out because I get the same error with them (my assumption is that they are first in the list). Just trying to nail it down to one thing here...

    Also had some early issues with the examples I was using for the applicationContext were using security 2.0.xsd - I changed those, just making sure that there is no problems with the namespace stuff too.

    Using STS 2.5.2 - have no problem upgrading if necessary
    Only thing I have changed in the pom is adding spring-security-config, core and web. If you need more infor about versions, please let me know.

    Do I need to mention that I am a nubie?

    web.xml excerpts
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    .
    .
    .
        <context-param>
            <param-name>contextConfigLocation</param-name>
             <!--  <param-value>/WEB-INF/spring/applicationContext*.xml</param-value>  -->
            <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
            <!-- <param-value>classpath*:WEB-INF/spring/applicationContext*.xml</param-value> -->
        </context-param>
    <!--      
        <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
    -->
    .
    .
    .
        <filter>
            <filter-name>HttpMethodFilter</filter-name>
            <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
        </filter>
        
        <filter>
            <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
            <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
        </filter>
    <!-- 
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    -->
    .
    .
    .
        <filter-mapping>
            <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    applicationContext-security.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <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.3.xsd">
    
        <http auto-config="true" use-expressions="true">
            <intercept-url pattern="/login*" access="permitAll()" />
            <intercept-url pattern="/resources/**" access="permitAll()" />
            <intercept-url pattern="/css/**" access="permitAll()" />
            <intercept-url pattern="/**" access="permitAll()"/>
    <!--permitalls are just for testing right now -->
    
            <!--<concurrent-session-control max-sessions="1" exception-if-maximum-exceeded="true"/> -->
    
        </http>
    
    	<authentication-manager>
    	    <authentication-provider>
    	        <user-service>
    	            <user name="edsdev" password="edsdev" authorities="ROLE_ADMIN" />
    		        <user name="test" password="test" authorities="ROLE_USER" />
    		    </user-service>
    		</authentication-provider>
    	</authentication-manager>
    
    </beans:beans>
    Exception is as follows:

    org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'entityManagerFactoryApp' is defined
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:527)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:1083)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:274 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:1079)
    at org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter.lookupEntityManagerFactory(OpenEnt ityManagerInViewFilter.java:151)
    at org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter.lookupEntityManagerFactory(OpenEnt ityManagerInViewFilter.java:135)
    at org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter.doFilterInternal(OpenEntityManager InViewFilter.java:94)
    at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.HiddenHttpMethodFil ter.doFilterInternal(HiddenHttpMethodFilter.java:7 7)
    at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at com.springsource.insight.collection.tcserver.reque st.HttpRequestOperationCollectionValve.invoke(Http RequestOperationCollectionValve.java:64)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:409)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
    Mar 30, 2011 7:54:30 AM org.apache.catalina.core.StandardWrapperValve invoke


  • #2
    Ureka!

    I knew that if I posted this question I would probably figure it out. Ok, so I placed my applicationContext-security.xml file in webapp/WEB-INF/spring. I did not see an original applicationContext.xml file there, so I assumed there was none. Well, roo places it in src/main/resources/META-INF/spring. i had looked for it in the war file and not seen it either, but it is under WEB-INF\classes\META-INF\spring. All my bean definitions were in there and when I switched it to look at the applicationContext-security.xml, I no longer had the bean definitions...

    Anyway, that was MY particular problem.

    Comment

    Working...
    X