We help IT Professionals succeed at work.

Linux Ubuntu Tomcat deployment

JianJunShen
JianJunShen asked
on
Medium Priority
1,998 Views
Last Modified: 2012-05-06
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?
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
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?

Author

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
CERTIFIED EXPERT
Top Expert 2016
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
check the logs, the answer is more than likely there.

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
is the war getting expanded?

Author

Commented:
the war file is not getting expanded
CERTIFIED EXPERT
Top Expert 2016
Commented:
Are you able to writer to that directory?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
check is tomcat actually running

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

Author

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.

CERTIFIED EXPERT
Top Expert 2016

Commented:
>>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
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
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

Author

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
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
that all looks fine.
have u checked the logs?

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
> What does ps -ef means?

lists the running processes

man ps

Author

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()
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
war appears to be unreadable/corrupt

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
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

Author

Commented:
It seems that my ant script is done adpat to windows envinronment. Does that matter? Does Linux could recognize windows zip.
CERTIFIED EXPERT
Top Expert 2016
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
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
make sure the war is readable

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

Author

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?
CERTIFIED EXPERT
Top Expert 2016
Commented:
Clear the log file, restart and attach it please (or post if short)

Author

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
CERTIFIED EXPERT
Top Expert 2016

Commented:
You need to move those jars 'not loaded' out of your web app

Author

Commented:
But in windows, it does not matter. I will try it in linux.

Author

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.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

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:

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

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
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

Author

Commented:
But simpleServelt war has same jar files. It deployed successfully and runned succesfully in ubuntu.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
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
Finnally, it is factory line in context.xml. Thanks to narrow down my problem
CERTIFIED EXPERT
Top Expert 2016

Commented:
:-)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.