Eclipse with Tomcat does not automatically republish my WAR file - eclipse

I've got Windows 8.1 with a 1.6 JDK manually installed.
I'm using Eclipse (Kepler, Java EE IDE for Web Developers).
I imported a project that builds a WAR file using an Ant build script; that shows up as a Project.
I created a Tomcat6 Server (downloading the available Eclipse package); that shows up as a second Project.
On the Modules tab for the Server, I clicked "Add External Web Module...", browsed to the folder holding my WAR file and clicked OK. I then added the name of my WAR file (directory name "...\SpiffyApp" to file name "...\SpiffyApp\spiffyapp.war"). I confirmed that the name of the path is "/"; I clicked to have "Auto reloading enabled" checked, and clicked OK.
I admit - I peeked inside the Server configuration. I clicked on "Open launch configuration"; in dialog "Edit launch configuration properties", on the Arguments tab, I discovered the following property setting:
-Dcatalina.base= "....metadata.plugins\org.eclipse.wst.server.core\tmp0"
Then in my mischief I observed that the "tmp0" directory had a "webapps" subdirectory. Aha!
I notice that, under some circumstances, the "SpiffyApp" is republished under "webapps" - problem is, I can't figure out when!
Specifically, I'm disappointed that Eclipse doesn't republish my app to "webapps" when I tell the server to "Clean"/"Publish". What I'd really like is for it to republish automatically when I rebuild the WAR.
I can get the WAR redeployed when I do all of this:
stopped my Tomcat Server
delete all folders under "tmp0/webapps"
delete all folders under "tmp0/work" (tip I got from Chris Lercher, here)
rebuilt my WAR file
Started my Server
Surely I'm doing something wrong.
What are the rules here? Am I really left to remove the Web Module, delete the folder in "tmp0" and re-add the Web Module?

What you're doing wrong is expecting it to watch for changes on an archive file, which generally isn't expected to change. Import the WAR as a project and then Eclipse can deploy it properly when something actually changes within the app.
Otherwise you might try forcibly Cleaning the server area from the context menu of the Tomcat server instance in the Servers View.

Related

how to make eclipse + tomcat instant deploy for webapps

I build a maven project and deploy this war into tomcat webapps folder then started tomcat, so that my app available in browser as localhost:8080/myApp
I can see myApp folder which was extracted from myApp.war under tomcat/webapps.
I can modify this app's UI by editing files undertomcat/webapps/myApp/.. using Notepad++.
I send this project to my co-worker, he also import this project in his eclipse and run this app.
He changed the jsp and js files from eclipse and the result will be reflected in browser, he never used separate editor to this modification.
If I change the files in eclipse then it is not reflected in browser.
What I need to do for the same to be working to me?
If you just want Hot deploy in Eclipse, please try to take following steps:
Double clicks on the Tomcat plugin, refer to publishing tab, 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, clicks on the Module view, make sure Auto Reload is Disabled. Default is enabled.
Note:
This is an important step, failed to set the auto reload to disabled, the Tomcat server will be restarted every time you modified something!
Start Project in DEBUG mode. Hot Deploy is supported in DEBUG mode only.
Limitation
Hot deploy has supported the code changes in the method implementation only. If you add a new class or a new method, restart is still required.
To simulate it, try to add a new method, following pop up screen will be displayed, saying the code changes cannot be hot swapped in the JVM.

Eclipse - Make dynamic web application include other projects in workspace

