Running Tomcat on Sun Solaris 10

Solaris 10 comes pre installed with a Tomcat 5.5 installation.

Having found little information on the setup I decided to contribute what little useful things I found here

THE ENVIRONMENT

The following assumes you have Java already installed. java is usually installed in /usr/java. This is a symbolic link from the actual installation in /usr/jdk/jdk1.6.0_[Update]

THE PROBLEM

Solaris comes with apache and tomcat preinstalled, just not in the locations you would expect unless your are familiar with Solaris. Solaris 10 comes with a new method for starting and stopping services on system startup, called SMF(Service Management Facility).

Software installation directory

/usr/apache/tomcat55

Configuration, logs, and deployed applications (webapps directory)

/var/apache/tomcat55

If you where to run multiple instances of tomcat your would want to duplicate the whole /var/apache/tomcat55 directory, create new startup.sh shutdown.sh scripts setting a CATALINA_BASE environment variable pointing to your new instance.

Configuring SMF to start and stop tomcat

Create file in the following location. (The location does not really matter but the convention says so.)

/var/svc/manifest/application/web/tomcat.xml

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
    tomcat_svr.xml : Tomcat service  manifest, Daniel Berg
-->

<service_bundle type='manifest' name='Tomcat55'>
<service name='application/web/tomcat' type='service' version='1'>

   <single_instance />

   <exec_method
      type='method'
      name='start'
      exec='/usr/apache/tomcat55/bin/startup.sh'
      timeout_seconds='30' />

   <exec_method
      type='method'
      name='stop'
      exec='/usr/apache/tomcat55/bin/shutdown.sh'
      timeout_seconds='30' />

   <instance name='default' enabled='false' />

   <stability value='Unstable' />

   <template>
      <common_name>
         <loctext xml:lang='C'>Apache Tomcat 5.5.27</loctext>
      </common_name>
      <documentation>
         <manpage title='tomcat' section='1' manpath='/usr/man' />
      </documentation>
   </template>

</service>
</service_bundle>

To import this file run

# svccfg import /var/svc/manifest/application/web/tomcat.xml

Starting and stopping tomcat

To start tomcat you can now run

# svcadm enable tomcat

To stop tomcat your would run

# svcadm disable tomcat

To se the current status:

#- svcs -lp tomcat

Output is something like the following

fmri         svc:/application/web/tomcat:default
name         Apache Tomcat 5.5.27
enabled      true
state        online
next_state   none
state_time   Fri Feb 26 13:25:28 2010
logfile      /var/svc/log/application-web-tomcat:default.log
restarter    svc:/system/svc/restarter:default
contract_id  183
process      8303 /usr/jdk/jdk1.6.0_18/bin/sparcv9/java -Djava.util.logging.config.file=/var/apac

You can see the log output from SMF in the filereferences as logfile in the above output for any troubleshooting.

Running tomcat through SMF negates the need to run tomcat using nohup on Solaris.


CategoryFAQ

  • No labels