How get tomcat6 configured?

Murray Eisenberg murrayeisenberg at gmail.com
Tue Mar 5 12:32:16 PST 2013


I've figured out, I think, how to get tomcat6 configured so that it actually starts (under OS X 10.8.2). The trick was to copy the folder  /opt/local/share/java/tomcat6/conf to /opt/local/share/java/tomcat6/webapps/conf. 

Now if I run

  sudo  /opt/local/share/java/tomcat6/bin/tomcatctl start

it does start, and I can get info about it:

  sudo  /opt/local/share/java/tomcat6/bin/tomcatctl info
Tomcat is running (pid 4829)

CATALINA_HOME       /opt/local/share/java/tomcat6
CATALINA_BASE       /opt/local/share/java/tomcat6/webapps
CATALINA_TMPDIR     /opt/local/share/java/tomcat6/webapps/temp
JAVA_HOME           /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
CLASSPATH           :/opt/local/share/java/tomcat6/bin/bootstrap.jar:/opt/local/share/java/tomcat6/bin/commons-logging-api.jar
TOMCAT_PIDFILE      /opt/local/share/java/tomcat6/webapps/logs/tomcat6.pid
JAVA_OPTS            -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
JPDA_OPTS    

A problem, though:  If I browse to http://127.0.0.1:8080 (or just localhost:8080) I just get a blank page. I would expect to see instead the page:

     /opt/local/share/java/tomcat6/webapps/ROOT/index.html

I tried things like 

  http://127.0.0.1:8080/index.html
  http://127.0.0.1:8080/ROOT/index.html