I'd like the exported .war file to include the other (referenced) projects in the workspace.
When I reference them in the Build Path only, it shows no "Problems", but ClassNotFoundException is thrown later, when I try to "Run on Server" or export.
Using eclipse Kepler, tomcat 7.0.42.
I've seen the solution here: Not able to configure run path for web application project in Eclipse workspace; that's how it works now. Is there a more convenient way?
Are you running Tomcat within Eclipse? Try this:
Run -> Run Configurations... (or Debug Configurations...).
Find Tomcat v7.0 Server at localhost (or whatever it's named for you) under Apache Tomcat on the left-hand side.
Go to the Classpath tab on the right.
Select User Entries and click Add Projects....
Select the projects you wish to include.
That should place that project on Tomcat's classpath.

Eclipse modifies server.xml each time run the project (Run-->Run on Server)

I'm using Tomcat 7 on Eclipse Juno. I use workspace metadata as server location (Please see my tomcat configurations below).
Also I got a Server project in eclipse [please see the image below] with separate server.xml and other configuration files.
Normally it works fine. The issue came across after I changed the server.xml (in eclipse project) for SSL configurations.
Configurations are working fine. But each time I run the project (Run-->Run on Server) server.xml get modified to the default version. My customized SSL changes are missing.
Also I tried to change server.xml in tomcat installation location (C:\apache-tomcat-7.0.35\conf), but it didn't pick from eclipse.
Can anyone please help me on this?
Thanks
In {workspace}/Servers you will find a folder for every Tomcat configuration, containing several configuration files, including the server.xml. There you then can edit the file directly.
To get changes taken into account restart Eclipse. That is imho better than removing and adding the configuration back all the time. Tested using Eclipse Mars and Tomcat 7.
(the solution is from: Eclipse with tomcat - eclipse modifies server.xml)
I found an applicable solution but not a perfect one.
What I have done is;
1.Changed server.xml file in installation location (In my case C:\apache-tomcat-7.0.35\conf)
2.Remove tomcat server from eclipse server panel (please see the image below)
3.Create a new server in eclipse server panel.
4.Then Server project will be generated new server.xml with my customized changes.
5.The trick is, initially eclipse picks server.xml from installation location when create a new server in panel.
Thanks
Make sure you are editing the files right beneath the tomcat server folder, not the ones beneath the config folder. Check the attached screenshot for the files I'm referring to.
I had this problem too, and the solution worked (I don't have enough reputation points to vote up the answer).
On a similar note, I had to make configuration changes to a port number and that also required me to delete and re-add my tomcat instance from STS (spring tool suite).
On Eclipse, double click on Server to view properties.
check "publish module contexts to separate XML files", and save it.
Run Tomcat server.
Eclipse will be create conf/[enginename]/[hostname]/[appname].xml without touching server.xml
Make sure that the path in the server.xml is same as in the Web project Settings.
To see the Web Project Settings: Right click on the project >> Properties >> Web Project Settings.
Always give the project path over here. The path in server.xml will automatically updated.
Clean Tomcat Work Directory & Republish the project.

Connecting Tomcat server to Eclipse

I am trying to use Tomcat 6.0 as a web development server within SpringSource Tool Suite 2.7.1. I create a runtime, download tomcat, create a server, etc as per these instructions http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html#N10148
When I try to run a web app on the server though I get the following error:
The archive: /Servers/Tomcat/bin/bootstrap.jar which is referenced
by the classpath, does not exist.
I know this bootstrap.jar file does exist in the exact place it says it should be yet it still causes an error. Any ideas?
You might want to check/manually edit your path by going into server properities:
In Servers view,
1) double-click on Tomcat server.
2) Then click on Overview of Tomcat settings appears.
3) "Open launch configuration" then Classpath
4) Edit User Entries here
The trick here was that the location of the jar was inside the Eclipse/STS project directory. STS stores its server configurations inside the /Servers folder and I had decided to store the tomcat runtimes here as well for neatness. Placing the runtimes elsewhere and trying again solves this issue.
None of the above answers provide proper concrete solution.
I faced exactly same issue and i figured out a very simple solution.
Open Eclipse and remove all entries of Apache server
Delete Servers from explorer tab, delete Tomcat from server explorer window, delete server from Window > Preferences > Server > Apache tomcat, delete it, also delete servers folder inside EclipseProjects.
Place Apache tomcat folder outside the project folder anywhere you wish to, you can place in Eclipse_Projects folder but not inside EclipseProjects/projectxyz/.
Now add server in eclipse the usual way and give path of this new location.
This should work!
I had similar issue. This is what worked for me:
When the path begins with slash like: "/Servers/Tomcat/bin/bootstrap.jar" it means that the local project is refered. In the picture - I had 'pivotal-tc-server-developer-3.2.8.RELEASE' as the name of the project.
Open the project ('Servers' in your case or 'pivotal-tc-server-developer-3.2.8.RELEASE') so it is accessible to Eclipse.
The jar should be now visible.
Alternatively go into Run Configurations; delete jars, and add it as an external jar.
Or you may delete the servers configuration, and configure the server again. This works when you may have changed the directory of the server.
I googled my way here on the search terms, "the specified tomcat directory does not exist". (I had moved it from one directory to another.)
For others here for that reason, my solution was to go into Window -> Preferences -> Server -> Runtime Environments and update it there. Then to update the JARs, as in Marcin Wasiluk's answer.
I was also facing same issue and solved it as follows :
My conclusions :
1) In my case issue was coming as I shifted the location of the Tomcat.
Solution :
2) double clicked on the server configured in the eclipse.
3) Click on Open Launch configuration.
4) Change the classpath under classpath tab to the new location.
Hope this would help.
I have faced the same problem.
Solution: In Project Explorer--> Servers(right click) --> Run As --> Run Configurations(click) --> (Select "Tomcat v7.0 Server at localhost") --> Arguments(tab) --> Working directory(bottom of window) --> others : (click workspace) --> select the "boostraps.jar" from -->Server.
Eg., My workspace.MY path is:
Project Explorer --> Servers(right click) --> Run As --> Run Configurations(click) --> (Select "Tomcat v7.0 Server at localhost") --> Arguments(tab) --> Working directory(bottom of window) --> others : (click workspace) --> /home/ciprus//Servers --> click apply.
this could happen if you probably used previous tomcat server in eclipse, so deleting server and its configuration and creating another one will make it work .
You can try as below steps:
Open Window -> Preferences -> Server -> Runtime Environments
Click add button, choose the what's kind of server you use.
Click next button, give a name to your runtime server and the path of tomcat.
New a new server with the new created runtime server
same problem in my case also i solved::
just remove your older tomacat server and add tomcat 8.0 version only
If you have unzipped downloaded Tomcat archive into Eclipse Servers folder, User Entries in classpath have relative path (e.g. /Servers/....) of bootstrap.jar and tomcat-juli.jar which path I guess is not accessible as a relative path.
Once I removed Tomcat installation directory (with files) outside Eclipse's Servers folder, delete the old configuration and re-add Tomcat, everything worked as expected.
I hope this helps narrow down the cause.

