简体   繁体   中英

Configuring Tomcat 6 with eclipse in ubuntu

Eclipse doesn't allow me to create web application while configuring Tomcat 6. It asked to set the Tomcat installation folder, if i set "/usr/share/tomcat6" then it shows "The Tomcat installation directory is not valid. It is missing expected file or folder conf.", if i set "/var/lib/tomcat6" then it shows "The Tomcat installation directory is not valid. It is missing expected file or folder lib/jasper-el.jar."

How to configure Eclipse with Tomcat6 in ubuntu

I experienced this same problem on Ubuntu Linux. Open a terminal window and type this in:

cd /usr/share/tomcat6
sudo ln -s /var/lib/tomcat6/conf conf

In the Eclipse configuration window it should immediately recognize this as a viable directory. I'm not exactly sure why the Tomcat installation splits the bin and conf directories but apparently Eclipse thinks they're supposed to be next to each other.

There is also an issue with the webapps directory, such if you install tomcat via apt-get. Do the same thing as the original answer for webapps as well as conf.

Open Terminal:

cd /usr/share/tomcat6
sudo ln -s /var/lib/tomcat6/conf conf
sudo ln -s /var/lib/tomcat6/webapps webapps

Sorry for the bump of a year old topic, but high hit on Google, so I figured it would be useful.

I wrote a patch for solving this problem and it has been merged in Ubuntu and Debian.

In Ubuntu 11.04 you can install tomcat6-user package. Then configure a user instance of tomcat6 by running this command

$ tomcat6-instance-create ~/my-tomcat-dir

A user instance of tomcat6 will be configured in ~/my-tomcat-dir directory.

Now to add tomcat6 inside eclipse to setup your development environment, simply point eclipse towards this directory and you will be ready to go.

If you are running an older version of Ubuntu, then you can simply download the latest version of tomcat6-user package from the Debian FTP: http://packages.debian.org/hu/sid/all/tomcat6-user/download

After a lot of fuss, this is what I had to do (partial credit to: John Skelton ):

Make sure you have added your name on the /usr/share/tomcat6/conf/tomcat-users.xml in the form (replace capitals):

<user username="USERNAME" password="PASSWORD" fullName="FULL NAME" roles="admin,manager,role1,tomcat" />

Then run:

sudo service tomcat6 stop
sudo apt-get install tomcat6-user
sudo chmod -R +rx /usr/share/tomcat6
tomcat6-instance-create ~/tomcat6
cd ~/tomcat6
rm -R bin
ln -s /usr/share/tomcat6/bin
ln -s /usr/share/tomcat6/lib
cd conf
ln -s /usr/share/tomcat6/conf/policy.d/03catalina.policy catalina.policy

Then point eclipse to your local instance and it should work (to verify check the project "Servers" created in your workspace and check that in the instance (ie localhost.config folder) you find a few files. Otherwise it didn't work.

You don't really need read and execute permissions on all the files in the tomcat6 folder, but it's a quick and dirty fix. You can always try to figure out which ones you really need. :)

I took the same idea in a different direction. Link from a local server instance to the /usr/share/tomcat6 bin and lib directories (ie your local becomes a full server, rather than making your full shared server tied to a specific local instance). My Eclipse Error Log showed catalina.policy was missing so a "touch" on /conf/catalina.policy fixed that and created my adapter. Full narative at http://possiblygonewrong.blogspot.com/2010/11/setting-up-tomcat-server-adapter-in.html

I'd download separate tomcat for development purposes from here - or there is a feature that downloads server distrubution directly from Eclipse (don't know if you have it installed). All Eclipse needs is a folder containing unpacked tomcat distro. I see no point in using ubuntu packaged tomcat for development.

@schmeedy:“尽可能接近你的生产版本/环境”怎么样?

Or even better,

cd /home/username/Desktop
wget http://mirrors.axint.net/apache//tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.tar.gz
tar xzvf apache-tomcat-6.0.29.tar.gz
cd /usr/share/tomcat6
sudo mkdir conf
cd /usr/share/tomcat6/conf
sudo cp /home/username/Desktop/apache-tomcat-6.0.29/conf/* .

This is how it worked for me :)

As told in the first answer, i created a link for conf folder in /usr/share/tomcat6 folder.

cd /usr/share/tomcat6

sudo ln -s /var/lib/tomcat6/conf conf

Then I copied all the policy files in /etc/tomcat6/policy.d folder in to /etc/tomcat6 . Removed the 01,02... prefix in each policy file. And given the read and execute permission on all the files ( sudo chmod 755 *.policy ). Then removed the existing workspace. Set up new workspace for Eclipse and configured the server again. It worked. Before starting the server in Eclipse it is essential to stop the currently running tomcat instance. It can be done by running the shutdown script ( sudo /usr/share/tomcat6/bin/shutdown.sh )

In Ubuntu 10.04, the Ubuntu repositories work easiest if you create a symbolic link for the conf folder and make sure you give generous permissions for the tomcat6 related files

cd /usr/share/tomcat6
sudo ln -s /var/lib/tomcat6/conf conf

then

sudo chmod -R 777 /usr/share/tomcat6/*

After installing the J2EE-related Eclipse packages I was able to find the server wizard and specify the /usr/share/tomcat6 successfully.

If Eclipse gets fussy, switch to a new workspace and try the wizard again until you get it right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM