• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Status 404 issue in Tomcat

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I've just set up Tomcat 7.0.50 in Centos 6 (64bit) [As a VPS]

I placed HelloWorld.war in usr/share/apache-tomcat-7.0.50/webapps
Then entered

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/webapps/HelloWorld.war">
</Context>

And saved as HelloWorld.xml in /usr/share/apache-tomcat-7.0.50/conf/Catalina/localhost

Stopping and starting tomcat, makes the web-app load correctly... http://37.59.151.138:8080/HelloWorld/




So my problem...
The HelloWorld.war was an old file I found, when I use netbeans 7.4 with java 1.7.0_45, and tomcat-7.0.41 locally,
I can create a new war file JJ.war,
I place this in usr/share/apache-tomcat-7.0.50/webapps
Then enter...

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/webapps/JJ.war">
</Context>

And saved as JJ.xml in /usr/share/apache-tomcat-7.0.50/conf/Catalina/localhost

Stopping and starting tomcat, gives me a 404 error, as you can see here.... http://37.59.151.138:8080/JJ



So I completely stuck now, I can't see why it works for that old HelloWorld war file, but not this new one, its very annoying,
Please let me know if you can help, thanks.

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check what your Tomcat log file says. Is your JJ Webapp deployed successfully when Tomcat started?
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats a good idea, I'm new to this VPS stuff, I forgot about the logs, but I found them ok....

If I wipe the logs, then stop and start tomcat, I get this...


Jan 15, 2014 4:18:08 PM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Jan 15, 2014 4:18:08 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jan 15, 2014 4:18:08 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jan 15, 2014 4:18:08 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jan 15, 2014 4:18:08 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Jan 15, 2014 4:18:08 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jan 15, 2014 4:18:08 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Jan 15, 2014 4:18:08 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
Jan 15, 2014 4:18:20 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Jan 15, 2014 4:18:20 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 15, 2014 4:18:20 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 15, 2014 4:18:20 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 865 ms
Jan 15, 2014 4:18:20 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 15, 2014 4:18:20 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.50
Jan 15, 2014 4:18:20 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /usr/share/apache-tomcat-7.0.50/conf/Catalina/localhost/JJ.xml
Jan 15, 2014 4:18:20 PM org.apache.catalina.startup.ContextConfig beforeStart
SEVERE: Exception fixing docBase for context [/JJ]
java.io.FileNotFoundException: /webapps/JJ.war (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.jar.JarFile.<init>(JarFile.java:153)
at java.util.jar.JarFile.<init>(JarFile.java:90)
at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:99)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:113)
at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:726)
at org.apache.catalina.startup.ContextConfig.beforeStart(ContextConfig.java:854)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:380)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:634)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:671)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1840)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

Jan 15, 2014 4:18:20 PM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Invalid or unreadable WAR file : /webapps/JJ.war
at org.apache.naming.resources.WARDirContext.setDocBase(WARDirContext.java:133)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:5077)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5257)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:634)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:671)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1840)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

Jan 15, 2014 4:18:20 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/JJ]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:634)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:671)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1840)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.catalina.LifecycleException: Error in resourceStart()
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5258)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more

Jan 15, 2014 4:18:20 PM org.apache.catalina.startup.HostConfig deployDescriptor
SEVERE: Error deploying configuration descriptor /usr/share/apache-tomcat-7.0.50/conf/Catalina/localhost/JJ.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/JJ]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:634)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:671)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1840)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

Jan 15, 2014 4:18:20 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /usr/share/apache-tomcat-7.0.50/conf/Catalina/localhost/HelloWorld.xml
Jan 15, 2014 4:18:26 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [4,948] milliseconds.
Jan 15, 2014 4:18:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomcat-7.0.50/webapps/ROOT
Jan 15, 2014 4:18:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomcat-7.0.50/webapps/MyApp
Jan 15, 2014 4:18:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomcat-7.0.50/webapps/host-manager
Jan 15, 2014 4:18:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomcat-7.0.50/webapps/docs
Jan 15, 2014 4:18:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomcat-7.0.50/webapps/manager
Jan 15, 2014 4:18:27 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /usr/share/apache-tomcat-7.0.50/webapps/examples
Jan 15, 2014 4:18:27 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 15, 2014 4:18:27 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 15, 2014 4:18:27 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6873 ms


------------------------------------------------
Seems its something to do with the deployment descriptor, but war file runs locally here in windows under tomcat when running through netbeans 7.4.
And its only 1 jsp and 1 servlet.

Let me know if you have any idea what to do, thanks.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The log files indicate that your JJ.war is not deployed at all. This explains why you get a 404.

Looks like your war file is corrupt. How are you building your war file?
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just do this...

In netbeans, click on "Clean & Build"
Then I go into the "dist" folder of the project and the war file is in there (Same as I do for jar files of a normal java project)
I just copy it across with sftp, not sure if thats whats corrupting it or not.

Is there a better way?
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Leaping Lizards!!

I figured it out, after scouring the internet, I read at the bottom of this page..http://pub.admc.com/howtos/tomcat/ch02.html#stagedir-section
that its best not to copy war files remotely into the webapps folder directly...
But to put them on the filesystem somewhere first, and then move them, (eg with mv command in linux for example)

So it wasn't about configuring settings thankfully, as there's enough of that already, hopefully this may help someone else.
Thanks for help given.

 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

colin shuker wrote:

So it wasn't about configuring settings thankfully, as there's enough of that already, hopefully this may help someone else.
Thanks for help given.



Cool!
 
Saloon Keeper
Posts: 28483
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a Manager application that comes with Tomcat. It provides a web-based administration service that can be used to deploy a WAR. You are presented with a page that has a file upload component that you use to transfer your local copy of the WAR to the appropriate place in the server and (optionally) supply a context name under which the deployed webapp will be accessed.

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excellent, I was looking for something like that, but didn't think tomcat had one.
I know glassfish does in port 4848, but I took it off as it uses too much ram.

Anyway, it seems to work great so far, just browse to war, and deploy, great
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic