Tomcat 7 resource not available - eclipse

I followed the instructions here to configure Tomcat 7 in Eclipse. As suggested there, I copied the webapps/ROOT directory to the eclipse workspace's wtpwebapps/ directory and I can see the tomcat welcome page now. I was also able to get the test-app project (downloadable from that link) working.
Then to see the examples, I also copied the webapps/examples directory to the wtpwebapps directory and then restarted tomcat in eclipse. But when I try accessing examples via http://localhost:8080/examples/ , it gives me a 404 error.
What more do I need to do to get the above working ?

I think you need context entry for examples in Server.xml. The default application of a fresh install of Tomcat 7 is ROOT. So, It is not required to make entry.
Go to Package Explorer--> Server --> Tomcat v7.0 Server at localhost-config --> server.xml
Tomcat v7.0 Server at localhost-config, This may be differ in your case.
Add Context entry for examples web application.
Here is the sample entry of my server.xml
And I have copied examples directory to wtpwebapps/ and added entry for like this
<Context docBase="examples" path="/examples" reloadable="true" source="org.eclipse.jst.jee.server:examples"/>
Restart Tomcat server and you should get http://localhost:8080/examples working.
Also read #BalusC 's answer : HTTP Status 404 - The requested resource (/) is not available

Related

Having Trouble Configuring Tomcat 9 with Eclipse Photon

So I installed Apache Tomcat 9 on my computer, and am having trouble configuring and running it on Eclipse Photon. When I start the server through the Monitor Tomcat application, I can open it up to see the appropriate Apache Tomcat Page, however when I try to run it through eclipse, I get an Error 404, as shown on this image:
I tried changing the server location from "use workspace metadata" to "use tomcat installation", as I saw on several websites and videos to correct the exact issue I'm having ("The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."), but when I run the file after saving that configuration, I get the error as shown in this image:
I am not attaching an application to it just yet, I wanted to ensure that the server was running, and I could see the appropriate Apache Tomcat splash page when I try to access localhost:8080, but that isn't happening.
The Monitor Tomcat application deploys a root application to handle '/'. When Eclipse launches Tomcat for you, it does not deploy anything you do not explicitly tell it to, so nothing's there for '/'.
https://wiki.eclipse.org/WTP_Tomcat_FAQ#If_I_start_my_Tomcat_server_and_try_to_display_Tomcat.27s_default_page.2C_why_do_I_see_a_directory_listing_or_404_error_page.3F
After doing some digging, I discovered that the reason I was receiving those errors was because the entire Tomcat 9.0 file had restricted access, only administrator-level accounts could modify those files. I was able to resolve the issue by going into the file path, right-clicking on the "Tomcat 9.0" folder --> Properties --> Security --> Edit --> Users --> Full Control.

Apache Tomcat 7.0 not working properly with eclipse EE juno version

When I run apache tomcat 7.0 alone, it works without any flaw in my browser I can execute the examples also, but when I apache tomcat 7.0 in eclipse I'm getting a 404 error message saying that "requested resource is not available".
I just type the session example program and run it again, it shows this 404 error message only.
How do I resolve it?
I don't know whether it's the problem with tomcat or with eclipse..
Please help!!
I think your eclipse is configured to load a webapp folder that is not the one installed with tomcat, please follow the steps below:
Open the Run Configuration of the Tomcat 7 in the eclipse
Go to the Arguments tab
In the VM arguments, it should have a property listed: -Dwtp.deploy=...
The folder on this property define the webapp folder for the tomcat started from the eclipse
If you want it to load the tomcat examples, change the folder of that property to the one that have the examples
try doing the following steps:
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.34\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, R-click, and paste ROOT (say "yes" if asked if you want to merge/replace folders/files).
Then reload tomcat test pagea to see the Tomcat welcome page.
I feel your pain. I am also using Tomcat 7.0, and I've gotten servlets to work in Tomcat doing everything by hand. Then a couple of days ago I downloaded eclipse, and after a struggle I successfully got some servlets to work in eclipse.
I downloaded the Java EE version of eclipse here:
http://www.eclipse.org/downloads/
And then I followed this tutorial:
http://www.vogella.com/articles/EclipseWTP/article.html
The tutorial is a little out of date, but I managed to get eclipse setup correctly using that tutorial. In a couple of places, the tutorial says to click on Window->Preferences->..., which for me was equivalent to Eclipse->Preferences->.... The biggest problem I had was when the tutorial said:
Create a new package called ....
There were no instructions on how to create a new package. The way you create a new package is by looking in your project folder for:
--JavaResources
--src
Then right click on the src folder and select:
New-->Package
Send me a comment if you have any questions about any of the steps in the tutorial.
I got that 404 Error constantly until I figured out what was the correct path with which to call the servlet. If you are calling the servlet, say with a <form>'s action attribute, the url should look like this:
<form action="/<project name>/WelcomeServlet" method="get">
And that would correspond to a web.xml something like this:
<servlet>
<servlet-name>WelcomeServlet</servlet-name>
<servlet-class>com.exmaple.WelcomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>WelcomeServlet</servlet-name>
<url-pattern>/WelcomeServlet</url-pattern>
</servlet-mapping>
Are you using servlets 3.0 or 2.5? With 3.0 you use the syntax:
#WebServlet("/WelcomeServlet")
public class WelcomeServlet extends HttpServlet {
for the url mapping instead of a web.xml file.
I had a similar issue with my project.
Maybe Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace.
Go to webapps directory inside apache directory (for example C:\apache-tomcat-7.0.34\webapps), right click on the ROOT folder and copy it.
Then go to your Eclipse workspace, go to the .metadata folder, and search for "wtpwebapps".
Start the Tomcat server by eclipse.
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).
Pay attention that the folder tmp0 is present only if the server is started.
Go to the wtpwebapps folder, right click, and paste ROOT (say "yes" if asked to override folders/files).
Then try to see the Tomcat welcome page.
Bye
Monica
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 radio button ,browse Server Path of the Tomcat Root directory(Ex: D:\RaviTeja\installed\apache-tomcat-7.0.57) and browse Deploy path aslo webapps folderof tomcat
(Ex: D:\RaviTeja\installed\apache-tomcat-7.0.57\webapps).
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.
3. Please find below Tomcat configuration screen shot.