but still just a blank page. (And there's nothing actually there if through Safari's 

I notice that JAVA_HOME points ultimately to Apple's current JDK, namely: 

  /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

But I also have jdk1.7.0_15.jdk installed. So I tried changing tomcat6's file setenv.sh so as to include:

  JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home
  export JAVA_HOME

But with that, now, tomcat6 won't even start!

What could be wrong -- and how fix?

On 5 Mar 2013 12:10:50 -0500, Murray Eisenberg <murrayeisenberg at gmail.com> wrote:

> I apologize: the problem with the setenv CATALINA_BASE command was a typo: I put it into a file named /etc/luanchd.conf instead of /etc/launchd.conf.
> 
> I fixed that. And now CATALINA_BASE is seen in the system environment.
> 
> But still, running
> 
>  sudo /opt/local/share/java/tomcat6/bin/startup.sh
> 
> doesn't remove the other errors being sent by conf_setup.sh.
> 
> I get the same errors even if I cd to /opt/local/share/java/tomcat6/bin and then run:  sudo ./startup.sh
> 
> So what's wrong with the tomcat6 configuration?
> 
> In particular, might there be some permissions issue? I have:
> 
> cd /opt/local/share/java
> 
> ls -l tomcat6
> total 0
> drwxr-xr-x  20 root  admin  680 Mar  4 13:15 bin
> drwxr-xr-x   3 root  admin  102 Sep 19 10:09 common
> drwxr-xr-x  17 _www  _www   578 Mar  4 14:49 conf
> drwxr-xr-x  17 root  admin  578 Sep 19 10:09 lib
> drwxr-xr-x   3 _www  _www   102 Sep 19 10:09 logs
> drwxr-xr-x   6 root  admin  204 Sep 19 10:09 shared
> drwxr-xr-x   3 _www  _www   102 Sep 19 10:09 temp
> drwxr-xr-x   9 _www  _www   306 Mar  4 15:09 webapps
> drwxr-xr-x   3 _www  _www   102 Sep 19 10:09 work
> 
> ls -l tomcat6/conf
> total 360
> -rw-r--r--  1 root  _www  10636 Feb 10 17:48 catalina.policy
> -rw-r--r--  1 _www  _www  10636 Sep 19 10:09 catalina.policy.sample
> -rw-r--r--  1 root  _www   3713 Feb 10 17:48 catalina.properties
> -rw-r--r--  1 _www  _www   3713 Sep 19 10:09 catalina.properties.sample
> -rw-r--r--  1 _www  _www   1395 Sep 19 10:09 context.xml
> -rw-r--r--  1 _www  _www   3290 Sep 19 10:09 logging.properties
> -rw-r--r--  1 root  _www   6616 Feb 10 17:49 server.xml
> -rw-r--r--  1 _www  _www   6616 Sep 19 10:09 server.xml.sample
> -rwxr-xr-x+ 1 root  _www    347 Feb 10 17:45 setenv.local
> -rwxr-xr-x  1 _www  _www    347 Sep 19 10:09 setenv.local.sample
> -rw-r--r--  1 root  _www   1651 Mar  4 14:49 tomcat-users.xml
> -rw-r--r--  1 _www  _www   1530 Sep 19 10:09 tomcat-users.xml.sample
> -rw-r--r--  1 root  _www   1654 Mar  4 14:38 tomcat-users.xml~
> -rw-r--r--+ 1 root  _www  52470 Feb 10 17:43 web.xml
> -rw-r--r--  1 _www  _www  52470 Sep 19 10:09 web.xml.sample
> 
> On Mar 4, 2013, at 11:31 PM, Murray Eisenberg <murrayeisenberg at gmail.com> wrote:
> 
>> I tried your solution with the correct path (which was my error in posting the query). . .
>> 
>> sudo CATALINA_BASE=$CATALINA_BASE /opt/local/share/java/tomcat6/bin/conf_setup.sh
>> 
>> and now that script seems to run.
>> 
>> [But I don't understand why that form is required: My understanding is that with Mountain Lion, if not before, one sets up system-wide environment variables by creating file /etc/launchd.conf and putting setenv commands there. In the case at hand:
>> 
>> setenv CATALINA_BASE  /opt/local/share/java/tomcat6
>> 
>> But that doesn't seem to be picked up.]
>> 
>> Next issue, I now ran:  
>> 
>> sudo CATALINA_BASE=$CATALINA_BASE /opt/local/share/java/tomcat6/bin/startup.sh
>> 
>> And got a bunch of error messages in the output:
>> 
>> conf_setup.sh: file conf/catalina.policy is missing, but no corresponding conf/catalina.policy.sample file was found to repair it!
>> conf_setup.sh: file conf/catalina.properties is missing, but no corresponding conf/catalina.properties.sample file was found to repair it!
>> conf_setup.sh: file conf/server.xml is missing, but no corresponding conf/server.xml.sample file was found to repair it!
>> conf_setup.sh: file conf/tomcat-users.xml is missing, but no corresponding conf/tomcat-users.xml.sample file was found to repair it!
>> conf_setup.sh: file conf/web.xml is missing, but no corresponding conf/web.xml.sample file was found to repair it!
>> conf_setup.sh: file conf/setenv.local is missing, but no corresponding conf/setenv.local.sample file was found to repair it!
>> Using CATALINA_BASE:   /opt/local/share/java/tomcat6/webapps
>> Using CATALINA_HOME:   /opt/local/share/java/tomcat6
>> Using CATALINA_TMPDIR: /opt/local/share/java/tomcat6/webapps/temp
>> Using JRE_HOME:        /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
>> Using CLASSPATH:       /opt/local/share/java/tomcat6/bin/bootstrap.jar
>> 
>> Evidently, startup.sh calls conf_setup.sh.
>> 
>> But there _are_ already files:
>> 
>>   /opt/local/share/java/tomcat6/conf/catalina.policy
>>   /opt/local/share/java/tomcat6/conf/server.xml       (and corresponding sample file)
>>   /opt/local/share/java/tomcat6/conf/web.xml          (and corresponding sample file)
>>   /opt/local/share/java/tomcat6/conf/tomcat-users.xml (and corresponding sample file)
>>    /opt/local/share/java/tomcat6/conf/setenv.local    (and corresponding sample file)
>> 
>> Note, though, that the output from startup.sh says:
>> 
>> Using CATALINA_BASE:   /opt/local/share/java/tomcat6/webapps
>> 
>> Which is _not_ what it was set to be in the commands invoking startup.sh or conf_setup.sh directly.
>> 
>> What's going on here? I'm now completely mystified!
>> 
>> 
>> On Mar 4, 2013, at 9:14 PM, Lawrence Vel?zquez <larryv at macports.org> wrote:
>> 
>>> On Mar 4, 2013, at 5:58 PM, Murray Eisenberg <murrayeisenberg at gmail.com> wrote:
>>> 
>>>> In my ~/.profile, I've set:
>>>> 
>>>> export JAVA_HOME=$(/usr/libexec/java_home)
>>>> export CATALINA_BASE=/opt/local/share/java/tomcat6
>>>> 
>>>> And re-loaded the profile into Terminal with: source ~/.profile
>>>> 
>>>> But wen I run 
>>>> 
>>>> sudo /opt/local/share/tomcat6/bin/conf_setup.sh
>>>> 
>>>> I get message:  CATALINA_BASE must be set in my environment
>>>> 
>>>> How do I fix that?
>>> 
>>> By default, sudo executes commands with a minimal environment, so CATALINA_BASE won't be passed along. The easiest thing to try is explicitly specifying the variable in the sudo invocation.
>>> 
>>>  sudo CATALINA_BASE=$CATALINA_BASE /opt/local/share/tomcat6/bin/conf_setup.sh

---
Murray Eisenberg                     murrayeisenberg at gmail.com
80 Fearing Street                      phone 413 549-1020 (H)
Amherst, MA 01002-1912







More information about the macports-users mailing list