Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: bean reinstanciation upon request

  1. #21
    Join Date
    Jun 2007
    Location
    Oslo, Norway
    Posts
    153

    Default

    Quote 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 at 03:30 AM.

  2. #22
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    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

    Quote 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.

  3. #23
    Join Date
    Jun 2007
    Location
    Oslo, Norway
    Posts
    153

    Default

    Quote 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 at 04:43 AM.

  4. #24
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    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

    Quote 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.

  5. #25
    Join Date
    Jun 2007
    Location
    Oslo, Norway
    Posts
    153

    Default

    Quote 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 at 06:27 AM.

  6. #26
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote 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

Posting Permissions

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