Announcement Announcement Module
Collapse
No announcement yet.
Why eclipse is asking to register session scope of a bean..? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why eclipse is asking to register session scope of a bean..?

    Hi,

    I am trying to use spring security. I have declared UserDomain class as session bean:


    Code:
    <bean id="userDomain" class="com.infosys.enr.user.domain.UserDomain" scope="session">
    <aop:scoped-proxy />
    </bean>
    Now I m using its instance like this:

    Code:
    public static void main(String arg[])
    	{
    		ApplicationContext classpathCtx = new ClassPathXmlApplicationContext("enrapp-servlet.xml");
    		UserDomain userDomain = (UserDomain) classpathCtx.getBean("userDomain");
    		userDomain.setEmailId("[email protected]");
    				  
    	}
    The code is very simple bt I am getting the error:

    Code:
    No Scope registered for scope 'session'
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
    	at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
    	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.getTarget(Cglib2AopProxy.java:653)
    	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:604)
    	at com.infosys.enr.user.domain.UserDomain$$EnhancerByCGLIB$$9cabb04f.setEmailId(<generated>)
    	at com.infosys.enr.user.main.Main.main(Main.java:18)
    My web.xml is:


    Code:
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>/WEB-INF/enrapp-servlet.xml</param-value>
    	</context-param>
      
      
    
      <listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
      
      <listener>
    <listener-class>
    org.springframework.web.context.request.RequestContextListener
    </listener-class>
    </listener>
    
      
      <error-page>
        <exception-type>java.lang.Exception</exception-type>
        <location>/WEB-INF/pages/error.jsp</location>
    </error-page>
    
    <!-- Spring Security -->
    	<filter>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<filter-class>
                      org.springframework.web.filter.DelegatingFilterProxy
                    </filter-class>
    	</filter>
     
    	<filter-mapping>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<url-pattern>/*</url-pattern>
    		<dispatcher>REQUEST</dispatcher>
            <dispatcher>INCLUDE</dispatcher>  
            <dispatcher>FORWARD</dispatcher>
    	</filter-mapping>
    
    <session-config>      
    <session-timeout>120</session-timeout>    
    </session-config>
    What is the problem..?? WHy I should register session scope??

  • #2
    Have you actually READ the reference guide... session scope only works in a web environment, the code you are using isn't running in a web container nor a web environment. Your main is pretty much useless for session scopes.

    Comment


    • #3
      Because you registered the UserDomain object as a session scoped bean. Spring Security does not typically use session scope. I'd suggest you go through the Spring Security documentation and examples to learn more about Spring Security. If you are confused about the session scope, read more about it on Spring's documentation.

      Comment


      • #4
        Why eclipse is asking to register session scope of a bean..?

        Thank you all for the reply..I read the documentation from the spring source only...but I was mainly concerned with its implementation part....anyways I will try that out using test cases...

        Comment

        Working...
        X