简体   繁体   English

在ubuntu中使用eclipse配置Tomcat 6

[英]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." Eclipse不允许我在配置Tomcat 6时创建Web应用程序。它要求设置Tomcat安装文件夹,如果我设置“/ usr / share / tomcat6”,则显示“Tomcat安装目录无效。它缺失预期的文件或文件夹conf。“,如果我设置”/ var / lib / tomcat6“,那么它显示”Tomcat安装目录无效。它缺少预期的文件或文件夹lib / jasper-el.jar。“

How to configure Eclipse with Tomcat6 in ubuntu 如何在ubuntu中使用Tomcat6配置Eclipse

I experienced this same problem on Ubuntu Linux. 我在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. 在Eclipse配置窗口中,它应立即将其识别为可行目录。 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. 我不确定为什么Tomcat安装会拆分bin和conf目录,但显然Eclipse认为它们应该是彼此相邻的。

There is also an issue with the webapps directory, such if you install tomcat via apt-get. webapps目录也存在问题,例如,如果您通过apt-get安装tomcat。 Do the same thing as the original answer for webapps as well as conf. 做与webapps和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. 我写了一个补丁来解决这个问题,它已经在Ubuntu和Debian中合并了。

In Ubuntu 11.04 you can install tomcat6-user package. 在Ubuntu 11.04中,您可以安装tomcat6-user软件包。 Then configure a user instance of tomcat6 by running this command 然后通过运行此命令配置tomcat6的用户实例

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

A user instance of tomcat6 will be configured in ~/my-tomcat-dir directory. 将在~/my-tomcat-dir目录中配置tomcat6的用户实例。

Now to add tomcat6 inside eclipse to setup your development environment, simply point eclipse towards this directory and you will be ready to go. 现在要在eclipse中添加tomcat6来设置你的开发环境,只需将eclipse指向这个目录,你就可以开始了。

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 如果您运行的是旧版本的Ubuntu,那么您只需从Debian FTP下载最新版本的tomcat6-user软件包: 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): 确保在表单中的/usr/share/tomcat6/conf/tomcat-users.xml中添加了您的名字(替换大写):

<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. 然后将eclipse指向本地实例并且它应该工作(验证检查工作区中创建的项目“Servers”并检查实例(即localhost.config文件夹)中是否找到了一些文件。否则它不起作用。

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. 您真的不需要对tomcat6文件夹中的所有文件具有读取和执行权限,但这是一个快速而又脏的修复。 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). 从本地服务器实例链接到/ usr / share / tomcat6 bin和lib目录(即,您的本地成为完整服务器,而不是使您的完整共享服务器绑定到特定的本地实例)。 My Eclipse Error Log showed catalina.policy was missing so a "touch" on /conf/catalina.policy fixed that and created my adapter. 我的Eclipse错误日志显示catalina.policy丢失,因此/conf/catalina.policy上的“触摸”修复并创建了我的适配器。 Full narative at http://possiblygonewrong.blogspot.com/2010/11/setting-up-tomcat-server-adapter-in.html 完整的比较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). 我从这里下载单独的tomcat用于开发目的 - 或者有一个功能直接从Eclipse下载服务器distrubution(不知道你是否安装了它)。 All Eclipse needs is a folder containing unpacked tomcat distro. 所有Eclipse需要的是一个包含解压缩的tomcat发行版的文件夹。 I see no point in using ubuntu packaged tomcat for development. 我认为使用ubuntu打包的tomcat进行开发没有意义。

@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. 正如在第一个答案中所说,我在/ usr / share / tomcat6文件夹中创建了conf文件夹的链接。

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 . 然后我将/etc/tomcat6/policy.d文件夹中的所有策略文件复制到/ etc / tomcat6中 Removed the 01,02... prefix in each policy file. 删除了每个策略文件中的01,02 ...前缀。 And given the read and execute permission on all the files ( sudo chmod 755 *.policy ). 并给出所有文件的读取和执行权限( sudo chmod 755 * .policy )。 Then removed the existing workspace. 然后删除现有工作区。 Set up new workspace for Eclipse and configured the server again. 为Eclipse设置新工作区并再次配置服务器。 It worked. 有效。 Before starting the server in Eclipse it is essential to stop the currently running tomcat instance. 在Eclipse中启动服务器之前,必须停止当前运行的tomcat实例。 It can be done by running the shutdown script ( sudo /usr/share/tomcat6/bin/shutdown.sh ) 可以通过运行shutdown脚本来完成( 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 在Ubuntu 10.04中,如果为conf文件夹创建符号链接并确保为tomcat6相关文件提供慷慨的权限,则Ubuntu存储库最简单

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. 安装与J2EE相关的Eclipse包之后,我能够找到服务器向导并成功指定/ usr / share / tomcat6。

If Eclipse gets fussy, switch to a new workspace and try the wizard again until you get it right. 如果Eclipse变得挑剔,请切换到新的工作区并再次尝试向导,直到你做对了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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