Apache Tomcat problem - eclipse

I installed eclipse with tomcat 7. I start tomcat from eclipse and it works when i access my own projects within the browser
localhost:8080/ReadFormData/Form.html
but what's strange is that when i type within the browser:
localhost:8080
it doesn't access the apache site. I get the following error status:
HTTP Status 404 - /
type Status report
message /
description The requested resource (/) is not available.
When i close eclipse and i start the server from outside and type
localhost:8080
it works. I know it's not a big deal but it's kind of frustrating.

Assuming it's the regular "Congratulations, you've managed to start Tomcat"-page and you really want it for your Eclipsed-managed Tomcat instance:
Double-click your Tomcat in the Eclipse "Servers" view
At the bottom of the view that just opened, select "Modules"
Click "Add External Web Module" and browse to the directory where you extracted your Tomcat, there select webapps/ROOT, press OK
Keep the "Path" field as /(single slash), press OK
If you now start your Tomcat from within Eclipse, you'll find that http://localhost:8080 works just like when you start Tomcat from outside Eclipse.
Now for the slightly more interesting reason behind this:
Eclipse very strictly controls what's going on in server instances managed by it, so it only runs with the contexts/web apps you explicitly add (see steps 1.-4. above).
When starting Tomcat from outside Eclipse, it runs any context it finds in its webapps directory; this usually includes the ROOT webapp (mentioned above), manager, host-manager, docs and examples.

Related

How to start apache tomcat packaged within eclipse?

My company does not allow me to upload apache tomcat from the official website . They told me that I already have it as a "plug in " in Eclipse . It's sort of packaged . So , anyway I could not find a startup.bat file anywhere .
I have the following folder on my computer that presumably contains apache tomcat somehow installed there. I am not sure whether i have a jboss . Here is the folder
If I go to the jre folder there is a servertool.exe . It looks like this
I am not sure how I can start apache tomcat . I mean I am not allowed to upload the zip file directly form the website, otherwise I could have used the startup.bat . . . I have never encountered a situation like this . I do not have a regular apache tomcat folder .
I tried localhost:8080 no result
How can I start working with it ?
Thanks
Eclipse does not ship with Tomcat. It integrates very nicely with it, though, after you install Tomcat. These instructions are for Eclipse Kepler SR1; other Eclipse versions are similar. There are third-party plugins that do this too, but the native plugin works nicely. Also, I'm not sure, but pretty sure, that you need the "Java EE IDE" version of Eclipse, not just regular Eclipse for Java. The steps:
1) Install Tomcat from the ZIP file (which just means extracting the ZIP to somewhere like c:\tomcat)
2) In Eclipse, choose Preferences from the Window menu; in the search box, type "runtime", then click Runtime Environments under the Server category (if you don't see this, you may not be running Eclipse Java EE; again, not sure if "regular" Eclipse for Java is enough).
3) Click the "Add" button and go through the process of telling Eclipse about where your Tomcat server is (i.e., it's where you just installed it to).
4) Create a Dynamic Web Project for your web-app (regular Java projects won't work; if your code is already in a regular project, migrate it into a Dynamic Web Project).
5) From the Window menu, choose Show View, then Other, then type "servers" and double-click Servers.
6) In The Servers pane, right-click anywhere in the pane and choose New, then Server. Follow the instructions to create a new Server that uses the Tomcat runtime you just created in Eclipse. When you're done, you'll have a Tomcat server listed in the Servers pane.
7) Not it's time to add your Dynamic Web Project to the list of web-apps that this server (that is, this Tomcat) knows about. So, right-click on your Tomcat server in the Servers pane, and choose Add and Remove. In the dialog that opens up, click Add All, then Finish.
8) Start Tomcat by clicking the Debug icon above the Servers pane (it looks like a green bug). Load http://localhost:8080/ (or http://localhost:8080/yourappname depending on your config) and you're done. (You can also run Tomcat by clicking the Run icon -- instead of Debug -- but one of the big reasons to run Tomcat from within Eclipse is that you get to use Eclipse's debugging functionality.)

Tomcat 6 Eclipse config -- Server Locations locked for edit

I am trying to change the default location for my Tomcat server running out of Eclipse EE 1.4.1 so that it uses the original Tomcat installation (which works fine when run standalone out of the console) and not the one created by Eclipse in the workspace as per this thread. However, my Server Locations section on the Tomcat server configuration form is all grayed out (see red rectangle):
Why is that and how do I change it?
It says it all on the page you published :
Server must be published with no modules present to make changes.
Stop your server. Undeploy everything and then (the trick part) click on publish to be sure to have nothing deployed (ie no files copied to the deploy location, the click on publish with no module in your server will erase everything deployed).
Then you will be able to change the setting.
Before making any changes in Tomcat Server Location, you need to remove project(s) deployed on server.
To remove project:
expand tomcat server in "Servers" view
right click and select remove
Just stop your tomcat server first ;)

eclipse debug remote web application

