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.
Related
I have xampp installed. With it, I got the tomcat required for java servlets to work. C:\xampp\tomcat\webapps\SavedFiles. This is the path for tomcat, considering it is installed with the xampp.
I have the following :
D:\School\Uni\S1\WEB\UploadFileToServer\out\artifacts\UploadFileToServer_war_exploded this is the output directory for my artifacts (I use intellij, if this matters).
SavedFiles contains: 1.jpg, 2.jpg, picture.bmp.
I know that I need to add a context and a path or something like that, so that I can display images stored on my computer but I am lost here.
I have images in SavedFiles.
What do I need to add to the servlet or tomcat server.xml so that I can display the images like this <img src='SavedFiles/1.jpg'>?
It seems like the problem was that I used the path instead of getRealPath("/"). This solved the problem for me. Maybe this will help someone in future as well.
I am using Tomcat 6.x and Eclipse J2EE Kepler. For reasons mentioned in my other question, I sometimes need to delete the Tomcat from the Servers list and re-add it.
The weird thing is: after I re-add the server, two configuration files server.xml and context.xml revert to a previous state! let's call it S. I cannot really tell what S is - it definitely is a state I once had, but it lacks some newer changes. For this reason my webapp does not work and I have to revert these two files in the workspace/Servers folder.
I'd love to fix this by updating S. However, I am unable to find the source of S, where Eclipse takes it from - I tried fulltext-searching my computer for files that look like the server.xml and context.xml, but to no avail. Specifically, I updated these two files in the conf/ folder of my Tomcat installation, but it did not help.
Where could Eclipse be keeping S? In some weird DB in the workspace metadata? Could it be using the local history?...
Thanks for any insights!
If you are working on Eclipse then there should be a folder called Servers in your workspace. When you start your server for the first time, it copies over the tomcat conf files into this eclipse project. So no matter if you change your actual context.xml from outside, eclipse will override it with what is stored in the 'Servers' folder.
If you still need the eclipse to take control of your tomcat installation directory, you need to primarily update this file from within the eclipse.
I have been working on a Java web application and i am using SmartGwt on Netbeans 7.3 and out of a sudden I encountered this problem. I tried cleaning the build-impl.xml then restarting the IDE and I should say I have fairly low knowledge on this. Can someone please tell me why it is giving an error and how I can fix that?
The error message says :
nbproject/build-impl.xml:1031: The module has not been deployed. See the server log for details.
BUILD FAILED (total time: 4 seconds)
Note: i am using Tomcat 7.0.34
may its so late but the response useful for others so :
Sometimes, when you don't specify a server or servlet container at the
creation of the project, NetBeans fails to create a context.xml file.
In your project under Web Pages, create a folder called META-INF.
Do this by right mouse button clicking on Web pages, and select:
New->Other->Other->File Folder
Name the folder META-INF. Case is important, even on Windows.
Create a file called context.xml in the META-INF folder.
Do this by right mouse button clicking on the new META-INF folder, and
select:
New->Other->XML->XML Document
Name it context (NetBeans adds the .xml)
Select Well-formed Document
Press Finish
Edit the new document (context.xml), and add the following:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/app-name"/>
Replace app-name with the name of your application.
Now your in-place deployment should work. If not, make sure that the
file can be read by everyone.
The context.xml file is specific to Tomcat. For more information about
that file, see the Tomcat documentation at tomcat.apache.org.
Start your IDE with administrative privilege( Windows: right click and run as admin), so that it has read write access to tomact folder for deployment. It worked for me.
Take a look at the server logs!
I had been with this for hours. The awful Tomcat servlet is not very helpful neither but if you can see the stacktrace that should be enough.
For instance, I read the following error message there:
As you can see, the message was pretty clear and easy to fix :-)
Check if there any other instance of the server is running already
Check if the port that will be used by the server is free.
If you add jars in tomcat's lib folder you can see this error
Close Netbeans.
Delete all libraries in the folder "yourprojectfolder"\build\web\WEB-INF\lib
Open Netbeans.
Clean and Build project.
Deploy project.
One of the main reason for this error is due to permission not granted to all users. so remove this error, follow the following steps :
1) Go to the C:/Programme Files/Apache Software Foundation/Tomcat 7.0
2) Right click on the Tomcat 7.0 folder and click on properties.
3) go to Security Tab.
4) Select the User and click on Edit... button
5) Grant all the permission to the user and click on apply and ok.
Refresh the system and now try. I hope it will work
if you still getting this error try this.
Go to Netbeans services
Remove Apache Tomcat.
Add Apache Tomcat again.
Build Project.
Deploy Project
in my case , it said that the 8080 port is in use , so I change the server port of Tomcat to 8081 and it works
Check whether you placed the within the .. or outside the ...
If you placed it outside the server tag , and if you try to access the init-parameter then it will give error.
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.
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