Eclipse 停止将项目的任何 [maven] 依赖项部署到 tomcat
我现在遇到这个问题有一段时间了。我尝试了很多东西都失败了,所以我不得不切换到 netbeans 才能进行开发。但 netbeans 缺乏一些重要的功能,所以我真的需要它才能在 eclipse 中工作。
从头开始: 我有一个“父”maven 项目,在我们的 svn 存储库中包含多个模块。其中 2 个模块是我需要在 tomcat 服务器中部署的 Web 项目。这些 Web 项目有多个依赖项,其中包括父 Maven 项目的其他模块。
我使用 eclipse ganymede 运行此配置,但 3 周前,我在启动服务器时开始收到 ClassNotFoundException ,我不知道为什么会发生这种情况。
从那时起,我尝试获取新的 Eclipse (Java EE) 软件包,但无论我怎么做,都会发生这样的情况:
- 我运行 maven+svn 来运行 eclipse,并将我的 tomcat 安装添加到 eclipse 的服务器列表中。
- 我查看了父项目,其中包括模块。 Eclipse 为我提供了完整的项目列表。
- 糟糕的是:我无法将 2 个 Web 项目添加到 tomcat,它告诉我无法添加任何项目(意思是“您没有任何 Web 项目!”)。另外,我无法在 Servlet 类上选择“运行方式 -> 在服务器上运行”(“选择不包含任何可以在服务器上运行的资源”),即使它们明显扩展了 HttpServlet。由于我花了太多时间在这上面,我找到了如何处理这个问题:将项目转换为项目属性中的“多面项目”。
- 现在我可以将这两个项目添加到 tomcat 服务器
启动服务器时,我得到
致命:加载 WebappClassLoader 时出错 上下文:/BEWeb 代表:假 存储库: /WEB-INF/类/ ---------->父类加载器: org.apache.catalina.loader.StandardClassLoader@55ae3b4d de.comp.utils.servlet.SInvokerServlet
此类位于作为依赖项列出的模块之一中
WEB-INF已部署项目的 /lib
为空。根本没有库,maven 和/或 eclipse 不做三周前所做的事情。
我尝试摆弄 .settings
中的 eclipse 文件以及 .project
和 .classpath
,但没有任何有用的结果。 有人能指出我正确的方向吗?如果你需要的话,我会从头开始做一切,这不会有什么不同,因为我已经这样做了很多次(使用不同版本的 eclipse、maven、tomcat,...) 如果您需要我发布任何文件,我将很乐意遵守。
由于这让我在很长一段时间里彻夜难眠,我将悬赏于此。 谢谢到目前为止。
==================================
编辑以回答即将到来的问题
只是为了检查:从命令行构建项目并手动部署它们确实有效,对吗?
是的,mvn package
工作正常,将该 .war 文件复制到 tomcat 会生成一个工作应用程序,而且该 war 文件包含所有依赖项。
当您说“获取新的 Eclipse (Java EE) 软件包”时,您的意思是您现在使用的是 Eclipse Indigo (3.7)?
是的。但我在 3.5 中遇到了同样的问题,Eclipse 版本的行为没有显示出任何差异。
当你说“I get eclipse with maven+svn running”时,你使用的是m2eclipse还是使用maven eclipse插件生成了eclipse配置?
我已经安装了 m2e 并使用“右键单击 -> 签出为 Maven 项目”从 svn 签出了项目。不过,存储库中没有 Eclipse 特定的文件,它们似乎是在签出时生成的。 当我使用mvn eclipse:eclipse
,然后关闭+重新打开项目时,我无法将它们添加到tomcat服务器(“没有可以从服务器添加或删除的资源”),这意味着Eclipse 不将它们识别为 Web 项目。
I'm having this problem for a while now. I tried so many things that failed that I had to switch to netbeans in order to be able to develop. But netbeans lacks some important features, so I really need this to work in eclipse.
From scratch:
I have a "parent" maven project with several modules in our svn repo. 2 of the modules are web projects that I need to deploy in a tomcat server. These web projects have several dependencies, among them are the other modules of the parent maven project.
I had this configuration running with eclipse ganymede, but 3 weeks ago I started to get ClassNotFoundException
s while starting the server, I have no clue why this started happening.
Since then I've tried to get new Eclipse (Java EE) packages, but no matter how I do it, this is what happens:
- I get eclipse with maven+svn running and add my tomcat installation to eclipse's server list.
- I check out the parent project, this includes the modules. Eclipse gives me a whole list of projects.
- The crap starts: I cannot add the 2 web projects to the tomcat, it tells me no projects can be added (meaning "you dont have any web projects!"). Also, I cannot choose "Run as -> Run on Server" on Servlet classes ("Selection did not contain any resources that can run on a server"), even though they clearly extend HttpServlet. Since I spent way too many hours into this, I found out how to deal with this: Convert the project into a "Faceted Project" in the project's properties.
- Now I can add both projects to the tomcat server
When starting the server, i get
FATAL: Error loading WebappClassLoader
context: /BEWeb
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@55ae3b4d
de.comp.utils.servlet.SInvokerServletThis class is in one of the modules that are listed as a dependency
WEB-INF/lib
of the deployed project ist empty. No libs at all, maven and/or eclipse doesn't do what it did 3 weeks ago.
I tried messing around with the eclipse files in .settings
and also with .project
and .classpath
, but nothing useful turned out.
Can someone point me in the right direction? I'll do everything from scratch if you need me to, it would not make a difference as I did this a lot of times already (with different versions of eclipse, maven, tomcat, ...)
If you need me to post any files, I'll be happy to comply.
Since this kept me awake at nights for quite some time now, I'll put a bounty on this one.
thx so far.
================================
EDIT in order to answer the upcoming questions
Just to check: building your projects from the command line and deploying them by hand does work, right?
Yes, mvn package
works fine, copying that .war file to tomcat results in a working application, also the war file contains all dependencies.
When you say "get new Eclipse (Java EE) packages", do you mean you are now using Eclipse Indigo (3.7)?
Yes. But I had the same problems with 3.5, the eclipse versions didn't show any difference in their behavior.
When you say "I get eclipse with maven+svn running", are you using m2eclipse or have you generated eclipse configuration using maven eclipse plugin?
I have m2e installed and checked out the projects from svn using "Right click -> Checkout as Maven Project". There are no eclipse-specific files in the repository though, it seems they are being generated upon checkout.
When I use mvn eclipse:eclipse
, then close+reopen the projects, I cannot add them to the tomcat server ("There are no resources that can be added or removed from the server"), meaning that eclipse does not recognize them as web projects.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先:不要将maven-eclipse-plugin与m2e/m2eclipse一起使用,两者不兼容。 m2e 应该能够导入您的 Maven 项目并按照 Eclipse 的预期进行设置。
您是否安装了 m2e 的 WTP 插件?这个 博客文章可能值得一读。
如果您的任何 pom.xml 文件调用任何特定插件(例如用于代码生成),您可能需要相应的 m2e 插件。这篇wiki 帖子可能会让您了解原因。
您可能会考虑的另一种尝试是设置基于 Helios 的环境。不过,请检查您可能需要的所有插件是否仍然可用。
First of all: do not use the maven-eclipse-plugin together with m2e/m2eclipse, the two are not compatible. m2e should be able to import your Maven projects and set them up as Eclipse expects.
Did you install the WTP add-on for m2e? This blog post may be worth reading.
If any of your pom.xml files invokes any specific plugin (e.g. for code generation) you may need a corresponding m2e add-on. This wiki post may give you an idea of why.
Another attempt you might consider is setting up a Helios based environment. Check that all the plugins you might need are still available, though.