Linux Ubuntu Tomcat deployment

Hi: I am a beginner to use ubuntu. I just installed tomcat5.5 and tomcat5.5-webapps by command:
sudo apt-get install tomcat5.5 tomcat5.5-webapps

Now I generate a war file by Eclispe. I put war file into /usr/share/tomcat5.5-webapps/. and /usr/share/tomcat5.5/webapps. But it always get 404 error when I try to open the link. In windows, when tomcat is started up, the war file would be unzipped. Why in ubuntu, it did not?
JianJunShenAsked:
Who is Participating?
 
JianJunShenConnect With a Mentor Author Commented:
Finnally, it is factory line in context.xml. Thanks to narrow down my problem
0
 
objectsCommented:
it should be in /usr/share/tomcat5.5/webapps


you do npot actually need to install  tomcat5.5-webapps

what is the context name?  
what path are you trying to load it with?

0
 
JianJunShenAuthor Commented:
The war file name is addemo.war. In window, I could access it by typing http://localhost:8080/addemo. In ubuntu, I type http://localhost:8180/addemo
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
CEHJConnect With a Mentor Commented:
Make sure that you have the correct file permissions to deploy. Probably best to add yourself to the tomcat user group and make sure everything's group-writable in the tomcat tree
0
 
objectsConnect With a Mentor Commented:
check the logs, the answer is more than likely there.

0
 
objectsConnect With a Mentor Commented:
is the war getting expanded?

0
 
JianJunShenAuthor Commented:
the war file is not getting expanded
0
 
CEHJConnect With a Mentor Commented:
Are you able to writer to that directory?
0
 
objectsCommented:
check is tomcat actually running

you haven't changed the default server.xml have you?

0
 
JianJunShenAuthor Commented:
Yes, I do not have right to write anything in /usr/share/tomcat5.5/webapps directory. I have not yet chanaged anything in server.xml.

0
 
CEHJCommented:
>>Yes, I do not have right to write anything

Then you won't be able to deploy anything. You need to make the changes i mentioned
0
 
objectsConnect With a Mentor Commented:
you don't need access to write to that directory.

Have you changed any of the tomcat config?
Are you using the init.d script to start?

whats the output from:

ps -ef|grep tomcat

0
 
JianJunShenAuthor Commented:
HI: I am using sudo /etc/init.d/tomcat5.5 start.

What does ps -ef means?

After I type ps -ef|grep tomcat, the output in the termianl is as follows:

juhanishen@juhanishen-desktop:/usr/share/tomcat5.5/webapps$ ps -ef|grep tomcat
root     11136     1  0 09:59 ?        00:00:00 /usr/bin/jsvc -user tomcat55 -cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat5.5/bin/bootstrap.jar -outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat5.5.pid -Djava.awt.headless=true -Xmx128M -Djava.endorsed.dirs=/usr/share/tomcat5.5/common/endorsed -Dcatalina.base=/var/lib/tomcat5.5 -Dcatalina.home=/usr/share/tomcat5.5 -Djava.io.tmpdir=/var/lib/tomcat5.5/temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/var/lib/tomcat5.5/conf/logging.properties org.apache.catalina.startup.Bootstrap
root     11137 11136  0 09:59 ?        00:00:00 /usr/bin/jsvc -user tomcat55 -cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat5.5/bin/bootstrap.jar -outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat5.5.pid -Djava.awt.headless=true -Xmx128M -Djava.endorsed.dirs=/usr/share/tomcat5.5/common/endorsed -Dcatalina.base=/var/lib/tomcat5.5 -Dcatalina.home=/usr/share/tomcat5.5 -Djava.io.tmpdir=/var/lib/tomcat5.5/temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/var/lib/tomcat5.5/conf/logging.properties org.apache.catalina.startup.Bootstrap
tomcat55 11139 11136  0 09:59 ?        00:00:10 /usr/bin/jsvc -user tomcat55 -cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat5.5/bin/bootstrap.jar -outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat5.5.pid -Djava.awt.headless=true -Xmx128M -Djava.endorsed.dirs=/usr/share/tomcat5.5/common/endorsed -Dcatalina.base=/var/lib/tomcat5.5 -Dcatalina.home=/usr/share/tomcat5.5 -Djava.io.tmpdir=/var/lib/tomcat5.5/temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/var/lib/tomcat5.5/conf/logging.properties org.apache.catalina.startup.Bootstrap
1000     11796 10656  0 13:57 pts/0    00:00:00 grep tomcat
0
 
objectsCommented:
that all looks fine.
have u checked the logs?

0
 
objectsCommented:
> What does ps -ef means?

lists the running processes

man ps

0
 
JianJunShenAuthor Commented:
catalina.log file shows:

java.util.zip.ZipException: error in opening zip file
      at java.util.zip.ZipFile.open(Native Method)
      at java.util.zip.ZipFile.<init>(ZipFile.java:131)
      at java.util.jar.JarFile.<init>(JarFile.java:150)
      at java.util.jar.JarFile.<init>(JarFile.java:87)
      at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:90)
      at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:66)
      at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:86)
      at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.ja
va:122)
      at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection
.java:89)
      at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:141)
      at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.ja
va:872)
      at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:990
)
      at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
