Can you try sample that I have posted in the previous mail?
If it works as well for you, then check once more your configuration.
And concerning final local variable - it has nothing to do with it. I (wild) guess that you do more then one change per try, so it may be not clear which change caused this ot that effect.
I just changed signature to your here is new output:
As you can see nothing is changed - all bean instances are still different.Code:2007-07-25 16:30:15,916 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] - <Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@dd5b: display name [org.springframework.context.support.ClassPathXmlApplicationContext@dd5b]; startup date [Wed Jul 25 16:30:15 CEST 2007]; root of context hierarchy> 2007-07-25 16:30:16,057 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path resource [myContext.xml]> 2007-07-25 16:30:16,277 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] - <Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@dd5b]: org.springframework.beans.factory.support.DefaultListableBeanFactory@337d0f> 2007-07-25 16:30:16,308 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@337d0f: defining beans [B1,B2,B3]; root of factory hierarchy> Bean3  Bean2  First fetch of B1 [B1@147c5fc] Bean3  Bean2  Second fetch of B1 [B1@64dc11]
I just created a simple example with one class and defined it in application context as prototype. Output was different for each time..
However. I can not see any difference from my other application in the definition of my prototype bean.
Should beCode:System.out.println(System.identityHashCode("Bean1 Hash: " + someService)); System.out.println(System.identityHashCode("Bean2 Hash: " + someService2));
WhileCode:System.out.println("Bean1 Hash: " + System.identityHashCode(someService)); System.out.println("Bean2 Hash: " + System.identityHashCode(someService2));
Should beCode:<bean id="someUtilities" class="SomeUtilities" scope="prototype"> <property name="someUtilities" ref="someUtilities" /> </bean>
I have used pseudonyms for my actual code and by doing so I got some type errors.Code:<bean id="someUtilities" class="SomeUtilities" scope="prototype"> <property name="someUtilities" ref="someTypeUtilities" /> </bean>
Last edited by DJViking; Jul 25th, 2007 at 12:41 PM.
BTW, I'm quite sure that ifyou would try to prepare such example by "stripping out" your code and configuration step-by-step, then in this process you will find cause of the problem
My testapplication was a simple runtime application, while the other is a web application. This shouldn't have any bearing on the result.
Edit: I increased the context xml in the small test application to include the complete context xml I use in the web application. And still the prototype bean work as it should. So I can see no fault with the Spring configuration.
Do I need to use a WebApplicationContext, even if I don't use Spring MVC?
Last edited by DJViking; Jul 26th, 2007 at 03:10 AM.
Concerning test application and real application - they, very likely , differs in a way how they load context. It is quite possible that in web application you load not that context that you mean to load (very typical error if you would look in the threads in this forum), especially if you have complicated context structure (e. g. multiply context files).
Try to make copy of your real application and strip it out step-by-step till you find a problem or obtain example that you may reveal.