I have a struts2 web application developed in eclipse IDE and exported
it as war file and deployed it in tomcat7 installed in windows server.
Now I need to debug this deployed web application in eclipse inside my local system.
How to bring those codes inside?
I found some links but I stuck with how to bring those code into
eclipse in my local system to place break points.
these are those few links...
link 1 link 2 link 3 link 4
..Or simply navigate to the bin folder and start your tomcat with the following command:
catalina jpda start
No need to make any changes with this approach.
The defaults are the same as quoted by Ingemar: port 8000 and transport=dt_socket.
Confirmed to work with tomcat 7 (.0.40 or newer to be precise).
Then follow his instructions and setup a Remote Java Application debug configuration in Eclipse. Basically, just use the defaults - they match (at least in Juno and Kepler). You might want to check the Source tab or do this on demand while you debug.
... Or, in case you use maven, you might consider the tomcat7-maven-plugin plugin, which will completely keep you inside eclipse.
Happy debugging
Solution for windows:
First you have to modyfy your tomcat startup script (startup.bat):
Put this on top of the startup.bat
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
...
Then modyfy the following line (nearly at hte end of startup.bat):
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
to
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Now you can start tomcat by executing startup.bat and tomcat opens the port 8000 for debuging.
Second step is to configure Eclipse:
Select Run > Debug Configurations ...
Create a new configuration by selecting 'Remote Java Application' with a right click.
Check that the right Project is selected.
And modyfy the Connection properties. (Note that the port has to be same (8000) as entered in startup.bat and not the port on which your struts app is running)
Finaly you have to click on Debug
Now you should be able to set breakpoints.

HTTP Status 404 - The requested resource (/) is not available

I integrated Tomcat 7 in Eclipse. When I start it using Eclipse, it shows that Tomcat is up and running, but when I go to http://localhost:8080 in my browser, it gives me following error:
HTTP Status 404 - /
type Status report
message /
description The requested resource (/) is not available.
Apache Tomcat/7.0.23
I tried changing the port in server.xml just in case if 8080 is used by another service, but it didn't work either. How can I solve it?
What are you expecting? The default Tomcat homepage? If so, you'll need to configure Eclipse to take control over from Tomcat.
Doubleclick the Tomcat server entry in the Servers tab, you'll get the server configuration. At the left column, under Server Locations, select Use Tomcat installation (note, when it is grayed out, read the section leading text! ;) ). This way Eclipse will take full control over Tomcat, this way you'll also be able to access the default Tomcat homepage with the Tomcat Manager when running from inside Eclipse. I only don't see how that's useful while developing using Eclipse.
The port number is not the problem. You would otherwise have gotten an exception in Tomcat's startup log and the browser would show a browser-specific "Connection timed out" error page (and thus not a Tomcat-specific error page which would impossibly be served when Tomcat was not up and running!)
Following steps helped me solve the issue.
In the eclipse right click on server and click on properties.
If Location is set workspace/metadata click on switch location and
so that it refers to /servers/tomcatv7server at localhost.server
Save and close
Next double click on server
Under server locations mostly it would be selected as
use workspace metadata Instead, select use tomcat installation
Save changes
Restart server and verify localhost:8080 works.
Copy the ROOT (Default) Web App into Eclipse.
Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace.
Go to C:\apache-tomcat-7.0.27\webapps, R-click on the ROOT folder and copy it.
Then go to your Eclipse workspace, go to the .metadata folder, and search for "wtpwebapps". You should find something like your-eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps (or .../tmp1/wtpwebapps if you already had another server registered in Eclipse).
Go to the wtpwebapps folder, right-click, and paste ROOT (say "yes" if asked if you want to merge/replace folders/files).
Then reload localhost:8080 to see the Tomcat welcome page.
I did what BalusC said but it was not enough for me, I had to clean the Tomcat workdirectory : ( Click right on right on Tomcat in the Servers Tab -> Clean Tomcat Work Directory )
Please check in your server specification again, if you have changed your port number to something else.
And change the port number in your link whatever new port number it is.
Also check whether your server is running properly before you try accessing your localhost.
If you are new in JSP/Tomcat don't modify tomcat's xml files.
I assume you have already deployed web application. But to be sure, try these steps:
- right click on your web application
- select Run As / Run on Server, choose your Tomcat 7
These steps will deploy and run in the browser your application. Another idea to check if your Tomcat works correctly is to find path where tomcat exists (in eclipse plugin), and copy some working WAR file to webapps (not to wtpwebapps), and then try to run the app.
If options under Server Locations are grayed out, note the message in the section title: "Server must be published with no modules present". To publish the server, right click the name of the server in the Server window and select "Publish".
Sometimes cleaning the server works. It worked for me many times.This is only applicable if the program worked earlier but suddenly it stops working.
Steps:
" Right click on Tomcat Server -> Clean. Then restart the server."
I had the same problem with my localhost project using Eclipse Luna, Maven and Tomcat - the Tomcat homepage would appear fine, however my project would get the 404 error.
After trying many suggested solutions (updating spring .jar file, changing properties of the Tomcat server, add/remove project, change JRE from 1.6 to 7 etc) which did not fix the issue, what worked for me was to just Refresh my project. It seems Eclipse does not automatically refresh the project after a (Maven) build. In Eclipse 3.3.1 there was a 'Refresh Automatically' option under Preferences > General > Workspace however that option doesn't look to be in Luna.
Maven clean-install on the project.
** Right-click the project and select 'Refresh'. **
Right-click the Eclipse Tomcat server and select 'Clean'.
Right-click > Publish and then start the Tomcat server.
In my case, I've had to click on my project, then go to File > Properties > *servlet name* and click Restart servlet.
For me, my Eclipse installation was hosed - I think because I'd installed struts. After trying a dozen remedies for this error, I re-installed Eclipse, made a new workspace and it was OK. Using Kepler-64-Windows, Tomcat 7, Windows 7.
This worked for me:
Project > Build Automatically (Make sure it's turned on)
Project > Clean ...
Right click Tomcat > Properties > General Tab > Switch Location (switch from workspace metadata to Server at localhost.server)
Restart Eclipse
Run Project As Server
Apache Tomcat/7.0.23 service is not loaded or enabled. Pls check the service status and other app which is using 8080 port currently. To check this use netstat command and observe whether another app is occupying the port 8080!

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.