g.java:279)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:120)
      at org.apache.catalina.core.StandardContext.init(StandardContext.java:50
71)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
984)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:760)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:74
0)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
      at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:831)
      at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:720
)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490
)
      at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1217)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:293)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:120)
      at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBas
e.java:1306)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
rocessChildren(ContainerBase.java:1570)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
rocessChildren(ContainerBase.java:1579)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.r
un(ContainerBase.java:1559)
      at java.lang.Thread.run(Thread.java:636)
Feb 9, 2009 10:06:18 AM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Invalid or unreadable WAR file : /var/lib/to
mcat5.5/webapps/addemo.war
      at org.apache.naming.resources.WARDirContext.setDocBase(WARDirContext.ja
va:130)
      at org.apache.catalina.core.StandardContext.resourcesStart(StandardConte
xt.java:3855)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
024)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:760)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:74
0)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
      at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:831)
      at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:720
)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490
)
      at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1217)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:293)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:120)
      at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBas
e.java:1306)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
rocessChildren(ContainerBase.java:1570)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.p
rocessChildren(ContainerBase.java:1579)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.r
un(ContainerBase.java:1559)
      at java.lang.Thread.run(Thread.java:636)
Feb 9, 2009 10:06:18 AM org.apache.catalina.core.StandardContext start
SEVERE: Error in resourceStart()
0
 
objectsCommented:
war appears to be unreadable/corrupt

0
 
objectsConnect With a Mentor Commented:
whats the outpiut of the following:

ls -l /var/lib/tomcat5.5/webapps/addemo.war
jar tvf /var/lib/tomcat5.5/webapps/addemo.war
0
 
JianJunShenAuthor Commented:
It seems that my ant script is done adpat to windows envinronment. Does that matter? Does Linux could recognize windows zip.
0
 
CEHJConnect With a Mentor Commented:
Shouldn't generally matter - Ant is cross-platform, although it could be made to break. What is this script that you're using - please attach it
0
 
objectsConnect With a Mentor Commented:
make sure the war is readable

sudo chown tomcat55 /var/lib/tomcat5.5/webapps/addemo.war

0
 
JianJunShenAuthor Commented:
After I use chmode 777 addemo.war, and restart the tomcat, it expands addemo.war file. But now problem comes for the following error when I check the catalina.log file:

Feb 9, 2009 2:44:32 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Feb 9, 2009 2:44:32 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/addemo] startup failed due to previous errors

So I still could not access http://localhost:8180/addemo. Any idea?
0
 
CEHJConnect With a Mentor Commented:
Clear the log file, restart and attach it please (or post if short)
0
 
JianJunShenAuthor Commented:
Feb 9, 2009 2:56:28 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Feb 9, 2009 2:56:28 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8180
Feb 9, 2009 2:56:28 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 884 ms
Feb 9, 2009 2:56:28 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 9, 2009 2:56:28 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5
Feb 9, 2009 2:56:28 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Feb 9, 2009 2:56:30 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive addemo.war
Feb 9, 2009 2:56:30 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat5.5/webapps/addemo/WEB-INF/lib/javaee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Feb 9, 2009 2:56:30 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat5.5/webapps/addemo/WEB-INF/lib/jsp-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/jsp/JspPage.class
Feb 9, 2009 2:56:30 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat5.5/webapps/addemo/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Feb 9, 2009 2:56:32 PM org.apache.catalina.core.StandardContext startSEVERE: Error listenerStartFeb 9, 2009 2:56:32 PM org.apache.catalina.core.StandardContext startSEVERE: Context [/addemo] startup failed due to previous errors
Feb 9, 2009 2:56:33 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8180
Feb 9, 2009 2:56:33 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Feb 9, 2009 2:56:33 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/44  config=null
Feb 9, 2009 2:56:33 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Feb 9, 2009 2:56:33 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4856 ms
0
 
CEHJCommented:
You need to move those jars 'not loaded' out of your web app
0
 
JianJunShenAuthor Commented:
But in windows, it does not matter. I will try it in linux.
0
 
JianJunShenAuthor Commented:
I deployed a simple servlets without database connection. Tomcat deployed this simple servlets and it worked well. I am afraid it is because addemo has database backend. And in web.xml there is JNDI for database which does not have correponding .xml file. I will install MySQL tomorrow to see what happend after that.
0
 
objectsCommented:
> After I use chmode 777 addemo.war, and restart the tomcat, it expands addemo.war file. But now problem comes for the following error when I check the catalina.log file:

you don't need to do that

> remove the following jars

/var/lib/tomcat5.5/webapps/addemo/WEB-INF/lib/javaee.jar
/var/lib/tomcat5.5/webapps/addemo/WEB-INF/lib/jsp-api.jar
/var/lib/tomcat5.5/webapps/addemo/WEB-INF/lib/servlet-api.jar

Thoses classes are already provided by tomcat installation

0
 
objectsConnect With a Mentor Commented:
those jars should only be in your compile path, and should not be part of deployment.
u also probably only need the last one really

0
 
JianJunShenAuthor Commented:
But simpleServelt war has same jar files. It deployed successfully and runned succesfully in ubuntu.
0
 
objectsConnect With a Mentor Commented:
Its only a warning, its not stopping you're context deploying.

I'm guessing its failing to deploy because it cannot get a db connection
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.