This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes multiple tomcat instances:Need Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "multiple tomcat instances:Need Help" Watch "multiple tomcat instances:Need Help" New topic
Author

multiple tomcat instances:Need Help

Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
I have Win XP on my machine.

I have installed Jakarta Tomcat in my "C:"

  • C:\jakarta-tomcat-5.5.9


  • My CATALINA_HOME points to above folder.

    Now, I run my "startup.bat" and it works fine.

    Now, the real question, i want to create an instance of it. Based on the other posts, I got some idea, but not sure how much correct it is.(I tried with the posts related to this issue,but somehow not helpful)

    What i did is i
    1) Created a "local" folder, inside the C:\jakarta-tomcat-5.5.9
    So my folder structure looks like C:\jakarta-tomcat-5.5.9\local
    Above folder is for "instance"
    2)Created "conf","webapps","logs","temp","work".These folders are created within the "local" folder
    3)I copied the "server.xml" and "web.xml" from the already existing folder
    4)edited the "server.xml", with SHUTDOWN "port" and "Connector Port."
    5)created a startup.bat and put it in "C:\jakarta-tomcat-5.5.9\local



    Man Suraj
    Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"
    Ben Souther
    Sheriff

    Joined: Dec 11, 2004
    Posts: 13410

    And what happened when you tried to run startup.bat?

    If you want to run multiple instances of Tomcat from the same codebase you'll need to set both the CATALINA_HOME and the CATALINA_BASE environment variables for each instances' environment.

    Disk space is cheap enough these days that most people (that I know of) just keep multiple, full, tomcat installs instead of trying to do this.

    Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
    Maan Suraj
    Ranch Hand

    Joined: Dec 20, 2007
    Posts: 299
    It gives "can not load server.xml" and then gives invocation target exception.

    Also, as per your suggestion
    Disk space is cheap enough these days that most people (that I know of) just keep multiple, full, tomcat installs instead of trying to do this.


    What value do i need to set for CATALINA_HOME environmental variable for keeping multiple ,full,tomcat installs
    Ben Souther
    Sheriff

    Joined: Dec 11, 2004
    Posts: 13410

    See section (4) from this document:
    http://tomcat.apache.org/tomcat-4.1-doc/RUNNING.txt

    It's from an older version of Tomcat so I'm not sure if it will work with recent builds.
    As I said earlier, these days with disk space being so cheap, it's hardly worth it to go through the trouble of setting this up.
    It's much easier to keep two full, independent copies of Tomcat. Then all you have to do is make sure they are using unique port numbers for the connectors and for the shutdown listener.
    Maan Suraj
    Ranch Hand

    Joined: Dec 20, 2007
    Posts: 299
    I had one question on below.
    It's much easier to keep two full, independent copies of Tomcat. Then all you have to do is make sure they are using unique port numbers for the connectors and for the shutdown listener.


    Currently, for my existing tomcat install, i have set my "CATALINA_HOME" environmental variable to "C:\jakarta-tomcat-5.5.9".

    Now say, as per you suggestion, i create an independent copy of Tomcat. Say i create "C:\program files\jakarta-tomcat-5.5.9" . Then what do i need to put in the environmental variables? I mean what entry do i need to have for my CATALINA_HOME variable for this independent Tomcat?
    Ben Souther
    Sheriff

    Joined: Dec 11, 2004
    Posts: 13410

    CATALINA_HOME tells tomcat where it's files are.

    So, make sure each instance has a CATALINA_HOME environment variable that points to where you have Tomcat.

    An easy way to do this is to set CATALINA_HOME right at the top of your startup.bat file.
    This way you know that each Tomcat is reading the right one.


    When I do this on Windows, I use the Windows service installer instead of the bat files.
    This script figures all of this out for you.
    Maan Suraj
    Ranch Hand

    Joined: Dec 20, 2007
    Posts: 299
    Now what i do is , For the independent Tomcat instance, I set the path of CATALINA_HOME in startup.bat
    I have set my CATALINA_HOME to "C:\Program Files\jakarta-tomcat-5.5.9", as mentioned below.
    The server starts.




    How do i change the port number?
    Actually i opened my "server.xml",

    Please find below the exceprt from that file


    Since , i wanted this instance of Tomcat to run on "8081" port, i changed above connector port from "80" to "8081".

    However, when i start the server, i see i need to still hit "http://localhost:80" i,e the Default one instead of "http://localhost:8081"
    Please tell me How do i change the port? Where am i wrong above?
    Ben Souther
    Sheriff

    Joined: Dec 11, 2004
    Posts: 13410

    Where are you setting CATALINA_HOME?
    Maan Suraj
    Ranch Hand

    Joined: Dec 20, 2007
    Posts: 299
    In my startup.bat (extract) .Please find my previous post for whole file.

    rem Guess CATALINA_HOME if not defined
    set CURRENT_DIR=%cd%
    if not "%CATALINA_HOME%" == "" goto gotHome
    set CATALINA_HOME=%CURRENT_DIR%
    if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
    cd ..
    set CATALINA_HOME=C:\Program Files\jakarta-tomcat-5.5.9
    cd %CURRENT_DIR%

    Please see above in bold. Wont that help?
    Ben Souther
    Sheriff

    Joined: Dec 11, 2004
    Posts: 13410

    Does that block of code even get executed if CATALINA_HOME already exists in the environment?

    I would just add it to the very top of the startup.bat file.

    Try adding some echo lines to make sure it's using the one that you intended.
    Maan Suraj
    Ranch Hand

    Joined: Dec 20, 2007
    Posts: 299
    Yep got it finally

    I would just add it to the very top of the startup.bat file.

    I did that and now my server listens to port 81 as well.

    Thanks for help Ben
    Ben Souther
    Sheriff

    Joined: Dec 11, 2004
    Posts: 13410

    Glad it's working
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: multiple tomcat instances:Need Help
     
    Similar Threads
    Loading a servlet using jdk1.4 in Tomcat
    The CATALINA_HOME enviornment variable
    Load Balancing in Tomcat 5.5
    Help!! Error in Tomcat
    tomcat startup problem..