Unable to “Run on Server” a webapp from Eclipse

2019-03-08 08:12发布

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.

15条回答
Lonely孤独者°
2楼-- · 2019-03-08 09:01

I have deleted the "problem folder" .metadata.plugins\org.eclipse.wst.server.core\tmp0\ and it works now :)

查看更多
不美不萌又怎样
3楼-- · 2019-03-08 09:02

Dont do those crazy cosmic workarounds !!

This works fine:

Add to your ".project" file (hidden) these lines:

 <natures>
    <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
    <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>org.eclipse.m2e.core.maven2Nature</nature>
    <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
  </natures>

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 !

查看更多
你好瞎i
4楼-- · 2019-03-08 09:03

Check Tomcat doc for Document base xyz does not exist or is not a readable directory:

Document base does not exist or is not a readable directory The URL specified by the war parameter must identify a directory on this server that contains the "unpacked" version of a web application, or the absolute URL of a web application archive (WAR) file that contains this application. Correct the value specified by the war parameter.

Can you manually do "Clean..." and then "Publish" (from context menu on Tomcat in Servers view) after clean project is completed?

查看更多
登录 后发表回答