Apache tomcat 7 No error with localhost page, But when run project: show HTTP Status 404

I know there are many questions about Apache tomcat 404 error: but I think mine is different.
I am using windows 7 64 bit
unzipped eclipse-jee-juno-SR2-win32-x86_64 to C:\
unzipped apache-tomcat-7.0.37-windows-x64
changed port server.xml to 3030 instead of 8080
continue with this steps "Quick Start" from point (2)
I didn't forget:
copying ROOT folder
R-click tomcat node in eclipse Servers tab -> properties -> Switch location
Double click tomcat node in Project explorer and check use tomcat instillation (takes control of tomcat installation)
The page:http://localhost:3030/ works fine. It shows the message If you're seeing this, you've successfully installed Tomcat. Congratulations!
But when I tried simple project (I followed basic tutorial) and use Run as -> Run on Server the page of error 404 is shown. When back to http://localhost:3030/ it shows no error.
No error with http://localhost:3030/
Error when running a project!
HTTP Status 404 - /SimpleProject/
type Status report
message /SimpleProject/
description The requested resource is not available.
Apache Tomcat/7.0.37
I am The author of this question, and I solved it. I will provide the solution so that others can get help from it.
As I followed this installation steps carefully, then the installation is correct.
The only problem that caused the error is in the web.xml:
- When create a new "Dynamic Web Project" (As my case)
- Take care of this file: WebContent -> WEB-INF -> web.xml
- The <welcome-file> </welcome-file> tags must refer to exist files to display in the browser.
- If there are some default tags delete them.
- when you create for example a new HTML file named index.html, then make sure that the web.xml file refers to it. <welcome-file>index.html</welcome-file>
Digression (irrelevant to the solution above)
I am actually working on NetBeans extensively doing simple Java Standard Edition projects. I rarely encountered problems with NetBeans, and when they occur I can solve them easily either myself or by searching for information about the problem.
When I began learning the Java Entrprise Edition, and see tutorial on NetBeans, I started my first project from the first day.
But I found most of the tutorials use Eclipse and that was the reason why I installed it.
When I moved to Eclipse. I encountered many problems, and each problem take many hours to search and solve. that takes three days before starting one project.
I am wondering why people prefer Eclipse over NetBeans. I think there is some reason. (^_^)

Tomcat webapps directory in windows

I am right now using eclipse to develop a simple web application and I am using Tomcat as web server. I have configured Tomcat in Eclipse and my application runs fine.
My question is: where does Tomcat store the web app and in which folder does it store the classes? I wanted to check the JSP to servlet conversion and wanted to verify how that converted file looks like and I am trying to find where exactly Tomcat stores the web app. I went into the webapps folder where Tomcat was extracted but my webapp is not in that folder.
Can someone tell where I can find the converted JSPs?
right-click on the web project and select Run As then Run Configurations...
From the Arguments tab, the tomcat deploy path is provided as a VM argument with the name -Dwtp.deploy
Found out the location.
Double clicked on tomcat server inside eclipse and got the server path. something like this ..
C:\EclipseWorkspace.metadata.plugins\org.eclipse.wst.server.core\tmp0
The location of the web app will be in the .metadata folder inside eclipse workspace (chk server path) and the converted jsp files can be found in location as given below.
serverpath\work\Catalina\localhost\loginApp\org\apache\jsp
#Admins ... This question can be closed or what ever action needs to be taken.
Thanks.

.war file not getting deployed on tomcat server 7.0

I have two queries which I am detailing below:
I installed tomcat 7.0 on my ubuntu machine 11.04.
1. .war file not deployed
When I start tomcat through terminal it works fine and I am able to see the tomcat webpage at http://localhost::8080/. After that I try to deploy a war file ps.war which I copy into the webapps folder inside the tomcat installation directory. And then I restart the server but get the same 404 error even when the .war has been extracted to a ps folder by tomcat.
2. Not running through eclipse
when I open it through eclipse then it shows in eclipse console that the server is started and synchronized but does not run any service and give HTTP 404 eroor. Also in this case, When I open a browser window then I get same 404 error at http://localhost::8080//
Please help me put as I am quite stuck at this moment and not able to run the web services any further. Thanks in advance.
#ezile i can understand for the first query that .war file was faulty thats why you were unable to get it through the browser..
but for second query solution how can i accept that making a correct .war file made http://localhost:8080 running in eclipse...
I am asking this question as i am having the same (first and second) difficulty !!
Did you mean to have two colons in your URL before the port number? It's supposed to just be one. http://localhost:8080
Next, in your tomcat installation directory there is a directory called logs which contains a few log files which will provide more information than just the 404 message you see in your browser.
One other thing to check which we've ran into before is case. I have seen a problem with WebContent\WEB-INF being the wrong case (i.e. lower case) and Tomcat not wanting to pick up the war artifacts.
Thanks all for your responses. I solved the problem. For first part there was some problems with my .war file and thats why it was not getting deployed.
For second, after I corrected my war, it automatically started working for eclipse too.
In my case it was because the WAR required a full path.
I had specified localhost:8080/WarFileName
Which didn't work. It was only when I specified
localhost:8080/WarFileName/src/homepage
Which was how the packages were created in the war file, that it worked.