Eclipse publishing to Tomcat

I recently came back to using Eclipse after 2 years of IntelliJ. Things have changed.
Now when I try to run Tomcat, it tries to publish my project to it. What the hell is publish?
What ever happened to pushing a war into the webapps directory and letting Tomcat deploy it?
Right now my deployment is broken because of compilation errors. I have a feeling that Eclipse is taking my project and copying it to webapps dir without first building it properly.
Can someone explain to me what exactly publishing does, and also how to turn it off and use Tomcat like normal people?
A the "Servers" view, you can double click on your Tomcat instance, to open the server settings editor.
There, at the upper right corner, you can find the Publishing options. Check the "Never publish automatically" option, and save.
With this it should be enough.
Oh, and by "Publishing", they kind of mean "Deploying", or "Copying to the deploy directory", depending on what server you are using.
Eclipse (Helios) makes a copy of your entire Tomcat configuration and starts a new instance of the Tomcat server when you are running the web application from Eclipse. That is why you must shut down any existing Tomcat service before running in Eclipse.
The application runs out of your workspace, not out of the "webapps" folder. Eclipse modifies the copied server.xml file to add "CONTEXT" tags that include your workspace project folders in the running application list.
The path in the "CONTEXT" tag should be the name of your project folder.
You can export the project to a WAR file and deploy your web application to the webapps folder if you want.