can't we create multiple instances of tomcat7 in ubuntu?

Posted June 12, 2016 4.2k views
DigitalOceanDigitalOcean ArticlesConfiguration ManagementJavaDeployment

I created duplicate instance of tomcat by creating a directory under /var/lib/tomcat7-a. Later i updated server.xml with new port i copied file and web.xml.

finally created init service for tomcat7-a and updated with defaults.
I tried to start the program when i pose a command like,
service tomcat7-a start
it gives “tomcat7-a not installed”
it stops at below script in init program,
if [ ! -f “$CATALINAHOME/bin/bootstrap.jar” ]; then
failure_msg “$NAME is not installed.... kjfkdj”
exit 1

what should i do now?

  • In your case, note that $CATALINA_BASE should be different from $CATALINA_HOME, where the former is where you created your instance and the latter is where tomcat7 is installed. Usually, $CATALINA_HOME is installed in /usr/share/tomcat7 on Ubuntu.

  • I configured the
    $ cd /var/lib/
    $ sudo mkdir tomcat7-a
    $ cd /var/lib/tomcat7-a
    $ sudo mkdir conf temp webapps work logs
    $ sudo mkdir conf temp webapps work logs
    $ cd ..

    $ sudo chown -R tomcat7:tomcat7 tomcat7-a
    $ sudo ln- s /var/lib/tomcat7/conf/ /var/lib/tomcat7-a/conf

    $ sudo ln- s /var/lib/tomcat7/conf/web.xml /var/lib/tomcat7-a/conf

    $ sudo ln- s /var/lib/tomcat7/conf/policy.d/ /var/lib/tomcat7-a/conf

    $ sudo cp /var/lib/tomcat7/conf/server.xml /var/lib/tomcat7-a/conf/

    –>changed the port 8080 to 8081 in tomcat7-a server.xml
    $ cd /etc/init.d/
    $ sudo cp tomcat7 tomcat7-a

    DESC=”Tomcat servlet engine”
    $ sudo service tomcat7-a start

    $ sudo update -rc.d tomcat7-a defaults

    Now, when i try to start the new instance it kicks with an error like above what i mentioned. Now i changed the CATALINABASE=/var/lib/tomcat7-a and CATALINAHOME=/usr/share/tomcat7 in new instance init config.

    Now it is starting when i use service tomcat7-a start. But when i go to browser it kicks an error like,
    http://localhost:8081/ Failed to load resource: the server responded with a status of 404 (Not Found)

    am i did anything wrong in config? ratherthan displaying tomcat manager page it displaying blank screen.. when i go to console i see this error.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi Jaccs

Were you able to fix the issue. I followed the same instructions but now facing following issue:

root@XXXXX:/etc/init.d# sudo service tomcat8-a start
Failed to start tomcat8-a.service: Unit tomcat8-a.service not found.

i have same problem right now