Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » need to build servlet twice before changes have any effect
need to build servlet twice before changes have any effect [message #709769] Thu, 04 August 2011 05:27 Go to next message
Alex  is currently offline Alex
Messages: 3
Registered: August 2011
Junior Member
Hello,
I create a "Dynamic Web Project", add a servlet to it and run it in Tomcat 6.0 (Eclipse Helios).

When I make changes to the servlet, build the project again and restart Tomcat, the changes haven't been applied.
I have to make another change (like changing some irrelevant string), rebuild and restart again, so that the previous (not the latest!) change is applied.

Why is the application running in Tomcat always one step behind of what was built in eclipse? And how do I get rid of this behaviour?

Thanks
Alex
Re: need to build servlet twice before changes have any effect [message #709936 is a reply to message #709769] Thu, 04 August 2011 09:10 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1304
Registered: July 2009
Senior Member
On 8/4/2011 5:27 AM, Alex wrote:
> Hello,
> I create a "Dynamic Web Project", add a servlet to it and run it in
> Tomcat 6.0 (Eclipse Helios).
>
> When I make changes to the servlet, build the project again and restart
> Tomcat, the changes haven't been applied.
> I have to make another change (like changing some irrelevant string),
> rebuild and restart again, so that the previous (not the latest!) change
> is applied.
>
> Why is the application running in Tomcat always one step behind of what
> was built in eclipse? And how do I get rid of this behaviour?
>
> Thanks
> Alex

A Tomcat server with default settings will publish the project to
"<your_workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp?\wtpwebapps"
where it is served by Tomcat. Is the servlet class being updated in the
"<webapp>\WEB-INF\classes" folder at the publish location after the
first change to the servlet? Also, please confirm that the Tomcat
server indicates it needs to Restart in the Servers view after the first
change.

Cheers,
Larry
Re: need to build servlet twice before changes have any effect [message #709969 is a reply to message #709936] Thu, 04 August 2011 10:41 Go to previous messageGo to next message
Alex  is currently offline Alex
Messages: 3
Registered: August 2011
Junior Member
Larry Isaacs wrote on Thu, 04 August 2011 09:10

A Tomcat server with default settings will publish the project to
"<your_workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp?\wtpwebapps"
where it is served by Tomcat. Is the servlet class being updated in the
"<webapp>\WEB-INF\classes" folder at the publish location after the
first change to the servlet?

No, the classes don't update if I change their java source and choose Project->Build Project. I found that the context menu of the Tomcat entry in the Servers tab has a "Publish" menu entry which updates those classes. I have never used this "Publish" function, but for some reason the classes got published after every second server restart.
Is the publishing supposed to happen automatically? What triggers the publishing? Or do I have to trigger it manually after each project build step? (By the way, I disabled Project-> Build Automatically)
I seem to be missing some information. Maybe I forgot to RTFM Embarrassed ... *which* manual?

Quote:

Also, please confirm that the Tomcat
server indicates it needs to Restart in the Servers view after the first
change.

Cheers,
Larry

Where does it indicate that it needs to be restarted? In the Servers tab I see:
"Tomcat v6.0 Server at localhost [Started, Synchronized]"
Sometimes the brackets included "Restart", but not after every project build step. How does the server recognize when it needs to be restarted?

Thank you
Alex
Re: need to build servlet twice before changes have any effect [message #710130 is a reply to message #709969] Thu, 04 August 2011 14:20 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1304
Registered: July 2009
Senior Member
On 8/4/2011 10:41 AM, Alex wrote:
> Larry Isaacs wrote on Thu, 04 August 2011 09:10
>> A Tomcat server with default settings will publish the project to
>> "<your_workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp?\wtpwebapps"
>> where it is served by Tomcat. Is the servlet class being updated in
>> the "<webapp>\WEB-INF\classes" folder at the publish location after
>> the first change to the servlet?
>
> No, the classes don't update if I change their java source and choose
> Project->Build Project. I found that the context menu of the Tomcat
> entry in the Servers tab has a "Publish" menu entry which updates those
> classes. I have never used this "Publish" function, but for some reason
> the classes got published after every second server restart.
> Is the publishing supposed to happen automatically? What triggers the
> publishing? Or do I have to trigger it manually after each project build
> step? (By the way, I disabled Project-> Build Automatically)
> I seem to be missing some information. Maybe I forgot to RTFM :blush:
> ... *which* manual?
>
> Quote:
>> Also, please confirm that the Tomcat server indicates it needs to
>> Restart in the Servers view after the first change.
>>
>> Cheers,
>> Larry
>
> Where does it indicate that it needs to be restarted? In the Servers tab
> I see:
> "Tomcat v6.0 Server at localhost [Started, Synchronized]"
> Sometimes the brackets included "Restart", but not after every project
> build step. How does the server recognize when it needs to be restarted?
>
> Thank you
> Alex
>

With Build Automatically off, I would not expect the class file for the
servlet to get updated. If the class file isn't updated, there isn't
anything new to publish. The indication in the Servers view should
remain "[Started, Synchronized]". There may be something about the
second save that could somehow be triggering a build, which updates the
class file and the desired behavior follows. If you want the server to
get updated following the first change, you will need to force a build
or turn Build Automatically back on.

Cheers,
Larry
Re: need to build servlet twice before changes have any effect [message #710625 is a reply to message #710130] Fri, 05 August 2011 04:29 Go to previous messageGo to next message
Alex  is currently offline Alex
Messages: 3
Registered: August 2011
Junior Member
Quote:
If you want the server to
get updated following the first change, you will need to force a build
or turn Build Automatically back on.


This is what I did: force a build (Project->Build Project) after each change (and save) of the servlet. Neither this forced build nor an automatic build (when enabled) trigger the publishing. Publishing only happends occasionally.

Alex
Re: need to build servlet twice before changes have any effect [message #710826 is a reply to message #710625] Fri, 05 August 2011 08:59 Go to previous message
Larry Isaacs is currently offline Larry Isaacs
Messages: 1304
Registered: July 2009
Senior Member
On 8/5/2011 4:29 AM, Alex wrote:
> Quote:
>> If you want the server to
>> get updated following the first change, you will need to force a build
>> or turn Build Automatically back on.
>
>
> This is what I did: force a build (Project->Build Project) after each
> change (and save) of the servlet. Neither this forced build nor an
> automatic build (when enabled) trigger the publishing. Publishing only
> happends occasionally.
>
> Alex

After the build occurs, does the Servers view show the Tomcat server as
needing a Restart. If so, then the publish should occur automatically
if you have that turned on in the Publishing section of the server
editor. If automatic publishing is not enabled, then the publish should
occur when the server is restarted (also when started if the server is
stopped).

Cheers,
Larry
Previous Topic:why does eclipse keeps validating my entire workspace?
Next Topic:FATAL [main] Main - No embedded stylesheet instruction for file:
Goto Forum:
  


Current Time: Fri Aug 01 20:46:16 EDT 2014

Powered by FUDForum. Page generated in 0.01594 seconds