title: Spring 3.0.5 prototype Bean Instance variables become null after method call
body: <p>Having the strangest Spring problem where after a Spring bean is created using Dependency Injection, and then running some method on the bean, the instance variables that are set during the bean method call all return to their default Java values.  Found this happening after we moved from Spring 2.5.5 to Spring 3.0.5.</p>
  
  <p>So for clarity sake here is the example</p>
  
  <p>The Prototype bean:</p>
  
  <pre><code>@Component("bean1")
  @Scope("prototype")
  public class Bean1{
      String someString;//There are other instance variables but same happens to them
  
      @Autowired
      @Qualifier("otherBean")
      private OtherBean otherBean;
  
      public void doSomething(){
           someString="1234ABC";
      }
      //setters and getters ....
  }
  </code></pre>
  
  <p>And the code that grabs the bean from spring and uses it:</p>
  
  <pre><code>Bean1 bean1 = (Bean1) applicationContext.getBean("bean1");
  bean1.doSomething();//updates some instance variables in bean1
  String value = bean1.getSomeString();  //Instance variables is null
  Object otherObject = bean1.getOtherBean(); //This Spring injected bean is correctly initialized
  </code></pre>
  
  <p>So if I debug into the code, the instance variables (someString) is set in bean while in the doSomething method call but right after I return, the value goes back to null.</p>
  
  <p>Worst thing is that this all works as expected in 2.5.5 but not in the updated Spring 3.0.5 </p>
  
  <p>This is legacy code so I know that you are supposed to code to interfaces and so the Bean1 should be an interface and the class that implements the interface should do the actual work.  I changed the code to this model as well and still does not work. </p>