Announcement Announcement Module
Collapse
No announcement yet.
Problem with session scope. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with session scope.

    Hey guys, I am having a problem when trying to use a bean with a session life cycle as described in the reference documentation (3.4.3)

    Here is the bean definition for the session scoped bean (A shopping cart)

    Code:
    <bean id="shoppingBasketBean" class="org.helpme.ShoppingBasket" scope="session">
        <aop:scoped-proxy/>
    </bean>
    Here is the bean definition for the controller I wish to use

    Code:
    <bean id="shoppingBasketController" class="org.helpme.ShoppingBasketController" lazy-init="true">
            <property name="requireSession" value="true"/>
            <property name="shoppingBasketBean" ref="shoppingBasketBean"/>
            <property name="methodNameResolver" ref="shoppingBasketNameResolver"/>            
    </bean>
    Here is the error I get

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoriesAdminFacade' defined in class path resource [core.xml]: "Initialization of bean failed; nested exception is null Caused by: java.lang.IllegalArgumentException: Cannot subclass final class class" $Proxy6
        at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
        at net.sf.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
        at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
        at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
        at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
        at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:195)
        at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:150)
        at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:72)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:389)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:246)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:282)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:884)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:240)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:132)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:153)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByName(AbstractAutowireCapableBeanFactory.java:612)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:569)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:392)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:240)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:132)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:153)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:612)
        at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:194)
        at org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initApplicationContext(SimpleUrlHandlerMapping.java:96)
        at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
        at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:86)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:268)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:871)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:240)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:132)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:237)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:153)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:254)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:337)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
        at org.springframework.test.AbstractSpringContextTests.loadContextLocations(AbstractSpringContextTests.java:130)
        at org.springframework.test.AbstractDependencyInjectionSpringContextTests.loadContextLocations(AbstractDependencyInjectionSpringContextTests.java:224)
        at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:110)
        at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:192)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    The error does not ac cur if I remove the <aop:scoped-proxy/> in the shopping cart definition but this is obviously essential to functionality.

    All the java code if pretty standard and there are no final classes to be seen.
    If anybody kind enough to offer there help believes the java code would be beneficial let me know and I will post it asap.

    How do you guys do testing with session scoped beans? At the moment I subclass AbstractDependencyInjectionSpringContextTests but that uses ConfigurableApplicationContext as apposed to the WebApplicationContext.

    Once again thank you to anyone who takes there time to help me solve my problem
Working...
X