Nov 272007
 

Sponsored Link

Apache Tomcat is a web container, or application server developed at the Apache Software Foundation (ASF). Tomcat implements the servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, providing an environment for Java code to run in cooperation with a web server. It adds tools for configuration and management but can also be configured by editing configuration files that are normally XML-formatted. Tomcat includes its own internal HTTP server.

First Sun JDK 5 need to be installed. It can be installed from Debian repository with unstable software

First you need to edit /etc/apt/sources.list file

#vi /etc/apt/sources.list

Add the following lines

# for sun-java packages in unstable
deb http://ftp.debian.org/debian/ unstable non-free
deb-src http://ftp.debian.org/debian/ unstable non-free

Save and exit the file.

Now you need to Update apt using the following command

#apt-get update

Install jdk using the following command

#apt-get install sun-java5-jdk

Check the java version using the following command

#java -version

Output looks similar to the following

java version "1.5.0_10″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)

Installing Apache Tomcat

Install Tomcat using the following commands

#apt-get install tomcat5.5
#apt-get install tomcat5.5-admin
#apt-get install tomcat5.5-webapps

To verify that Tomcat is running just navigate to http://localhost:8180/ in your browser (make sure you have replaced ‘localhost’ with your server ip or name)

You can start/stop or restart Tomcat using following command:

#/etc/init.d/tomcat5.5 [start | stop | restart]

Configuring ‘admin’ and ‘manager’ applications

You need to configure some user to have admin and manager roles. For example you can do it with ‘tomcat’ user. Stop server using the following command.

#/etc/init.d/tomcat5.5 stop

Now you need to edit /var/lib/tomcat5.5/conf/tomcat-users.xml file to look like below

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="tomcat"/>
<user username="tomcat"
password="tomcatpassword"
roles="tomcat,admin,manager"/>
</tomcat-users>

Save and exit the file.

Start tomcat using the following command

#/etc/init.d/tomcat5.5 start

Now you can use manager application at http://localhost:8180/manager/html.
Your user will be ‘tomcat’ and password will be ‘tomcatpassword’

