I am using this tutorial and I did all the steps according to it. But I am stuck to the very end step that is
Build the project and deploy the war file in Tomcat. Start Tomcat and hit below URL.
URL: http://localhost:8080/springDemo-1.0/welcome.do
I done 'build project' in eclipse and I export the project as .war file to webapps of tomcat, but when I use the URL it says "HTTP Status 404" and "The requested resource (/springDemo-1.0/welcome.do) is not available." Please help
Better is to use m2e-wtp plugin for eclipse
Update site http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/
After install update maven configuration (Maven -> Update Configuration). Now you can simple add WAR project to Tomcat instance configured in Eclipse WTP.
More about using this -> https://docs.sonatype.org/display/M2ECLIPSE/WTP+mini+howto
Maybe try manually loading the project into Tomcat. Go to http://localhost:8080 and click on "Tomcat Manager". At the bottom, upload your WAR and hit "Deploy". You should then be able to click on the link in the table, add the "/welcome.do", and see your page.
If you are denied access to the Tomcat manager, you might have to update the tomcat-users.xml in your Tomcat's conf folder (for example, see below).
<role rolename="manager-gui" />
<user username="admin" password="password" roles="manager-gui" />
With the above, you can access the manager using admin/password.
Related
I use Eclipse Oxygen (4.7.2). I have JBoss Tools in my eclipse. I have JBoss AS7.1.
I have a maven "ear" project. It is called abc-project. It is a maven project from the git repository. It's version in maven pom.xml is 4.7.5-SNAPSHOT. Its Artifact Id is abc-project. When I right click the server (under the Servers tab), and added the project, it is added as abc(abc-4.7.5-SNAPSHOT).
In the ear's application.xml, we have the display name as 'abc'
After I build and publish the project to JBoss, then in the standalone/deployments folder, the ear project is deployed under the folder with name abc-4.7.5-SNAPSHOT.ear
Now in one of our code, we refer as abc.ear while looking for some default labels files. The server starts fine, but it fails to access the project, because it s deployed under the folder name abc-4.7.5-SNAPSHOT.ear.
Can I change the deployment folder or the deployment name of this project?
I would like it to be deployed under the folder abc.ear
Wherever your project is, locate the .settings folder for your project. I believe this is the eclipse settings folder. Underneath this folder, there is a file called
org.eclipse.wst.common.component
Open this file, and change the name of your project in this following entry
from:
<wb-module deploy-name="abc-4.7.5-SNAPSHOT">
to:
<wb-module deploy-name="abc">
Then, remove the project from the jboss server in eclipse under the server tab/view.
Then restart eclipse clean.
Add the project again to jboss server in eclipse under the server tab/view
Publish and restart jboss from 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.
I am using Tomcat 7 to deploy my web projects on. Also I am more comfortable when using the Eclipse interface to start and stop my Tomcat, so I've added it in the Eclipse's Servers and check the "Use Tomcat Installation" in Server Locations. One more thing that I use is the Tomcat's web Manager tool to deploy/undeploy the projects.
As we know in order to use the Manager/html tool you have to sign in. The username and the password to authenticate are set in the tomcat-users.xml like this (in my file):
<role rolename="tomcat"/>
<role rolename="manager"/>
<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<role rolename="standard"/>
<role rolename="admin"/>
<user username="tomcat-eclipse" password="tomcat-eclipse" roles="tomcat,manager,manager-script,standard,admin"/>
<user username="root" password="toor" roles="manager-gui" />
Everything works fine until some moment in time (I'm not sure but maybe after several restarts or redeploys) the configuration that I've entered is flushed and the default (empty configuration) file overrides my customized config.
Q: What causes the file to be overridden and how can I prevent that? Thanks.
Edit:
A: What I suggest based on some experiments is:
Variant one: Change the Tomcat 7's tomcat-users.xml file before
you add it to Eclipse. This is because I suspect when I was using the "Use
Tomcat Installation" option Eclipse copied the old tomcat-users.xml in its metadata folder
and when I change it later in Tomcat's install dir, it don't overrides it in the metadata.
Then, for some reason, when running the server through Eclipse I
suspect that it checks if the files are the same and if not then it
overrides the tomcat-users.xml in the Tomcat's installation folder.
Use "Use workspace metadata" option. It is default. Then go to the Eclipse's Package explorer -> Your Tomcat Server -> tomcat-users.xml and change it from there. You can also copy the contents of your-tomcat-install-dir/webapps into your-eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ in order to have the nice Tomcat html interface (as shown in Tutorial: Installing Tomcat 7 and Using it with Eclipse).
Try it. :)
In Eclipse go to your Project 'Servers' in your 'Project Explorer' panel and inside folder 'Tomcat v7.0 Server at localhost-config'(this is the default name for a Tomcat server maybe yours is slightly different) change there tomcat-users.xml
Project Explorer > 'Server's > Tomcat v7.0 Server at localhost-config > tomcat-users.xml
How can I set the crossContext directive in the context of an web application so any WTP publish / deploy will set this correct to the generated Applications context.xml (conf/Catalina/localhost/appname.xml)
I tried to set it in the Servers context.xml as "default" but also generated a stub context.xml in the WEB-INF/context.xml of the web application, but nothing seems to help here ;/
The WEB-INF/context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context crossContext="true">
</Context>
Notes:
related to How to get a tomcat project path from different project in same tomcat by using java
http://olafsblog.sysbsb.de/tomcat-5-und-crosscontext-konfiguration/
http://www.eclipse.org/forums/index.php/t/51881/
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
http://www.eclipse.org/forums/index.php/t/50640/
It's simple but not perfect:
After adding the module to tomcat via wtp, open the WTP Tomcat server.xml (typically located in your workspace > Servers > Tomcat vX.X Server at localhost) and add attribute crossContext="true" to the <Context> tag of the corresponding web-module.
check "Publish module contexts to seperate XML files" in Tomcat WTP Frontend
Positive side-effects:
This will survive any "clean Tomcats working directory" or "clean project" actions
(still) Negative:
This will be overridden / removed if you change any WTP Tomcat options that affects server.xml like adding new modules, changing ports... After this action, you have to add it again.
There is still NO frontend option as like for reloadable or ContextPath ;/
I use Tomcat 6.0 and Eclipse 3.0 under Linux and I try to deploy a WAR in Tomcat. The problem is that the server is managed by Eclipse and I have some Eclipse project deployed. I tried to modify the server.xml file then launch Tomcat via Eclipse but it doesn't work:
Could not load the Tomcat server configuration at /Servers/Tomcat v6.0 Server at localhost-config. The configuration may be corrupt or incomplete.
I tried to extract the war in the webapps directory but the webapp is still inaccessible.
What is the best practice to deploy a War ?
Tomcat behaves differently in development and production mode. When you develop your webapp in Eclipse there is no reason to deploy a WAR file of your application as a WAR during development.
Just go to the "servers" view and add a new server (you should already have done this otherwise you could not create your Dynamic Web project). In the server view you should see the server you created (Tomcat at localhost or something similar) just right click it and go to the Add and Remove section. Here you can add and remove the Dynamic Web projects you created in Eclipse. Once you added your project, all you have to do is click the green start button in the servers view and your app should be available in at localhost:8080/mycontext.
When you're done building your app just right click the project and go the the Export section in the menu. You should be able to export a WAR file. Once you have your WAR file you can upload and deploy that on a Tomcat instance that is NOT tied to Eclipse running in dev mode.
Yes, in a way, you can deploy a war in the dev mode.
I have the same problem.
I have an Eclipse webapp project, which Eclipse deploys to an instance of Tomcat run by Eclipse, so I can hot-edit the project.
This Web project needs to use resources published by another webapp that has to be run within the same instance of Tomcat. The other webapp is a completed project by someone else, so it is already in a war form.
I needed to File->Import the war as an Eclipse project and let Eclipse deploy it to the same instance of Eclipse, in order to run it in the same instance of Tomcat in which my webapp also runs.
The problem is that some wars work this way but some others do not, while all of them work perfectly fine in a stand-alone Tomcat (started by startup.sh). I can't figure out why.
This is old but is one of the first answers in google search.
You can import the war file:
A Web Archive (WAR) file is a portable, packaged Web application
that you can import into your workspace.
Before importing a WAR file,
you should first determine if the WAR file contains needed Java™ source
files. When importing a WAR file into an existing Web project, the imported
Web deployment descriptor files are either not changed or overwritten by the
ones included in the imported WAR file, based on your response to the prompt
that is provided. In either case, this action does not represent a
merging of the two sets of deployment descriptors.
To import the
Web project resources in a WAR file into your workspace, complete the following
steps:
Select File > Import
.
In the Import dialog, select WAR file and
then click Next.
Locate the WAR file that you want to import using the Browse button.
The wizard assumes you want to create a new Web project with the
same name as the WAR file. If you accept this choice, the project will be
created with the same servlet version as specified by the WAR file and in
the same location. If you want to override these settings, you can click New and
specify your new settings in the Dynamic Web Project wizard.
Click Finish to populate the Web
project.
Source: http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Ftwimpwar.html
If all you have is a binary WAR (no source code), it cannot be installed within Eclipse. This can happen in certain scenarios outside of normal development workflows. Here's the work-around solution:
Launch another instance of Tomcat (outside Eclipse).
Modify the tomcat-users.xml file to enable admin
Go to http://localhost:8080/manager/html
Scroll down to WAR file to deploy
Click Choose File (next to Select WAR file to upload) and click Deploy.