I need to install Tomcat 6 for a school assignment. I thought the installation process was easy as counting 123, but it turned out to be a few hours long of head scratching. Well, the first start is to setup a few environment variables as required by Tomcat:
CATALINA_BASE=/home/kenno/bin/apache-tomcat-6.0.13 CATALINA_HOME=/home/kenno/bin/apache-tomcat-6.0.13 export CATALINA_HOME; export CATALINA_BASE# JAVA_HOME and Path to java, javac JAVA_HOME=/usr/lib/j2sdk1.6-sun/bin export JAVA_HOME; export PATH=${JAVA_HOME}/bin:${PATH}:.
It can be stored in a setEnv.sh
file, and run with source setEnv.sh
to load those variables.
Then when I tried to run Tomcat with the following command, there was some error with the
BASEDIR
:
kenno@kampongcham:~$ $CATALINA_HOME/bin/startup.sh The BASEDIR environment variable is not defined correctly This environment variable is needed to run this program
I wasted a few hours trying to search for solutions on Google, and as when I was about to temporarily give up for dinner, I found an unexpected answer from one of the blogs.
“I need to set all the shell scripts in $CATALINA_HOME/bin
to be executable”
So let’s fix it:
kenno@kampongcham:~$ cd $CATALINA_HOME/bin kenno@kampongcham:~/bin/apache-tomcat-6.0.13/bin$ chmod +x *.sh
Finally, it’s done. We can now run tomcat without any errors:
kenno@kampongcham:~/bin/apache-tomcat-6.0.13/bin$ ./startup.sh Using CATALINA_BASE: /home/kenno/bin/apache-tomcat-6.0.13 Using CATALINA_HOME: /home/kenno/bin/apache-tomcat-6.0.13 Using CATALINA_TMPDIR: /home/kenno/bin/apache-tomcat-6.0.13/temp Using JRE_HOME: /usr/lib/j2sdk1.6-sun/bin
That’s it folks. When you setup Tomcat on your machine, make sure you specify the correct path to all the variables mentioned above.
Thanks to Michael for the solution: Tomcat 6 on OSX
Thank you!!
Glad this post is helpful. 🙂
searched around google and found this post. THANKS! now i can eat lunch.
Enjoy your lunch. The last time I had this problem, I didn’t have dinner until I get it fixed too.
Fine post, thank you. But as for me, I prefer not to hardcode . into PATH.
Well, I have tried all of the above and am still getting the error
The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program
I am using Tomcat 5.5.27 on Linux Debian.
I am also using su to the user that has rights.
Thanks for any help as I am stumped!
Melodie
The BASEDIR environment variable is not defined correctly This environment variable is needed to run this program. it’s a permission issue. run bellow command
cd $CATALINA_HOME/bin
chmod u+x *
That was good.
Thank you. I was looking for something like that.
Tomcat 6 is now in squeeze, and is included with ubuntu since 9.04, which means, you can install via packages in a way that’s coherent with the existing system. I’m not sure about the state of the dependencies but you might be able to install the squeeze packages on lenny without much fussing.
Thanks for the update @tychoish. I haven’t touched Tomcat since 2007, a few months after this post was written.
and fair enough, really, I can’t see much merit to it, unless you have something that already needs it… but when you need it, it’s a good thing indeed. but you have some google juice here, and now that lenny is stable, I just wanted to clarify…
Hey guys,
If you guys are getting base dir error then please check the post under given on IT Operationz. Hope it will help you to solve your problem.
http://www.itoperationz.com/2009/06/how-to-install-and-configure-apache-tomcat-6-on-debian-5/
A startup script for tomcat is also included in that post.
Thanks for the tip. The bit about all the shell scripts being set needing to be executable really helped. I had switched startup.sh and catalina.sh but it wasn’t enough.