i use tomcat 6 for production. i have a web app deployed on this server called: app.war
it has a url : test.org.
every time when i undeploy app.war and redeploy it this path won't work any more
http://test.org/home
but this url always work: http://test.org/app/home.
to make the first url work, i need to restart the tomcat server.
i wonder why when i redeploy the app.war the url http://test.org/home does not work.
if there a way to make it always work without restarting the server?
i don't want the application name to be included in the url
Thanks
This has no simple answer, as there are many components involved. You should isolate the problem. For instance, you could start removing test.org domain mapping, ensuring that there's no component possibly caching the output and so on.
And then after you had isolated Tomcat from anything else, if the problem persist, you could state that this is a Tomcat problem.
So please (pleeeeeeease) refine your question when you have done a couple of these steps so the SO community can help you.
Sorry for the long response.
Check out your app.xml in ${TOMCAT_HOME}/conf/Catalina/localhost . Whe you try to redeploy this file might get deleted and gets recreated causing you the problem.
In your war file try creating a folder META-INF at the top level (in the same directory as WEB-INF) and creating a file context.xml in the META-INF folder. In context.xml put this:
<Context path="" reloadable="true">
</Context>
See if that works for you.
Related
I am newbie in Tomcat(8) and having some issues with Tomcat. i want it to display the default Tomcat homepage like the way it was when i installed it for the first time. I am running/compiling some maven project in netbeans and it seems they are automatically deployed to Tomcat.
I have looked into the folders of Tomcat i can't see the app anywhere but its "index.html" file displays when i launch "localhost" . This makes the index.html file of the maven application displays as the default localhost page.
At the moment i want the localhost to display the default Tomcat page like it was when i first installed it.
I have changed my "C:\servers\tomcat8\conf\Catalina\localhost\ROOT.xml" file to the following but it is not working::
<?xml version="1.0" encoding="UTF-8"?>
<!--Context antiJARLocking="true" docBase="C:\projects\spring\PersistenceWithHibernate\target\PersistenceWithHibernate-1.0-SNAPSHOT" path="" /-->
<Context antiJARLocking="true" docBase="C:\servers\tomcat8\webapps\examples" path=""/>
I have pointed the docBase to docBase="C:\servers\tomcat8\webapps\manager" and comment out the one that is displaying the index.html page,
yet its not working
How do i fix it?
I am not certain if i understand what you are asking for, could you clarify the question up a bit?
But when you do a clean tomcat install, the default directory where the projects are deployed at, is under the tomcat install folder ../tomcat/webapps/ROOT.
The manager part is a tool to manage the tomcat, you sohuldn't need to configure it's docbase.
Check http://tomcat.apache.org/tomcat-8.0-doc/ for reference. At least the few first chapters, its all explained.
It's hard to say what (many things) you did to get to where you are. If you unzip a default tomcat installation next to your current installation and compare the directories, you'll be able to spot the differences.
As this is probably not what you want to hear: The default tomcat installation has the default web application in webapps/ROOT (because there needs to be an encoding for the "empty" context name, answering on www.example.com/
Restoring the default webapp might be as simple as restoring the original ROOT.xml, remove that file, restore webapps/ROOT or anything in combination.
Frankly, your problem description "but it is not working" doesn't really help. If this answer doesn't solve your problem, you might want to give more detailed description than that. What do you actually see. But then, you might as well state what differences you find between the original and your installation.
I have a simple hello world java application I deployed, and in the new code I changed the output of the servlet to print some statements in a loop.
It works fine locally.
I uploaded the new .war file, stopped tomcat, deleted the old .war file in /webapps and the exploded folder.
Then I copied the new .war file, and then restarted tomcat.
It exploded the folder, but somehow the code is old.
Could it be caching the .war file somehow?
I did change server.xml and set autodeploy=false but not sure if that is relevant?
delete the work directory and restart tomcat.
Bit too terse sorry.
Tomcat will turn jsp into servlet source before compiling, some caching takes place in the work directory this may be what is causing it to happen.
It has been some time since I used Tomcat but I am fairly sure the structure was something like work/host/engine/context so you will probably find your stuff under work/localhost/Catalina/--web context--
I did change server.xml and set autodeploy=false but not sure if that
is relevant?
oO.
From the docs
This flag value indicates if new web applications, dropped in to the
appBase directory while Tomcat is running, should be automatically
deployed. The flag's value defaults to true. See Automatic Application
Deployment for more information.
I'd start there.
When I put a new war file in the webapps directory and restart tomcat, my war file is exploded but the servlets are not available and their respective log files are not created in the logs directory. When I bounce tomcat again, then the servlets are available and the log files are created. I'm assuming I have setting(s) not correct within tomcat, but I'm not sure where to start.
Does anyone know the cause of my current situation? Or even what parameters to review?
New Additional/Comments: Our setup allows us to have our app 'myApp' be the default application that is seen at root of our URL. On the first starting of tomcat, I can get to myApp by going to /myApp/index.html - whereas on the second start of tomcat I can then just goto and myApp/index.html is displayed.
My welcome file list is the 'myApp/index.html'
I had a similar problem with Tomcat 6.0.26. I worked around it by deleting the exploded webapps before copying the new war file to the webapps directory. Maybe a little kludgy, but it solved my problem.
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
antiJARLocking
If true, the Tomcat classloader will take extra measures to avoid JAR file locking when resources are accessed inside JARs through URLs. This will impact startup time of applications, but could prove to be useful on platforms or configurations where file locking can occur. If not specified, the default value is false.
have you set unpackWars and autoDeploy params to true in your server.xml file?
Try to do unpackwars=false and always make sure tomat is not running when you do deployment try to avoid hot deployment...
I have this folder under Tomcat webapps/mysite which is where all my JSPs and other things are located. To access this folder I go to http://blah.com/mysite and it works just fine. However (because of stylesheets and images statically connected to the root /) I have to make it so that when I go to http://blah.com/ it will load the stuff inside webapps/mysite.
I've tried many different things including contexts and setting the absolute path in server.xml... nothing seems to work, whenever I go to http://blah.com/ it still tries to load the ROOT folder... what's happening here?
The solution I use is to set this in your Tomcat server.xml
Add a <Context> element within the <Host> like below which sets your mysite as the default web app. Note the empty path="" which makes it the default.
<Context docBase="mysite" path="" />
Attributes of Context Container from the Tomcat docs:
docBase You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory
of the owning Host.
path All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are
defining the default web application for this Host, which will process
all requests not assigned to other Contexts.
See others who have had similar question and the similar answer here, here and here
See also Apache Tomcat Configuration Reference - Context
There are a number of ways to make an application the root application. The simplest way is to just replace the contents of webapps/ROOT with the contents of your web application.
For other solutions, please see the following website:
http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application_.3F
https://stackoverflow.com/users/1123501/george-siggouroglou 's awnser works but lacks a step.
delete ROOT and all items
copy the war to webapps as ROOT.war
Without the deletion, it may not work. Tested with docker.
You can rename your war from something.war == to ==> ROOT.war.
So, tomcat will unpack the war and will create the folder ROOT for it.
It is a trick that is working on tomcat 8 also.
I downloaded a couple of webapps and placed them in my /webapps folder.
Some of them I could open by going to http://localhost:8080/app1 and it would open.
However, some others I would do the exact same thing and go to http://localhost:8080/app2 and it will display "HTTP Status 404 - /app2/", even though I am sure it is there. I've checked that it contains a WEB-INF folder just like app1, and I've even restarted Tomcat to be sure.
My question is: is there anything (perhaps in the web.xml file) that specifies what the URL has to be to start the webapp? Or is it simply just http://localhost:8080/<folder name> ?
P.S. If you want to know exactly what app1 and app2 I am refering to:
app1 (works) = http://assets.devx.com/sourcecode/11237.zip
app2 (doesn't work) = http://www.laliluna.de/download/eclipse-spring-jdbc-tutorial.zip
I've tried a few others as well, some work, some don't. I'm just wondering if I'm missing something.
I usually debug this by going the the manager page and making sure that all of the contexts are deployed (http://localhost:8080/manager/html).
It sounds like app2 has not been deployed properly or is not starting up because of some other error.
I would look at the logs. There may be a bunch of information in there but usually it explains what is broken.
The second app (the directory named WebRoot) can also be deployed correctly but you get a 404 by going to it because there is not an "index.jsp" or "index.html" file in the root directory.
Try putting a file there with any of those names, and the 404 is gone.
A servlet mapping in the web.xml is not strictly necessary for this to work.
The first zip file you mention has a .war file as part of the zip. The second one is just the source code and it needs to be built into a .war file.
It looks like it is setup to have that done in Eclipse. Try the File>>Export option and select War file as the export type.
The second requires the spring framework. The only runnable things I could find were a client in eclipse-spring-jdbc-tutorial.zip\SpringJdbc\src\test\de\laliluna\library\TestClient.java and one in eclipse-spring-jdbc-tutorial.zip\SpringJdbc\src\de\laliluna\library\sample\MyApplication.java. If you open it in eclipse (it is an eclipse project), and compile, provided the Spring framework is installed, you should be able to run both.
Are you familiar with log4j? Spring puts a lot of often-useful information into the logs created via log4j. When I have a SpringMVC application that won't startup correctly or otherwise isn't running I check my log4j and potentially turn up the Spring log level to INFO or even DEBUG.
If "/" is not accessible it means that there is no "index.html", "index.jsp" or whatever is defined in the welcome-files list of the web.xml
Also no Servlet-Mapping for the context ROOT directory is present.
Check the web.xml for Servlet-Mappings or try to figure out the name of the jsp/html /... file being in the context root