Eclipse Tomcat not Updating - java

I am developing an application with SpringMVC and Tomcat using Eclipse. The problem is: the server does not update the changes I am making.
One example:
#RequestMapping(value = "test", method = RequestMethod.GET)
public ModelAndView test(){
ModelAndView mv = new ModelAndView("test");
System.out.println("test");
return mv;
}
Every time I hit the mapped url, Eclipse prints test in my console. If I comment out the println, I get the same result.
Attempts to fix the problem:
clean Tomcat directory
restart the server
close Eclipse
add/remove the project in the Server tab
delete the JSP the method is using
different browsers
All to no effect. It just looks like Tomcat is not updating any changes I make in the code.

To make Eclipse Tomcat update automatically or hot deploy you have to make certain changes in server configuration:
Below are the steps:
Double clicks on the Tomcat Server, refer to "publishing" tab in the "Overview" view, make sure "Automatically publish when resources change" is selected. This should be the default option, to support “hot deploy” resources, for example : JSP, XML and properties files.
In the Tomcat Plugin page, click on the "Modules" view, Select the Module then click on Edit button and make sure "Auto Reload" is "Disabled". Default is enabled.
Start Project in DEBUG mode. Hot Deploy is supported in DEBUG mode only.

Two more things to check:
deploy directory: in the tomcat server UI and according to "deploy path" configuration, check that the output directory has read/write access (you could also remove it and try to publish again : check expected output resources/classes).
deployment assembly: in project properties menu; in the "deployment assembly" section, check that you are publishing all wanted resources. For example, in my case I download/generate some items from maven custom plugin phase and this resources are not published by default. I had to add some target subdirectories here...

I had roughly the same problem and after tried it all with no success I gave up, created another fresh workspace and the problem was gone. Not the ideal solution but hey, it's an option.

Related

How do I get rid of the below stated issue when I try to add tomcat to Spring Tool suite in Ubuntu?

