Results 1 to 4 of 4

Thread: Session scoped proxy bean not setting properties correctly

  1. #1
    Join Date
    Apr 2007
    Posts
    276

    Default Session scoped proxy bean not setting properties correctly

    There is probably something simple that I am missing here. I am at a loss of what I am doing wrong.

    I have the following proxy bean in my appconfig.xml:
    Code:
    <bean id="userInfo" class="com.xactsites.shared.userinfo.UserInfo" scope="session">
    	<property name="translator" ref="translator" />
    	<property name="test" value="Did this work?" />
    	<aop:scoped-proxy />
    </bean>
    
    <bean id="translator" class="com.xactsites.shared.Translator" scope="singleton">
    	<property name="messageSource" ref="messageSource" />
    </bean>
    I put in the second property test to see if I could get that to work but it doesnt either. The first time I get the userInfo object from the applicationContext these properties are not set (for that matter they are never set). When I do the following:

    Code:
    UserInfo userInfo = (UserInfo)appContext.getBean("userInfo");
    Translator trans1 = (Translator)appContext.getBean("translator");
    String test = userInfo.getTest();
    Translator trans2 = userInfo.getTranslator()
    trans1 gets the singleton bean that I want to be wired into userInfo. However trans2 and even test are null. Am I missunderstanding something? I have used this for a while without wiring in properties to the proxy bean and it has worked wonderfully. I just can't figure out why I can wire in some singleton beans. Thoughts?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    session/request scoped beans work ONLY in a web environment, so if you are using a testcase it isn't going to work.

    So the question I have is HOW are you testing it, what is appContext here?
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2007
    Posts
    276

    Default

    Thanks for your reply. This is not in test. I am in a web environment. I just put in that test property to see if I could get that to get set.

  4. #4
    Join Date
    Apr 2007
    Posts
    276

    Default

    My debugger was displaying null when it really wasnt null. I found this issue in my code after I figured that out. Sorry for the trouble.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •