You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by kkus <kk...@hotmail.com> on 2007/12/04 17:55:39 UTC

Value can't be changed in bean extended from AbstractController of Spring

Hi,

For the following code, I put String urlReq = "value" first and set up a
breakpoint there. Then I run app in debug mode. It shows me "value" when
breakpoint is reached. Then I change String urlReq = "value2" and fire http
request again. When breakpoint is reached again this time urlReq still
equals to "value" rather than "value2". Why did it happen? Is it related to
servlet thread? I am using Spring 2.0 MVC and tomcat 5.5.20 in XP SP2.
Thanks!

<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="/test.htmll">earthController</prop>
            </props>
        </property>
</bean>

<bean id="earthController" class="action.EarthController" />

public class EarthController extends AbstractController {

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String urlReq = "value";
//logic to return xml response
return null;
}
}
-- 
View this message in context: http://www.nabble.com/Value-can%27t-be-changed-in-bean-extended-from-AbstractController-of-Spring-tf4944277.html#a14154549
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Value can't be changed in bean extended from AbstractControllerof Spring

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: kkus [mailto:kk_us@hotmail.com] 
> Subject: Re: Value can't be changed in bean extended from 
> AbstractControllerof Spring
> 
> But Java can handle hot-swapping for normal Java application
> automatically, so still can't understand why Tomcant can't work
> this way.

Your assumption is incorrect.  Java doesn't handle hot-swapping
automatically; the application (or the environment it's running in) must
make use of the redefineClasses() method of the
java.lang.instrument.Instrumentation interface.  JBoss has code to do
this (part of its AOP implementation), but Tomcat itself does not.
JVMTI agents available with Eclipse, NetBeans, etc., may be able to do
it, but I can't say I'm familiar with them.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Value can't be changed in bean extended from AbstractController of Spring

Posted by kkus <kk...@hotmail.com>.
For JBoss project it has "automatic publishing" checked, I guess that is why
it can hot-swapping properly without restart/redeployment. Thank you for
your pointing!

For Tomcat project I start Tomcat from its bootstrap class, so it will be
treated as a normal Java application rather than a server application. So
there is no automatic publish for Tomcat (maybe that is reason I can't see
changed value?). But Java can handle hot-swapping for normal Java
application automatically, so still can't understand why Tomcant can't work
this way.


Konstantin Kolinko wrote:
> 
> Do you have "Serve modules without publishing" option in Eclipse
> configuration for the server turned on or off?
> 
> (Double click the server on the servers view to open the configuration
> dialog).
> 
> 
> 2007/12/8, kkus <kk...@hotmail.com>:
>>
>> In my another project (JBoss+Spring+Hibernate), I see my changes take
>> effect
>> immediately in Eclipse IDE Debug without restart/redeployment.
>>...
>>
>> This project is Tomcat+Spring+Hibernate.
>>
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Value-can%27t-be-changed-in-bean-extended-from-AbstractController-of-Spring-tf4944277.html#a14221831
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Value can't be changed in bean extended from AbstractController of Spring

Posted by Konstantin Kolinko <kn...@gmail.com>.
Do you have "Serve modules without publishing" option in Eclipse
configuration for the server turned on or off?

(Double click the server on the servers view to open the configuration dialog).


2007/12/8, kkus <kk...@hotmail.com>:
>
> In my another project (JBoss+Spring+Hibernate), I see my changes take effect
> immediately in Eclipse IDE Debug without restart/redeployment.
>...
>
> This project is Tomcat+Spring+Hibernate.
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Value can't be changed in bean extended from AbstractController of Spring

Posted by kkus <kk...@hotmail.com>.
In my another project (JBoss+Spring+Hibernate), I see my changes take effect
immediately in Eclipse IDE Debug without restart/redeployment. I think
JBoss' ClassLoader is working properly for swapping new changes. All these
changes occur in classes extended from SimpleFormController. I use
hot-swapping daily on that project but don't study how it works.

This project is Tomcat+Spring+Hibernate, and changes can be reflected in
class extended from SimpleFormController, not from AbstractController. So I
doubt there is something wrong on ClassLoader for AbstractController but no
clue how to find it out.


Konstantin Kolinko wrote:
> 
>> In this case should I expect to see ... due to Java hot-swapping when
>> breakpoint is reached?
> 
> Obviously, if you do not see it working, it probably does not.
> 
> You should familiarize yourselves with code hot-swapping technology,
> its implications, and how it works upon tomcat, web application
> deployment, and how your IDE interacts with tomcat while debugging.
> 
> Have you searched for any successful examples of using hot-swapping
> while debugging in the IDE that you are using?
> 
> I am not yet familiar with that new hot-swapping technology, and would
> like to know your findings:
> 
> As far as I have observed, Eclipse IDE restarts web application when I
> do changes in its java classes. Sometimes that restart is really fast.
> May be it is what you observed with your controller?
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Value-can%27t-be-changed-in-bean-extended-from-AbstractController-of-Spring-tf4944277.html#a14221448
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Value can't be changed in bean extended from AbstractController of Spring

Posted by Konstantin Kolinko <kn...@gmail.com>.
> In this case should I expect to see ... due to Java hot-swapping when
> breakpoint is reached?

Obviously, if you do not see it working, it probably does not.

You should familiarize yourselves with code hot-swapping technology,
its implications, and how it works upon tomcat, web application
deployment, and how your IDE interacts with tomcat while debugging.

Have you searched for any successful examples of using hot-swapping
while debugging in the IDE that you are using?

I am not yet familiar with that new hot-swapping technology, and would
like to know your findings:

As far as I have observed, Eclipse IDE restarts web application when I
do changes in its java classes. Sometimes that restart is really fast.
May be it is what you observed with your controller?

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Value can't be changed in bean extended from AbstractController of Spring

Posted by kkus <kk...@hotmail.com>.
I changed to "value2" in source code without rebuilding/redeployment. In this
case should I expect to see "value2" due to Java hot-swapping when
breakpoint is reached?

I remembered I can see changed value for class extended from
SimpleFormController in this scenario. I am not sure if it is a ClassLoader
issue for class extended from AbstractController. Does hot-swapping work in
the same servlet/thread or different one? Thanks!


Konstantin Kolinko wrote:
> 
> Isn't is obvious? Why do you expect it to become "value2"?
> 
> What are you changing? Are you changing the source code for the class?
> I do not expect hot-swapping of compiled classes to be available here.
>  If it is the same class instance, it will still be "value".  Restart
> your webapp, or reload your spring context, and it will be "value2"
> 
>> Then I change String urlReq = "value2" and fire http
>> request again. When breakpoint is reached again this time urlReq still
>> equals to "value" rather than "value2".
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Value-can%27t-be-changed-in-bean-extended-from-AbstractController-of-Spring-tf4944277.html#a14217645
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Value can't be changed in bean extended from AbstractController of Spring

Posted by Konstantin Kolinko <kn...@gmail.com>.
Isn't is obvious? Why do you expect it to become "value2"?

What are you changing? Are you changing the source code for the class?
I do not expect hot-swapping of compiled classes to be available here.
 If it is the same class instance, it will still be "value".  Restart
your webapp, or reload your spring context, and it will be "value2"

> Then I change String urlReq = "value2" and fire http
> request again. When breakpoint is reached again this time urlReq still
> equals to "value" rather than "value2".

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org