I am trying to add Tomcat server in to STS but I do am not able to do it. Some times the server name doesn't appear when I try to add Tomcat by selecting it from the list, I can't type in the server name myself as well and If that step works properly (I mean when the serve name appears automatically which it should when server is selected form the list); the Finished button is grayed out in the resource page which is the last step in adding the Tomcat server to STS.
Close Eclipse
In {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings delete the following two files:
org.eclipse.wst.server.core.prefs
org.eclipse.jst.server.tomcat.core.prefs
Restart Eclipse
this is actually a bug.
got this from this question actually Eclipse add Tomcat 7 blank server name

Spring Tool Suite: Copying and renaming a Maven Web App

I have a HelloWorld Java app called FitnessTracker that I want to clone as another name, FDE3, leaving the original website in tact. I performed the following steps an attempt to do this. Please tell me where I went wrong and/or what else I need to do.
Change Context Root
Confirm Change Context Root
Still the original "FitnessTracker" name persists and I'm not sure how to get rid of it.
If I was able to successfully clone the FitnessTracker webapp as FDE3, I should be able to access the new site as
http://localhost:8080/FDE3
But I get an invalid resource error. Instead, the site is still accessible as
http://localhost:8080/FitnessTracker
..because of reminants of the old name.
What do I need to change within Spring Tool Suite to get the web app to use only the new name? To minimize chance of corruptying the project, I'd rather do it via the STS GUI over manual modification of any system file.
I see that the following file contains the text "FitnessTracker" but I would rather not modify it manully for fear of breaking. What GUI option controls this?
Search "fitnesstracker" (2 hits in 1 file)
C:\Dev\Workspace\FDE3\.settings\org.eclipse.wst.common.component (2 hits)
Line 2: <wb-module deploy-name="FitnessTracker">
Line 7: <property name="java-output-path" value="/FitnessTracker/target/classes"/>
Sorry for being a noob.
Update:
I'm not sure what I did, maybe just clean, refresh, open/close a million time, dunno, but now when I run the web server from with the Spring IDE the site is coming up using the FDE3 path, however, I am wondering why I see a reference to Fitness in Parens in the project node.
Earlier, it just displayed "FitnessTracker" in parens, now I see a full path to a Test folder...
Update 2:
When I copied the FitnessTracker project as FDE3, I didn't expect that the new FDE3 project would have any ties to FitnessTracker project and I didn't think that the new FD3 project would be in SVN until I added it to SVN, but based on the icons I see below, it looks like it is, (I'm new to SVN, too)
It looks like my issues are related to SVN.
Why is there a tie to the original FT project and why? How should I have clone the FitnessTracker project?
Yes, your issue is indeed related to SVN. Copying an SVN working copy will copy .svn folders inside that and will be pointing to the same URL in the SVN repository. What you have to do is an SVN Export of your FitnessTracker project to FitnessTracke-Ex first in either Tortoise or Subclipse SVN client and then import that project into your STS Eclipse environment. Finally you can copy and rename the FitnessTracke-Ex project FDE2 or FDE3
See this
post on how to Export a working copy
See this post on how to Import an existing project into Eclipse

How do I run a DropWizard / Jersey server locally without having to restart & repack to get asset file updates?

I'm working on the client side of a project that is using DropWizard. Unfortunately what I'm experiencing is that for me to make a change to assets I have to stop the server, package the assets with maven, and then rerun the server or the assets will not be updated.
I tried adding dropwizard-configurable-assets-bundle but I'm still seeing the same behavior. Here's the service after adding it:
Service.java
public void initialize(strap<ServiceConfiguration> strap) {
// Assets
strap.addBundle(new ConfiguredAssetsBundle(
"/dashboard/app/", "/dashboard/", "index.html"
));
// Redirect /dashboard to /dashboard/
strap.addBundle(new RedirectBundle(ImmutableMap.<String, String>builder()
.put("/dashboard", "/dashboard/").build()));
}
I'm currently running mvn package && java -jar target/pack.jar server config.yml. I tried using Eclipse but I was having to restart it manually and it wasn't repackaging for me so it was slowing things down even further.
This whole process is reaaaally slowing me down and I'm hoping it's just my ignorance to the world that is Java.
In my Intellij Idea, i am using JRebel plug-in for this purpose. JRebel also supports Eclipse.
If your assets are packaged under src/main/resources then they should just update automatically with Eclipse without a restart being required, so long as you're running the executable service main() from within the IDE.
You may need to check that your Maven plugin is set to "generate-resources" on changes but that is just the default setting so should be in place already.
What you're describing is definitely possible in Eclipse - I have personal experience of making resource changes (e.g. change and save an HTML asset) and then seeing an immediate update upon doing nothing more than a browser refresh.

Tomcat doesn't update until I restarted Eclipse

i have problem with tomcat. when i change something in my xhtml file, tomcat can not show the changes. it shows the page before changing. i restart the tomcat,i clean tomcat work directory, right click on server and select clean, but i have to restart the eclipse to see the result. i search in google but i could not find which setting i should do in tomcat to solve the problem.in publish tab i selected "automatically publish when resource changes" .
please help me. i have to restart eclipse for each changing.
Please be sure your XHTML file is not being cached by your browser. Try a forced refresh (on Firefox, press Shift+Refresh Button or Command+Refresh on Mac).
You might also try to configure Tomcat context to disable caching for static resources as documented in the Apache Tomcat Configuration Reference. Set the cachingAllowed property to false (default is true).
Check HTTP headers using Firebug. See what you is in the HTTP response: HTTP response code, Cache-Control and Expires headers.
Like #Sam said, make sure that your files are not being cached by your browser. On Mac (Command + R) Firefox and Chrome (Shift + F5).
If this does not work, double click the server on Eclipse and go to the Publishing tab. Make sure that it is set to Automatically publish when resources change.

Eclipse 'loading descriptor' takes ages

We have a Java Spring MVC based project using Eclipse (Juno - the latest build), using the latest JVM 1.7 and Tomcat 7. Eclipse is pretty fast, and everything is set to default settings. Once it is all loaded up, it is lightning fast, which makes a pleasant change.
However, the only gripe is that if I open a project, it begins 'Loading descriptor', which as far as I can tell is our 185-line web.xml file. Sometimes this might take 5 minutes to load, sometimes might just not load at all. This prevents any changes being made, as the system waits for the descriptor to load before anything else happens. Pressing the stop button on this leaves the system 'waiting' for the cancel to go through, and the only way out seems to be to kill the java process is the task manager. If it does by chance load, then the system runs fine (unless you open another project for reference, then the fun begin again).
Is there some configuration that skips the descriptor (e.g. is it something to do with validation that can be skipped) or would there be some reason that the descriptor might not load properly?
This happens when your Project Explorer is open. Uncheck unnecessary options at Project Explorer's "Customize View" dialog. On the top right corner of the Project Explorer panel there is menu called "Customize View", go to the second tab called "Content" and uncheck unwanted options...
That problem occurred because "Project Explorer" performs loading of environment descriptor.
So after the eclipse was loaded, choose "Windows" -> "Open Perspective" -> "Java". It will open the "Package Explorer" instead of "Project Explorer".
You need to be quick and get it done before the eclipse load the descriptor.
As you mentioned you could try disabling all 'xml' based validations like so :
Start by disabling all XML / XSL based validation towards the bottom
in Windows -> Preferences -> Validation :
Type 'Validation' in Eclipse preferences and disable any XML related
validations, like so:
and,
Might be worth to try out the following:
Check your proxy settings. Are they such that if required your Eclipse would be able to connect to the internet ? The reason I ask is, with XML files Eclipse attempts to download the related schema files.
Also, check Eclipse' error log view to see whether there is something specific that it's trying to do when it hangs.
Do you have a source control plugin inside eclipse which is linked to the project containing the web.xml file ? If so, if you disconnect your network does it help ? Infact, I would recommend disconnecting your network connection and try opening the problematic project.
If this is an old workspace from a previous version of Eclipse, try importing this project into a new workspace ?
Hope the above helps.
Yes, the problem is in "Project Explorer". If you like to use the "Java EE" perspective (which by default opens "Project Explorer" view) then close the "Project Explorer" view and open the "Package Explorer" view.
Changed Explorer to Package Explorer
Window->Show View->Other->Java->Package Explorer
It works now.
In my case, renaming the web.xml to web-fail.xml stops the hanging.
At least, I replaced my 2.4 schema definition with the 3.1
`<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
`
and everything works fine again
My way to succes was deleting the project from the eclipse. And removing ".classpath",".settings" and ".project" files(".settings" is a directory). After that importing project into eclipse as existing maven project.

Categories