Eclipse:启动静态资源时出错 java.lang.IllegalArgumentException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4438374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse: Error starting static Resources java.lang.IllegalArgumentException
提问by Tim
I have a project called myproject2 in my Eclipse IDE. I have a Tomcat application server and I can add there the resource myproject2 (it is a Spring MVC project).
我的 Eclipse IDE 中有一个名为 myproject2 的项目。我有一个 Tomcat 应用程序服务器,我可以在那里添加资源 myproject2(它是一个 Spring MVC 项目)。
Now I closed the myproject2 in Eclipse, removed myproject2 from the Tomcat resources and do a fresh Subversion checkout with projectname: myproject3.
现在,我在 Eclipse 中关闭了 myproject2,从 Tomcat 资源中删除了 myproject2,并使用 projectname:myproject3 执行了全新的 Subversion 检出。
REstarting the IDE I want to set myproject3 to the Tomcat server so this should be deployed. But all what is available is myproject2 to choose. So I choose it. I can access http://localhost:8080/myproject2/but I get this warning and serve in the console:
重新启动 IDE 我想将 myproject3 设置为 Tomcat 服务器,因此应该部署它。但所有可用的都是 myproject2 可供选择。所以我选择它。我可以访问http://localhost:8080/myproject2/但我收到此警告并在控制台中提供服务:
14.12.2010 11:43:11 org.apache.catalina.startup.HostConfig deployDescriptor
WARNING: A docBase C:\Spring\apache-tomcat-6.0.29-windows-x86\apache-tomcat-6.0.29\webapps\myproject2 inside the host appBase has been specified, and will be ignored
14.12.2010 11:43:11 org.apache.catalina.core.StandardContext resourcesStart
SERVE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Spring\apache-tomcat-6.0.29-windows-x86\apache-tomcat-6.0.29\webapps\myproject3 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:4249)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4418)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
14.12.2010 11:43:11 org.apache.catalina.core.StandardContext start
SERVE: Error in resourceStart()
14.12.2010 11:43:11 org.apache.catalina.core.StandardContext start
SERVE: Error getConfigured
14.12.2010 11:43:11 org.apache.catalina.core.StandardContext start
SERVE: Context [/myproject3] startup failed due to previous errors
14.12.2010 11:43:11 org.apache.catalina.core.StandardContext stop
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myproject3] has not been started
So what's wrong here? Why don't I have a myproject3 to choose what should be deployed in Tomcat?
那么这里有什么问题呢?为什么我没有一个 myproject3 来选择应该在 Tomcat 中部署什么?
Does anyone know?
有人知道吗?
Best Regards.
此致。
Update:
更新:
.project (myproject2):
.project (myproject2):
<projectDescription>
<name>myproject</name>
<comment>My-Project. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
<projects/>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
.project (myproject3)
.project (myproject3)
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>myproject</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
采纳答案by Tim
I searched a few days for it, but I did not find a solution. So I reinstalled everything and set it up from a new project.
我搜索了几天,但没有找到解决方案。所以我重新安装了所有东西并从一个新项目中设置它。
回答by Ladlestein
Are you using the Eclipse WTP and Tomcat-server integration to deploy your app, or are you creating a WAR and deploying it to Tomcat yourself?
您是使用 Eclipse WTP 和 Tomcat 服务器集成来部署您的应用程序,还是您正在创建一个 WAR 并将其部署到 Tomcat?
If you're using the integration, you might try creating a WAR and deploying it yourself, next, to see what happens. Post an update - I'll follow up after.
如果您正在使用集成,您可以尝试创建一个 WAR 并自己部署它,然后看看会发生什么。发布更新 - 之后我会跟进。
I've read your original question again. Maybe the problem is with the way you created myproject3. I suspect doesn't have the necessary project nature to be deployed to a server by Eclipse. ("Project nature" is an Eclipse concept; a project can have several of them; different parts of Eclipse check project natures to determine what projects they can act on.) You said you checked out the code from Subversion and created the project in one step. That doesn't necessarily create the right type of project. Eclipse's J2EE deployment mechanism only allows you to deploy projects with a certain project nature - I think it's "eclipse.common.project.facet.core.nature". Also, your project needs certain Eclipse builders to be viable; I think "org.eclipse.wst.common.project.facet.core.builder" is one of them.
我再次阅读了您的原始问题。也许问题在于您创建 myproject3 的方式。我怀疑没有必要的项目性质由 Eclipse 部署到服务器。(“项目性质”是一个 Eclipse 概念;一个项目可以有多个;Eclipse 的不同部分检查项目性质以确定它们可以作用于哪些项目。)你说你从 Subversion 检出代码并在一个项目中创建了项目步。这不一定会创建正确类型的项目。Eclipse 的 J2EE 部署机制只允许你部署具有特定项目性质的项目——我认为是“eclipse.common.project.facet.core.nature”。此外,您的项目需要某些 Eclipse 构建器才能可行;我认为“org.eclipse.wst.common.project.facet.core.builder”
The .project file at the root of your project is where natures and builders are configured. You should examine those files in your two projects.
项目根目录下的 .project 文件是配置自然和构建器的地方。您应该检查两个项目中的这些文件。
Q: in your Eclipse workspace, are myproject2/.project and myproject3/.project significantly different (besides the name)? Post the differences here.
问:在您的 Eclipse 工作区中,myproject2/.project 和 myproject3/.project 是否有显着不同(除了名称之外)?在此处发布差异。
Q: does myproject2, in SVN, contain the .project file?
Q: SVN 中的 myproject2 是否包含 .project 文件?
Answering those questions should tell you more. You may want to carefully examine the different options for checking out and creating a project in a single step.
回答这些问题应该会告诉你更多。您可能需要仔细检查用于在单个步骤中检出和创建项目的不同选项。
回答by Shiva
This happens because the project was run before using that server or was configured using that server. Hence its path is stored in a folder inside your tomcat directory.
发生这种情况是因为项目是在使用该服务器之前运行的,或者是使用该服务器配置的。因此,它的路径存储在您的 tomcat 目录内的文件夹中。
In you tomcat folder, go to conf\Catalina\localhost\
在你的 tomcat 文件夹中,转到 conf\Catalina\localhost\
In this folder, delete the xml file that corresponds to your project.
在此文件夹中,删除与您的项目对应的 xml 文件。
Alternatively, remove the server and add it again.
或者,删除服务器并重新添加。
回答by chrisjleu
I think Ladlesteinis certainly on the right track but I can add a bit more context to this problem in the way that I was able to reproduce it:
我认为Ladlestein肯定是在正确的轨道上,但我可以通过重现它的方式为这个问题添加更多背景信息:
I have a similar Eclipse (Indigo) set up whereby I have a Maven project and use the Eclipse WTP feature to deploy to an embedded Tomcat 7 server. It all works fine if I import the project as a Maven project from within Eclipse but my issue occurs when I perform a mvn eclipse:clean
and mvn eclipse:eclipse
from the command line. This of course rebuilds the Eclipse .project
file but leaves it without some apparently important Naturesand buildCommands.
我有一个类似的 Eclipse (Indigo) 设置,其中我有一个 Maven 项目并使用 Eclipse WTP 功能部署到嵌入式 Tomcat 7 服务器。如果我从 Eclipse 中将项目作为 Maven 项目导入,则一切正常,但是当我从命令行执行 a mvn eclipse:clean
and时会出现问题mvn eclipse:eclipse
。这当然会重建 Eclipse.project
文件,但没有一些明显重要的Natures和buildCommands。
I observe a .project
file very similar to the erroneous one in the question (in myproject2) and within Eclipse itself the project is no longer what Eclipse calls a "Dynamic Web Module" - hence not deployable - nor is it any longer a Maven project. I was able to fix this as follows:
我观察到一个.project
与问题中的错误文件非常相似的文件(在 myproject2 中),并且在 Eclipse 本身中,该项目不再是 Eclipse 所谓的“动态 Web 模块”——因此不可部署——也不再是 Maven 项目。我能够解决这个问题如下:
Firstly make it a Maven project by adding the following to the .project
file (I don't know if there is a better way through Eclipse itself):
首先通过在.project
文件中添加以下内容使其成为Maven项目(我不知道Eclipse本身是否有更好的方法):
<buildSpec>
...
...
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
</buildCommand>
</buildSpec>
<natures>
...
...
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
Now you can ensure the project is up to date by right clicking on the project and running Maven > Update Project Configuration...
.
现在,您可以通过右键单击项目并运行Maven > Update Project Configuration...
.
Next you can make the project deployable through Properties > Project Facets > Dynamic Web Module
(checkbox). Here is a more complete set of instructions for making your project a Dynamic Web Module.
接下来,您可以通过Properties > Project Facets > Dynamic Web Module
(复选框)使项目可部署。这是一组更完整的说明,可让您的项目成为动态 Web 模块。
In the end your .project
file should look more like this:
最后,您的.project
文件应该更像这样:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>project1</name>
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
</natures>
</projectDescription>
回答by Ehsan Khodarahmi
I'd similar problem(with eclipse & tomcat7 & WTP) & I solved it by manually editing eclipse_workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmpX\server.xml
where tmpX is temporary folder which caches projects publish settings.
我有类似的问题(使用 eclipse & tomcat7 & WTP)& 我通过手动编辑解决它, eclipse_workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmpX\server.xml
其中 tmpX 是缓存项目发布设置的临时文件夹。
回答by Amin Oruji
This problem will be resolved only by creating a new project.
这个问题只能通过创建一个新项目来解决。
回答by user2414808
I'd similar problem(with eclipse & tomcat7 & WTP). Solved it by removing (commenting out ) the following line from %CATALINA_HOME%/conf/server.xml
我有类似的问题(使用 eclipse & tomcat7 & WTP)。通过从 %CATALINA_HOME%/conf/server.xml 中删除(注释掉)以下行来解决它
Context docBase="[CATALINA_HOME]\webapps\\ROOT" path="" reloadable="false"/>
上下文 docBase="[CATALINA_HOME]\webapps\\ROOT" path="" reloadable="false"/>
回答by zhouwubai
Solve my problem. I just copy the .project file from another runnable web project and modify the project name attribute
解决我的问题。我只是从另一个可运行的 web 项目中复制 .project 文件并修改项目名称属性
回答by Heena Hussain
I faced the same problem. What did a trick for me, in the overview of server (double-click on your server in servers tab) I had to set the deploy path to "MY_SERVER_PATH\webapps" .Hope it will be helpful .
我遇到了同样的问题。什么对我有用,在服务器概述中(在服务器选项卡中双击您的服务器)我必须将部署路径设置为“MY_SERVER_PATH\webapps”。希望它会有所帮助。
Thanks :-)
谢谢 :-)
回答by Patience Mpofu
Removing the server instance from my IDE and adding it back solved my problem.
从我的 IDE 中删除服务器实例并将其添加回来解决了我的问题。