无法“在服务器上运行”来自 Eclipse 的 Web 应用程序
从 Eclipse 运行我的 WebApp 项目时,大多数情况下它都能正确运行。但是,如果错误地停止服务器,我会在“控制台”视图中杀死它,而不是从“服务器”视图中“停止”服务器。 在运行干净的项目时,我得到了这个
java.lang.NullPointerException
at org.eclipse.wst.common.componentcore.internal.util.VirtualReferenceUtilities.getDefaultProjectArchiveName(VirtualReferenceUtilities.java:81)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getJavaClasspathReferences(J2EEModuleVirtualComponent.java:332)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getNonManifestRefs(J2EEModuleVirtualComponent.java:236)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:160)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:208)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:201)
at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.hasConsumableReferences(SingleRootUtil.java:217)
at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.validateSingleRoot(SingleRootUtil.java:165)
at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.isSingleRoot(SingleRootUtil.java:93)
at org.eclipse.jst.common.internal.modulecore.SingleRootExportParticipant.canOptimize(SingleRootExportParticipant.java:84)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.canOptimize(FlatVirtualComponent.java:136)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.cacheResources(FlatVirtualComponent.java:118)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.fetchResources(FlatVirtualComponent.java:101)
at org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.members(FlatComponentDeployable.java:147)
at org.eclipse.wst.server.core.internal.ModulePublishInfo.hasDelta(ModulePublishInfo.java:418)
at org.eclipse.wst.server.core.internal.ServerPublishInfo.hasDelta(ServerPublishInfo.java:443)
at org.eclipse.wst.server.core.internal.Server.hasPublishedResourceDelta(Server.java:1539)
at org.eclipse.wst.server.core.internal.Server$ResourceChangeJob$1.visit(Server.java:214)
at org.eclipse.wst.server.core.internal.Server.visitModule(Server.java:2929)
at org.eclipse.wst.server.core.internal.Server.visit(Server.java:2913)
at org.eclipse.wst.server.core.internal.Server$ResourceChangeJob.run(Server.java:225)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
,在启动时,我得到了这个,
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Webapp does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4319)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
请帮助恢复。
When running my WebApp project from Eclipse most of times it run correctly. But if by mistake to stop server, I kill it in "Console" view on instead of "Stop" Server from "Servers" View.
While running clean project I get this
java.lang.NullPointerException
at org.eclipse.wst.common.componentcore.internal.util.VirtualReferenceUtilities.getDefaultProjectArchiveName(VirtualReferenceUtilities.java:81)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getJavaClasspathReferences(J2EEModuleVirtualComponent.java:332)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getNonManifestRefs(J2EEModuleVirtualComponent.java:236)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:160)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:208)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:201)
at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.hasConsumableReferences(SingleRootUtil.java:217)
at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.validateSingleRoot(SingleRootUtil.java:165)
at org.eclipse.jst.common.internal.modulecore.SingleRootUtil.isSingleRoot(SingleRootUtil.java:93)
at org.eclipse.jst.common.internal.modulecore.SingleRootExportParticipant.canOptimize(SingleRootExportParticipant.java:84)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.canOptimize(FlatVirtualComponent.java:136)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.cacheResources(FlatVirtualComponent.java:118)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.fetchResources(FlatVirtualComponent.java:101)
at org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.members(FlatComponentDeployable.java:147)
at org.eclipse.wst.server.core.internal.ModulePublishInfo.hasDelta(ModulePublishInfo.java:418)
at org.eclipse.wst.server.core.internal.ServerPublishInfo.hasDelta(ServerPublishInfo.java:443)
at org.eclipse.wst.server.core.internal.Server.hasPublishedResourceDelta(Server.java:1539)
at org.eclipse.wst.server.core.internal.Server$ResourceChangeJob$1.visit(Server.java:214)
at org.eclipse.wst.server.core.internal.Server.visitModule(Server.java:2929)
at org.eclipse.wst.server.core.internal.Server.visit(Server.java:2913)
at org.eclipse.wst.server.core.internal.Server$ResourceChangeJob.run(Server.java:225)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
And while launching I get this
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Webapp does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4319)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
Please help recover from this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
我很难让它工作,但是感谢“Alexander Pogrebnyak”(参见在 WTP(Eclipse) tomcat 服务器中部署一个 war 文件)我能够通过 m2e 使 Eclipse Web 项目与 Maven 一起工作:
在开始之前,我必须说我是一个非常多疑的人,所以我总是首先使用“Eclipse > Project > Clean...”菜单清理所有项目(没有选中“立即启动构建”选项)。我也没有选中“Eclipse > 项目 > 自动构建”选项。
顺便说一句,我想你已经安装了 m2e 插件,或者我要说的没有意义......
好吧,让我们开始:
首先,再见服务器配置:
1 ) 如果您以前的服务器配置中有任何项目,请将其删除(右键单击服务器并选择“添加和删除”选项)
2) 清理服务器工作目录(右键单击服务器并选择“Tomcat 服务器工作目录”) )
3) 清理编译的“剩余”(右键单击服务器并选择“清理”)
4) 从“服务器”选项卡中删除服务器配置
5) 完全删除“服务器”项目/文件夹(显示在“项目资源管理器”选项卡中)
6)奖励:我还删除了我的服务器运行时环境(“Eclipse > Window > Preferences > Server > Runtime Environments”)
第二,“Maven clean”(如果您的 Web 项目有“Maven 性质”):
1)右键单击您的 Web 项目
2)“弹出菜单 > 运行方式 > Maven clean”
这应该会清除您的目标文件夹
第三,安装 m2e WTP 集成(是的) !它不是“默认”的。花了一整天的时间来弄清楚):
1)打开 Maven“Discovery”选项(Eclipse > Windows > Preferences > Maven > Discovery)
2)按“打开目录”按钮(“m2e Marketplace”)窗口应该出现)
3) 向下滚动直到找到“WTP Integration”选项,然后“选中”它!
4) 按“完成”
5) 将出现“类似插件屏幕”。 “下一步”,“下一步”,“同意”,等等,等等,等等......
第四,离开 Eclipse 而不是再次运行它:
1)如果没有要求重新启动 Eclipse(我发现很难相信你不会),自己重启吧!
第五,maven重新集成:
1)为项目添加Maven性质(右键单击您的Web项目,“弹出菜单>配置>转换为Maven项目”)
2)更新您的maven配置(是的) ,是的,可疑,我知道)。再次右键单击您的 Web 项目,现在其图标上带有“M”(“弹出菜单 > Maven > 更新项目”)
3) 运行 maven 安装(右键单击您的 Web 项目,“弹出菜单 > 运行” As > Maven install")
4) 构建您的项目("Eclipse > Project > Build All")
第六,将其全部投入使用:
1) 部署并运行您的 Web 应用程序(右)单击您的 Web 项目,“弹出菜单 > 运行方式 > 在服务器上运行”)
2) 系统将要求您创建另一个服务器配置。它将再次创建“服务器”项目/文件夹,但事实就是这样。
就是这样!!!我必须承认,一旦我运行服务器,它就不起作用了,但是这次(我不知道为什么)找不到“Log4J”库。在一个“project clean”+“maven clean”和一个“maven install”+“project build”之后,另一条消息指出找不到我的 Servlet 类。我再次执行了“project clean”+“maven clean”和“maven install”+“project build”,然后“瞧”!它起作用了(这就是为什么我如此怀疑)。
我开始担心这个新的 Juno + m2e double...Indigo 或 Ganymede 从来没有遇到过这种问题...但我想我可以再次信任 Eclipse(可以吗?)
I had a hard time to make it work, but thanks to "Alexander Pogrebnyak" (see deploying a war file in WTP(Eclipse) tomcat server) I was able to make Eclipse Web Projects work with Maven through m2e:
Before starting, I must say that I'm a very suspicious man, so I always start by cleaning all my projects using "Eclipse > Project > Clean..." menu (without "start a build immediately" option checked). I also do not have "Eclipse > Project > Build Automatically" option checked.
By the way, I suppose that you will have your m2e plugin installed already, or what I'm going to state has no meaning...
Well, let's start:
First, bye bye Server configuration:
1) If your have any project in a previous server configuration, remove it (right click on the server and select "Add and remove" option)
2) Clean your server work directory (right click on the server and select "Tomcat Server Work Directory")
3) Clean the compiled "leftovers" (right click on the server and select "Clean")
4) Remove your server configuration from the "Servers" tab
5) Completely delete your "Servers" project/folder (shown in your "Project Explorer" tab)
6) BONUS: I also remove my server runtime environment ("Eclipse > Window > Preferences > Server > Runtime Environments")
Second, "Maven clean" (if your web project has a "Maven nature"):
1) Right click your web project
2) "Pop up Menu > Run As > Maven clean"
This should wipe out your target folder
Third, Instal m2e WTP integration (yeah! It does not come as "default". One whole day to figure it out):
1) Open Maven "Discovery" option (Eclipse > Windows > Preferences > Maven > Discovery)
2) Press "Open Catalog" Button (a "m2e Marketplace" window should appear)
3) Scroll down until you find the "WTP Integration" option, then "check" it!
4) Press "Finish"
5) A "plugin screen like" will appear. "Next", "Next", "Agree", blah, blah, blah...
Fourth, leave Eclipse than run it again:
1) If not asked to restar Eclipse (that I find hard to believe you won't), restart it yourself!
Fifth, maven reintegration:
1) Add Maven nature to the project (Right click your web project, "Pop up Menu > Configure > Convert to Maven Project")
2) Update your maven configuration (Yeah, yeah, suspicious, I know). Right click your web project again, now with a "M" on its icon ("Pop up Menu > Maven > Update Project")
3) Run a maven install (Right click your web project, "Pop up Menu > Run As > Maven install")
4) Build your project ("Eclipse > Project > Build All")
Sixth, put it all to work:
1) Deploy and run your web application (Right click your web project, "Pop up Menu > Run As > Run on Server")
2) You will be asked to create another server configuration. It will create the "Servers" project/folder again, but that's the way it is.
That's it!!! I gotta admit, once I ran the server, it didn't work, but this time (i dunnot know why) "Log4J" libraries could not be found. After one "project clean" + "maven clean" and one "maven install" + "project build" another message stating that my Servlet class could not be found. Once again, I executed a "project clean" + "maven clean" and a "maven install" + "project build" and "voila"!!! It worked (And that's why I'm so suspicious).
I was starting to get worried with this new Juno + m2e double... Never had this kind of problem with Indigo or Ganymede... But I guess I can trust Eclipse again (can I?)
不要做那些疯狂的宇宙解决方法!!
这工作正常:
将这些行添加到您的“.project”文件(隐藏):
享受!
为什么?如果你检查那个不存在的目录,那么
"../.metadata/blah/blah/tmp0/wtpwebapps/YOURPROJECT/"
是空的:那么你的构建不会创建 WAR...! !因为 maven 插件不理解他必须!
我在比较来自不同部署/非部署项目的两个 .project 文件后发现了这一点...
希望有所帮助!
Dont do those crazy cosmic workarounds !!
This works fine:
Add to your ".project" file (hidden) these lines:
Enjoy !
Why? if you check that unexisting directory, well, that
"../.metadata/blah/blah/tmp0/wtpwebapps/YOURPROJECT/"
is EMPTY: then your build aint creating the WAR... !!!Because maven plugin isnt understanding HE HAVE TO !
I found this after comparing two .project files from both different deploying/non-deploying projects...
Hope helped !
我已经删除了“问题文件夹”.metadata.plugins\org.eclipse.wst.server.core\tmp0\ 并且它现在可以工作了:)
I have deleted the "problem folder" .metadata.plugins\org.eclipse.wst.server.core\tmp0\ and it works now :)
我有完全相同的问题和完全相同的异常,但我只需通过将 POM 的包类型指定为 war(如“war”)并右键单击项目并选择“Maven > >”就解决了问题。更新项目配置”,然后将该 Web 模块重新部署到 tomcat 服务器,就这样!
I have the exact same problem and exact exception, but I solved the problem just by specify package type of POM to war like "war" and right click the project and select 'Maven > Update Project Configuration', then re-deploy that web module to tomcat server, that's it!
就做maven->更新项目配置并从 Eclipse 中清理/构建。项目将被加载。
Just do maven -> Update project configuration and clean/build from your eclipse. Project will be loaded.
我也遇到过这个问题,但原因不同。
问题源于
错误的服务器名称([项目名称] != [服务器名称])
。我认为我可以通过重新创建服务器来弄清楚。
此问题可以通过以下步骤解决:
[Servers]
并删除服务器。[Project Explorer]
并删除服务器(您创建的)。[项目 -> Clean]
[Servers]
和新服务器。server.xml
。[Servers]
并删除服务器。I suffered from this problem, but cause was different.
Problem sprang from
wrong server name([Project Name] != [Server Name])
.I thought that i could figure out by recreate Server.
This Problem can solve by following below steps:
[Severs]
and remove server.[Project Explorer]
and delete Server(you created).[Project -> Clean]
[Severs]
and new server.server.xml
foor your web server.[Severs]
and remove server.我对这个问题感到非常困惑,因为在问题发生之前我还有另一个 jar 依赖项正在工作。我正在使用 Eclipse Luna,它已经具有 m2e 集成,并且上述解决方案都不适合我。
当向 Maven War 项目添加新的 jar 依赖项时,问题就开始了,但当该依赖项在 pom.xml 中被注释掉时,它仍然运行良好。
幸运的是,我能够比较这两个项目,最终问题与新 jar 项目中缺少的项目方面有关:实用程序模块。
I was quite puzzled by the problem because I had another jar dependency working before the issue occurred. I am using Eclipse Luna which already had m2e integration and none of the above solutions worked for me.
The problem started when adding a new jar dependency to a maven war project, but it still worked well when that one was commented out in the pom.
Luckily I was able to compare both projects and eventually the issue was related to a missing project facet in the new jar project: Utility Module.
检查 Tomcat doc 文档库 xyz 不存在或不可读目录:
清理项目完成后,您可以手动执行“清理...”,然后“发布”(从服务器视图中 Tomcat 上的上下文菜单)吗?
Check Tomcat doc for Document base xyz does not exist or is not a readable directory:
Can you manually do "Clean..." and then "Publish" (from context menu on Tomcat in Servers view) after clean project is completed?
我已经停止使用这种运行我的网络应用程序的方法。
我使用
mvn tomcat:run
代替。容易多了。虽然我不知道如何调试。I have stopped using this method of running my webapp.
I use
mvn tomcat:run
instead. Much easier. Though I don't know how to debug.此问题可能是由于您的本地项目与代码存储库不同步引起的。
我建议刷新/同步您的项目。
This problem might be caused by your local project being out of sync with your code repository.
I would suggest to refresh/synchronize your project.
我遇到了同样的问题,清理和重新创建服务器没有帮助。但是当我部署另一个项目时,它能够成功启动。经过多次比较,我发现 .project 文件存在差异。因此,我将工作项目的 .project 文件的内容复制到有问题的项目中,将其添加回服务器,然后它就可以工作了。以下是有效的 .project 文件的内容。请注意,您需要相应地更改项目名称:
I encountered the same issue and cleaning and recreating server does not help. But when I deployed another project, it was able to start successfully. After much comparison, I found differences in the .project files. So I copy the contents of the .project file of the working project into the one that has problem, add it back to the server and it works. Following is the contents of the .project file that works. Note that you need to change the name of the project accordingly:
尝试了一切但没有运气。我的日食中只有一个项目。关闭eclipse,重命名eclipse目录,再次解压,在新的eclipse中重新启动。它起作用了。
不,它效率不高。
Tried everything with no luck. I just had one project in my eclipse. Shut eclipse down, rename the eclipse directory, unzip it again, started fresh in new eclipse. It worked.
No it is not efficient.
我遵循的步骤将 100% 工作:
Steps which I followed and will work 100%:
就我而言,复制(从工作项目)就足够了:
In my case it was enough to copy (from working project):