Apache Tomcat 7.0 not working properly with eclipse EE juno version - eclipse

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.

Related

Unable to deploy my spring web project to eclipse internal tomcat server.(java.lang.ClassNotFoundException on tomcat startup)

when I use an external tomcat everything is just fine. but I need to deploy my project on internal eclipse tomcat server in order to be able to use DCEVM class hot swapping.
When I try to start tomcat server from within eclipse it says it is not able to find one of my service classes I mentioned in my spring security configuration file as a bean.
I also tried to add the project to tomcat class path but it did not solve my problem.
UPDATE
I found out the problem is because when I deploy my web project to eclipse tomcat server, no .class is copied to:
C:\Users\Meysam\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\villapweb\WEB-INF\classes
in fact, this folder contains my src/java/main package structure but no .class is copied in it.
lib folder is fine though (e.g. all dependencies of maven and other stuff copies in the path it is supposed to)
I think there might be something wrong with m2e-wtp plugin. I dont know what!
I am using eclipse 4.3 BTW.
SOLVED
I Solved this issue following these steps:
right click on project in eclipse > properties > project facets
in the right panel select runtimes and select your target server. Apply and ok.
in the server modules list right click on project module and click clean module work directory
right click on the server itself and you can clean both server and tomcat work directory one after another
if that didn't work, try project > clean and also toggle "build automatically" option under project menu item.
Thats it. tomcat now copies all .class files to the target server and you see no ClassNotFound exception as tomcat starts up.
[Copied to answer section]
I Solved this issue following these steps:
right click on project in eclipse > properties > project facets
in the right panel select runtimes and select your target server. Apply
and ok.
in the server modules list
right click on project module and
click clean module work directory right click on the server itself
and you can clean both server and tomcat work directory one after
another
if that didn't work, try project > clean and also toggle
"build automatically" option under project
Thats it. tomcat now copies all .class files to the target server and you see no ClassNotFound exception as tomcat starts up.
I've followed the steps on the answer but It still wouldn't work for me, so, besides doing these steps once, I've found that doing a refresh on the target after doing a clean install automatically triggers the "Republish" status on the server, so when the server is executed all changes on the compiled classes (new classes and changes to existing ones) are then copied to wtpwebapps when the server is started.
I had almost the same problem - one of my projects did not make it to the deployment area (its jar). What i did is 1) remove the appliction from tomcat 2) clean tomcat work directory 3) most important: project - clean - all. Then i added the application again and... problem solved
I had the same problem in Web Dynamic project converted to Maven project.
I found error in properties->Deployment Assembly->right panel.
There was source=src folder and deploy path=WEB-INF/classes. Classes couldn't be found by Eclipse.
Changed to source=target/classes.

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.

How do you import a Java Class Library into a Java Web project (using NetBeans)?

I've already tried the options "Add folder...", "Add Library...", and "Add JAR/Folder...", but it's not working this time -- I've done this several times before without any problems.
I've also tried to add the folder / JAR file (.war-file) manually to the projects properties in every thinkable way, but still no success.
And so far, Google hasn't helped either..
Any help would really be appreciated.
(This is for a Java Web project with JavaServer Faces, using NetBeans 7.1)
Solved: I never found out what caused the problem. I ended up re-installing entire NetBeans, and re-created (a thousand times) the project I was trying to import. And in the end, I got it working.
Put the JAR file in the WEB-INF/lib directory of your web project. All JARs in the WEB-INF/lib and all packages in WEB-INF/classes are automatically in the CLASSPATH.
Can you make "Hello, servlet" work? If not, why bother with JSF? Do a simple web app successfully and build up from there.
I had this problem with netbeans, but it seems like all the answers I found are for Eclipse (I guess am wrong) as I dont see any WEB-INF/lib directoryin NetBeans, though I have a WEB-INF directory.
so here what I did.
I remove the tomcat server on NetBeans, go to C:\apache-tomcat-7.0.30\lib , put the jstl-1.2.jar file their, restart NetBeans and add a new (Tomcat) server, create a new web app, and their, I could find the jstl-1.2.jar file in the Libraries > Apache tomcat.
and for unknown reason, it worked.!

Dynamic Web Project libraries

Good morning in my timezone.
I have imported one Dynamic web project to my eclipse. I have downloaded the Tomcat server.
If I work without any IDE, I know that every libraries that we use in the project must be inside the lib folder in tomcat.
Folder structure : Tomcat\webapps\WEB-INF\lib
My question is, if I need a library (*.jar) should I put it directly in the lib folder or should I configure in the build path, adding it in the libraries tab?
Second question, my project steels have the red cross above the project name, but I do not see where the error is, in the src folder no class have any error and inside the Web Content folder there is not any cross, so how can I know where the problem is?
Thanks in advance.
Best regards developer community.
There shouldn't be any need for configuration, just copy them in the lib folder.
Make sure you have set the right jdk and the server libraries. right click on project -> build path -> configure -> libraries. if there is no tomcat runtime lib, you should add it.(I assume tomcat is embedded in eclipse. If not, right click on servers(next to console) and add the tomcat server.)