views:

6794

answers:

3

Hi,

I'm setting up my development environment for writing web applications using Java, and I'm in need of some help.

What I have done:

Installation of Java SE 6 from Sun

I installed (sudo apt-get install …) the following packages (one at a time as some of them requires user interaction) to get Java SE 6 from Sun: sun-java6-bin sun-java6-doc sun-java6-fonts sun-java6-javadb sun-java6-jdk sun-java6-jre sun-java6-plugin sun-java6-source .

I also set JAVA_HOME by adding JAVA_HOME=”/usr/lib/jvm/java-6-sun/” to /etc/environment.

Began installing and configuring Tomcat 5.5

I installed (sudo apt-get install …) the following packages: tomcat5.5 tomcat5.5-admin

What I have at the moment:

I'm able to connect to http://localhost:8180/admin and get the admin web application which I installed by installing the tomcat5.5-admin package. The Tomcat server is running as a deamon.

My problems and questions:

  1. The environment variable $CATALINA_HOME doesn't seem to be defined. How should I define it? (The same way as my $JAVA_HOME maybe? But if so, which path should I assign it?)
  2. To deploy a war, can I just copy the JAR to $CATALINA_HOME/webapps? Or do I need to change the file permissions on the war? (Here I assume $CATALINA_HOME is set correctly.)
  3. What's the user and password I need for the admin web application I installed? How do I change them?
  4. Are there any best practices for Tomcat 5.5 on Ubuntu which I should think of?
+2  A: 

You could do an "echo $CATALINA_HOME" to check if it has been defined or not.

It should be set to the installation directory of tomcat. Mine is set to /usr/local/tomcat

Are you using an IDE? I was able to provide a user name and password for admin when adding Tomcat as a server in NetBeans. You need to set the Catalina_Home first.

I had some trouble installing Tomcat on Ubuntu (through sudo apt-get install and synaptic manager) with NetBeans. The best option is to download the tar file (using wget) and extract it to your choice of path.

Epitaph
$CATALINA_HOME is not defined.
DeletedAccount
Did you try setting it to the location of the tomcat directory installation?
Epitaph
Thanks for your answer. I set it to CATALINA_HOME=/var/lib/tomcat5.5 . I prefer to use it from the repository in case a bug fix comes out.
DeletedAccount
+2  A: 
  1. The path where your Tomcat is installed. I don't know, I am on openSUSE, and usually install tomcat in my preferred directory, most likely under my /home/adeel/. You can check it using whereis tomcat command on your console, or may be try whereis catalina. It might give you the path of your tomcat. This time I am running tomcat under my Netbeans, just for a try, and didn't set the environment variable.

  2. You may just copy the war file under the *CATALINA_HOME/webapps/* directory. Or you can even place it exploded. I don't think you would need to change the privileges of your war.

  3. You can set it in *CATALINA_HOME/webapps/tomcat-users.xml*. Below is the example,

    <?xml version='1.0' encoding='utf-8'?>

    <tomcat-users>
    <role rolename="manager"/>
    <role rolename="tomcat"/> <user username="tomcat" password="tomcat" roles="tomcat,manager"/>

    </tomcat-users>

  4. Not really. The only suggestion I have in my mind at the moment is, to set it as user-variable, not in system-variable.

NOTE: In case you are using Tomcat under Netbeans, number of tomcat configuration is provided within the IDE, for example, you can change the port, username/password, VM options, etc. Beware Netbeans keep its own place and file for web-app deployment in Tomcat, and doesn't use *CATALINA_HOME/webapps/*.

Adeel Ansari
+3  A: 

You have to add it manually. You can either do it in the file:

 ~/.bashrc  <---- for session-wide variables
 /etc/environment <---- for system-wide variables

You should set CATALINA_HOME in here by adding the following line:

 CATALINA_HOME=PATH_TO_WHERE_YOU_ARE_RUNNING_TOMCAT

Afterwards, if you edited .bashrc, reload the file, by typing in:

 Source .bashrc

If it was /etc/environment, I believe you can do the same thing. If that doesn't work, try logging off then in. If that doesn't work, just restart.

Anton