I've got a project in Eclipse, with a .war file inside it. I'm using Spring for the project, with the help of Maven too.
I've installed Tomcat 8, but I'm having trouble deploying the webapp to Tomcat. The Tomcat runs without errors and the console output of launching the Tomcat looks like it is successfully deploying it, however when I go to localhost is just displays the generic Tomcat home page saying I have successfully deployed Tomcat.
I've tried changing my server location to use the tomcat installation, I've changed the location in the properties of my server to not be the workspace metadata.
When I add jars to the tomcat, I click on my project, and under it it lists the Spring jar if that is of any relevance.
I don't really know what else to put here at the moment, but I'm at hand to respond immediately to any questions or any more info that you require.
Thanks.
EDIT:
http://localhost:8080, it leads me to this: http://i.imgur.com/82lmpai.png
My tomcat console output is: https://gist.githubusercontent.com/J-Owens/8164b3ec6dbed9986322/raw/6756486aad0092647bbea8f315c42ac5ba9550b1/tomcatconsole
Each war file will have a name associated with it. When you use localhost:8080 as the URL, Tomcat will use the war with name ROOT under tomcat/webapps to display on the browser. By default, Tomcat will have a ROOT war that comes with the tomcat bundle. If you need to open your project, you will need to use localhost:8080/<your-war-name> to open your project's page. Alternatively, you could remove everything under tomcat/webapps and rename your war to ROOT to be able to access your project pages with the localhost:8080.
Related
I'm new in Java EE and Tomcat.
I worked on a REST Java application in OpenShift with JBoss EWS 2.0 and I had no problem. Recently, we got a server that I have to run my web service on.
Following How to deploy a war file in Tomcat 7, I went to my application root and used this command:
jar -cvf myapp.war *
Note that myapp is my application name for example.
I put the .war file to /base/path/of/tomcat/webapps/ and went to Tomcat GUI App Manager.
I saw that Tomcat created a folder with my .war name and put files into it, so I started my app but when I went to http://localhost:8080/myapp/ it returned 404. However, in OpenShift, when I opened it (opened root path), it displayed the index.html insomuch my webservice path is not valid and does not work.
please guide me and thank you for your time spent on my question.
I have to write an answer because I can't comment.
I suggest to give us a copy of the web.xml file.
On another hand, you have to know that Tomcat is a Servlet Container and JBoss a full stack JEE server. If you have EJB in your web-app it will not works.
AS Clément Duveau says an EJB application cannot be deployed in a Servlet container (like Tomcat). An EJB application needs to be deployed in an Application Server like JBoss, Wildfly, GlassFish, Weblogic, Websphere, TomEE, etc.
The most similar server to Tomcat (Java EE compliant) would be TomEE.
Suggestion: If you need to use Tomcat, you can change EJB for Spring Framework.
it is simple.
there is two way to deploy a war file on tomcat with custom path
the first one is to
renaming your war file to custom URL you want (for example the war file name is java-web-app-1.0.war and your path is myapp so you have to rename it to myapp.war)
and copy and put it under {tomcat-path}/webapps/, then the Tomcat/TomEE does its job. (it creates an empty directory with the same name of your war file)
after about 1 minutes you can check the path (in this example must be localhost:8080/myapp and see your war file was deployed)
the second one is to use Tomcat GUI.
go to Web Application Manager part.
it's a page like this:
in Deploy box just fill the Context field (it will be the custom path and in this case is myapp) and then choose the war file and push deploy button.(do not need to fill XML Configuration file URL field)
then it gives you a message like this:
this means your war file was deployed on the custom path.
I have got a war file generated using Maven and it works perfectly fine when i manually deploy it on the tomcat server.
However, the war file was generated using Maven on eclipse and when i try deploying this on the server using eclipse, it just doesn't act. The tomcat server starts perfectly fine. What I do is : Right click on the Tomcat Server 7.0, then Add/Remove Project and add it to the server.
The problem is when I deploy and publish it on the server and nothing happens after that.
On trying to access it, it says - The required resource is not found
Eclipse doesn't deploy the WAR. Instead, it knows how Tomcat works and deploys the exploded WAR.
The next step is to look into the webapps/ folder of Tomcat to make sure Eclipse really has deployed something.
If that looks ok, you need to look into the Tomcat log to see why it doesn't like the deployed web app.
Most of the time, there is old code which is somehow stuck in Tomcat, so Tomcat can't undeploy the old version. If that's the case, stop Tomcat, delete the app manually and try again.
There were certain jars required in specific versions for the application to work. I was usin the maven supported versions. I have got it to work adding them directly in Tomcat's lib folder for time being and the application now works. (Anyways i need to look to get them configured now on the maven)
Also, i guess installing the plugin for m2e - eclipse.org/m2e-wtp helped as well. Thanks #Aaron Digulla for the inputs.
I integrated Tomcat 6 into Eclipse Indigo. When I start the server in Eclipse, it shows that Tomcat is up and running, but when I go to localhost:8080 in my browser, it does not respond at all.
I have Tomcat server entry in the Servers tab with "Use Tomcat Installation" and it didnt help me.
I have removed my entire projects from eclipse and started importing it again to set it up from the beginning and it didnt help either.
Could you please some help me out?
It is most probable that you are running Tomcat from eclipse as Use workspace metadata (does not modify Tomcat installation). While running under metadata, tomcat's default welcome page is not deployed. So you wont be able to view the welcome page under localhost:8080/ but you can access your application with the application context in the url ( something like localhost:8080/yourApplicationContext/hello.jsp)
See below the image where you can set the server location. If you change it to Use Tomcat Installation, eclipse will use the actual installation of tomcat. You can even see this by deploying the application and then open up your file browser, navigate to tomcat directory and you will see your application deployed there in the webapps folder. But if you use use workspace metadata option, eclipse makes a stripped copy of your tomcat's installation and places it in the .metadata folder of the workspace. Something like eclipse_workSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\
The question as to which technique is better totally depends on your use.
I have made a project in Eclipse. It is running on local tomcat server. But when I deploy this war file in external tomcat server webapps directory. It is deploying correctly but when run on browser, Page not found. But I checked that directory and pages exists there but tomcat says Page not found. Then I made a demo.txt file inside project directory but it is also not found by tomcat. Now, I created a directory inside tomcat Webapps. It is found but my Project directory not found which exists there. What should I do now?
Check the port number. If not 80, try 8080 then.
There may be something wrong in web.xml or in library.
You can check tomcat Manager whether the Context is false(if then you will get only 404 error).
You can check the tomcat log files to get the exact error.
I am trying to use tomcat with eclipse. I have installed it all and got the tomcat plugin installed. I have put a .war file in the webapps folder of tomcat and have made sure autodeploy is set to true. The problem I am having is that I can't get tomcat to run this .war file. The tomcat server is started and running as it tells me under the servers tab at the bottom of eclipse. It also shows the name of my .war file under it and says synchronized meaning it at least knows its there. But I can't get it to work at all. Even when I go to the local host page it shows the title of apache tomcat but does not show the file. I want it to show me the .war file. It has the correct xml files and everything in it. Any help is much appreciated.
You may try to check whether the application is deployed or not. You can directly go to the Tomcat directory to see this.
Another possible thing could be, you might be typing the incorrect url.
http://localhost:8080/[your_application]
where 8080 is the port you have specified for tomcat.
You need to let Eclipse publish your web project for you when using the Eclipse Tomcat plugin instead of trying to manually deploy it youself.
The Tomcat plugin for Eclipe supports hot deployment whereby you can change jsp's etc without having to manually redeploy your web application.
If you have a valid web project in eclipse then you can check that it is being deployed by looking at the Server View.
Window, Show View, Other, Server
This window should contain details of your Apache server. (If no server is listed then you'll need to right click on the list and set one up.)
To check that your application is being deployed right click on your server and select Add/Remove projects. Check that your web project is listed. If it is not listed under Configured Project then add it.
If your project does not appear in the list then it probably wasn't setup as a Dynamic Web Project. You can fix this by by right clicking on the project to bring up project properties and then clicking on facets and then enabling Dynamic Web Project.
It is also worth having the Console view visible when starting/stopping Tomcat so that you can see the server output.
Start tomcat from the command line (not eclipse) and see if your webapp shows up. It should if you have indeed created a valid war file. If it doesn't work, check the logs.
You shouldn't be manually deploying the war file if you are using eclipse to launch tomcat. Running tomcat from eclipse does not necessarily use the same default workspace as the standalone tomcat. Check the configurations for the 'server': it may be that the eclipse launched server's webapp folder is empty.
If for some reason your webapp failed to initialize properly (error in the descriptor, an uncaught exception in a context listener, ...) tomcat will unload it and you won't see anything at http://localhost:8080/yourwebapp.
Is it there in the list of applications in tomcat manager?
if you havent done this...then follow the steps...
Go to http://localhost:8080/
Go to Tomcat manager and check if your application is there in the list of deployed applications. Try redeploying or starting the application if running=false. It usually tells you what is wrong when you do that.