Announcement Announcement Module
Collapse
No announcement yet.
bean reinstanciation upon request Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by DJViking View Post
    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.
    So ask somebody to look over your complete configuration and code

    Comment


    • #17
      Originally posted by al0 View Post
      And here someUtilities refrers to itself (circular reference, which is not allowed).
      Those errors was simply a type error
      Code:
      System.out.println(System.identityHashCode("Bean1 Hash: " + someService));
          System.out.println(System.identityHashCode("Bean2 Hash: " + someService2));
      Should be
      Code:
      System.out.println("Bean1 Hash: " + System.identityHashCode(someService));
          System.out.println("Bean2 Hash: " + System.identityHashCode(someService2));
      While
      Code:
            <bean id="someUtilities" class="SomeUtilities" scope="prototype">
                  <property name="someUtilities" ref="someUtilities" />
            </bean>
      Should be
      Code:
            <bean id="someUtilities" class="SomeUtilities" scope="prototype">
                  <property name="someUtilities" ref="someTypeUtilities" />
            </bean>
      I have used pseudonyms for my actual code and by doing so I got some type errors.
      Last edited by DJViking; Jul 25th, 2007, 01:41 PM.

      Comment


      • #18
        Originally posted by DJViking View Post
        Those errors was simply a type error
        ...
        I have used pseudonyms for my actual code and by doing so I got some type errors.
        I have thought so, but it is hard to give some definite suggestion when instead a real code some mess is present. It is absolutely Ok not to reveal a real code, but coud you prepare some working example that exhibits the claimed behavior? It may be posted as an attachment to the message.

        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

        Regards,
        Oleksandr

        Comment


        • #19
          Originally posted by al0 View Post
          I have thought so, but it is hard to give some definite suggestion when instead a real code some mess is present. It is absolutely Ok not to reveal a real code, but coud you prepare some working example that exhibits the claimed behavior? It may be posted as an attachment to the message.

          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

          Regards,
          Oleksandr
          This is frustrating. I took and copied my prototype beans over in a test application with only 5 beans. The code was identical and it worked.

          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, 04:10 AM.

          Comment


          • #20
            Originally posted by DJViking View Post
            This is frustrating. I took and copied my prototype beans over in a test application with only 5 beans. The code was identical and it worked.

            My testapplication was a simple runtime application, while the other is a web application. This shouldn't have any bearing on the result.
            What is frustrating - my advice or the whole situation

            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.

            Regards,
            Oleksandr

            Comment


            • #21
              Originally posted by al0 View Post
              What is frustrating - my advice or the whole situation

              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.

              Regards,
              Oleksandr
              It is frustrating not to find the error. There must be one someplace

              My application would not work if I didn't load the application context that I mean to load(applicationContext.xml). And it loads that one. The application works fine when I create a new application context for each request. But now when I tried to define a bean as prototype so I did not have to load the application context each time. I only have two context files. (applicationContext.xml and DataSource.xml). The DataSource.xml is including in applicationContext.xml

              Edit: I just created a new Web application. Loaded the application context(the entire piece) and prototyping worked.
              Last edited by DJViking; Jul 26th, 2007, 04:30 AM.

              Comment


              • #22
                Is there in your real web application only one context file (no separate contexts for controllers and so on)?

                How are you loading that context - with ContextListener configured in the web.xml or in some other way?

                Can you put in your test web application the whole piece of code from real application that deals with those prototype beans?

                Regards,
                Oleksandr

                Originally posted by DJViking View Post
                It is frustrating not to find the error. There must be one someplace

                My application would not work if I didn't load the application context that I mean to load(applicationContext.xml). And it loads that one. The application works fine when I create a new application context for each request. But now when I tried to define a bean as prototype so I did not have to load the application context each time.

                Edit: I just created a new Web application. Loaded the application context(the entire piece) and prototyping worked.

                Comment


                • #23
                  Originally posted by al0 View Post
                  Is there in your real web application only one context file (no separate contexts for controllers and so on)?

                  How are you loading that context - with ContextListener configured in the web.xml or in some other way?

                  Can you put in your test web application the whole piece of code from real application that deals with those prototype beans?

                  Regards,
                  Oleksandr
                  I have one application context file(applicationContext.xml). Since I have 8 datasources I have seperated these bean in a DataSource.xml which application context import.

                  I load the application context the following way.

                  Code:
                  ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
                  I copied my entire web application code(one servlet) into the test web application and it still worked for the test web application. I have tried running in both WebSphere and Jetty with negative result for the real application as I run the test web application in WebSphere.
                  Last edited by DJViking; Jul 26th, 2007, 05:43 AM.

                  Comment


                  • #24
                    Ok, so it seems that test web application handles context exactly the same way as real application, yes?

                    Then error shall be somewhere in the code of the real application.
                    Hard to say where w/o looking on the real code.

                    Regards,
                    Oleksandr

                    Originally posted by DJViking View Post
                    I have one application context file(applicationContext.xml). Since I have 8 datasources I have seperated these bean in a DataSource.xml which application context import.

                    I load the application context the following way.

                    Code:
                    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
                    I copied my entire web application code(one servlet) into the test web application and it still worked for the test web application. I have tried running in both WebSphere and Jetty with negative result for the real application as I run the test web application in WebSphere.

                    Comment


                    • #25
                      Originally posted by al0 View Post
                      Ok, so it seems that test web application handles context exactly the same way as real application, yes?

                      Then error shall be somewhere in the code of the real application.
                      Hard to say where w/o looking on the real code.

                      Regards,
                      Oleksandr
                      It handles the context exactly the same way with one addedum it works with prototype beans while the real does not.

                      Edit: The error has been found. I had a copy of the applicationContext.xml in WebContent/WEB-INF/classes somehow.
                      Last edited by DJViking; Jul 26th, 2007, 07:27 AM.

                      Comment


                      • #26
                        Originally posted by DJViking View Post
                        It handles the context exactly the same way with one addedum it works with prototype beans while the real does not.

                        Edit: The error has been found. I had a copy of the applicationContext.xml in WebContent/WEB-INF/classes somehow.
                        Exactly, as was predicted

                        Comment

                        Working...
                        X