Sponsored Link

 Posted by at 12:29 am
  • Yong

    I followded those instructions and was able to run tomcat admin/manager (great!!!).
    But when I deployed my web app, the app failed to start. The only error I can see in catalina.log is:
    SEVERE: Error listenerStart

    How can I get more details about what causes the failure???

    Thanks!

    -Yong

  • Miguel

    Great job. It worked.

    Thanx.

  • http://www.ab-steam.com Ann

    Thank you for making it SUPER easy to set up my Linux server!
    This page alone saved me heaps of headaches

  • http://www.zentralratderluden.de brndnbg

    I would like to annotate that althoug this solution works to get your admin-page, you will not be able to deploy war-archives to the server. To be able to do that, you will have to modify the file “/etc/tomcat5.5/policy.d/04webapps.policy” and find the following block:

    grant codeBase “file:${catalina.home}/bin/tomcat-juli.jar” {
    //some permissions here
    [...]

    };

    then you add the followin line to the other permissions in the block and fill in your webapps name:

    permission java.io.FilePermission “/var/lib/tomcat5.5/webapps/<>/WEB-INF/classes/logging.properties”, “read”;

    This is a nasty task and took me quite a few hours on “grepping” through logfiles and googling. It should be done automatically by tomcat. Has anyone a better solution? I’m still a novice in this J2EE thing.

    Greets.

  • http://www.zentralratderluden.de brndnbg

    seems like the doubled angle brackets where interpreted as comments or something. You have to insert your webapps name between ““/var/lib/tomcat5.5/webapps/” and “/WEB-INF/classes/logging.properties” ;-)

  • pj

    Thanks,

    Piece of cake with this HowTo

  • Thanks

    I hava searched for many websites to install the tomcat to my Ubuntu8.04 before I seen your page ,but all fail ! Then I do as your says ,now ,I finally can open the page “http://localhost:8180″ ,Thank you very much ! Good luck with you ! The late success is exciting !!!!!!!!

  • Kees

    Ps. tomcat had problems with your tomcat-user.xml file. My /var/lib/tomcat5.5/conf/tomcat-users.xml looks like:

    User ad can then login to both the admin and the manager part of tomcat.
    See http://www.netadmintools.com/art340.html

  • http://www.ClearEvo.com Kasidit

    Thanks very very much!

  • Yann

    Hi,

    I just installed tomcat5.5 on debian server 40r6, with:
    aptitude install sun-java5-jre
    aptitude install tomcat5.5 tomcat5.5-admin tomcat5.5-webapps

    It is then available from http://localhost:8180/, as well as the Tomcat Manager (http://localhost:8180/manager/html). So far, so good.

    Then I create a dummy HTML file I want to see when calling http://localhost:8180/foo.html, I have to put it there:
    /usr/share/tomcat5.5-webapps/ROOT/foo.html

    If I put a WAR file in this directory, it is automatically expanded:
    /var/lib/tomcat5.5/webapps/

    BUT the problem is that:
    1. it does not show up in the “Tomcat Web Application Manager” page
    2. it is not reachable by http://localhost:8180/

    If I deploy a WAR using the “Tomcat Web Application Manager”, it is then available in /var/lib/tomcat5.5/webapps, but not shown in the Manager page.

    What’s the problem?
    It seems I have 2 webapps directories, instead of one.

    How can I solve that?

    Thanks

  • Stacy

    Yann, I had the same problem. If you look at the catalina log file you see a logging.properties exception when tomcat is trying to load your app. The fix is described by brndnbg above.

  • zito

    hi

    very good, wonderfull, you do help me

    thanks

  • akram

    you may need #chmod +x -R tomcat5.5/

  • John

    I just used this tutorial on the fresh installation of Lenny without problems, the only thing was to add:

    grant {
    permission java.security.AllPermission;
    };

    to “/etc/java-6-sun/security/java.policy”

    I have no idea whether it’s the right solution, but it works :)

    But how is it with some mods etc? Isn’t it better to use apache2 + libapache2-mod-jk instead of the built-in web server in Apache Tomcat?

  • Alphonse

    I also used this tutorial to get to the admin-page but could not deploy war-archives (orbeon forms in my case). Changing from java-6-sun to java-6-openjdk did not bear fruit. Disabling the java security option in tomcat5.5 startup script and restarting tomcat5.5. did the trick. i.e.

    Edit /etc/init.d/tomcat5.5 and change TOMCAT5_SECURITY from ‘yes’ to ‘no’

    # Use the Java security manager? (yes/no)
    TOMCAT5_SECURITY=no

    Good Luck!
    My System
    Debian Lenny 5.0 amd64

    neptune:~# uname -a
    Linux neptune 2.6.28.7 #1 SMP Wed Mar 4 19:50:38 EAT 2009 x86_64 GNU/Linux
    astonish:~#

    neptune:~# java -version
    java version “1.6.0_0″
    OpenJDK Runtime Environment (build 1.6.0_0-b11)
    OpenJDK 64-Bit Server VM (build 1.6.0_0-b11, mixed mode)
    neptune:~#

  • Robert

    Hey

    ok sorry, but i try all opinions what your say.
    i set the TOMCAT5_SECURITY to “no”,
    i add the permission “permission java.io.FilePermission “/var/lib/tomcat5.5/webapps/geoserver/WEB-INF/classes/logging.properties”, “read”;” to /policy.d/04.webapps.policy

    and restart the tomcat5.5.

    i use debian lenny, java-5-jdk, tomcat5.5 and try to start geoserver.
    But when i try to start it with the manager follow message comes: “FAIL – Application at context path /geoserver could not be started

    excuse my bad english.

  • Tobias

    Same here.

    * set TOMCAT5_SECURITY to “no” in /etc/init.d/tomcat5.5 and /etc/default/tomcat5.5
    * added the permission to /etc/tomcat5.5/policy.d/04.webapps.policy

    INFO: Deploying web application archive myapp.war
    log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester).
    log4j:WARN Please initialize the log4j system properly.
    2011-03-22 21:09:40,411 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO org.springframework.orm.jpa.LocalEntityManage
    rFactoryBean - Building JPA EntityManagerFactory for persistence unit 'myappdb'
    Mar 22, 2011 9:09:41 PM org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart
    Mar 22, 2011 9:09:41 PM org.apache.catalina.core.StandardContext start
    SEVERE: Context [/myapp] startup failed due to previous errors
    2011-03-22 21:09:41,973 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO org.springframework.orm.jpa.LocalEntityManage
    rFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'myappdb'
    log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
    Mar 22, 2011 9:09:58 PM org.apache.catalina.core.StandardContext stop
    INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myapp] has not been started
    Mar 22, 2011 9:09:58 PM org.apache.catalina.startup.HostConfig checkResources
    INFO: Undeploying context [/myapp]

  • http://dichvuketoan247.com Mr Anh

    Log error tomcat:

    Apr 27, 2011 6:57:05 AM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.NullPointerException
    at org.apache.jsp.jsp.languages_jsp._jspService(languages_jsp.java:76)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:581)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:775)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:704)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:897)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:595)

    Help fix error

    Thank’s
    Apr 27, 2011 11:27:22 AM org.apache.coyote.http11.Http11BaseProtocol pause

  • croolyc

    I have same as Mr Anh – java.lang.NullPointerException
    I have no idea what’s wrong
    I think that tomcat don’t read .jar files from apps WEB-INF dir
    but howto tell him that he has to do it
    any sugestions??

    debian 6 /up to date/