Eclipse tomcat 错误:文档库不存在或不是可读目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8492454/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:45:54  来源:igfitidea点击:

Eclipse tomcat error: Document base does not exist or is not a readable directory

eclipsetomcat7illegalargumentexception

提问by Claudio Pomo

13-dic-2011 17.00.36 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
13-dic-2011 17.00.36 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Preventivi' did not find a matching property.
13-dic-2011 17.00.36 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
13-dic-2011 17.00.36 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8443"]
13-dic-2011 17.00.37 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
13-dic-2011 17.00.37 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 983 ms
13-dic-2011 17.00.37 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
13-dic-2011 17.00.37 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
13-dic-2011 17.00.37 org.apache.catalina.core.StandardContext resourcesStart
GRAVE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /home/claudio/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Preventivi does not exist or is not a readable directory
    at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:140)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4880)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5060)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)
13-dic-2011 17.00.37 org.apache.catalina.core.StandardContext startInternal
GRAVE: Error in resourceStart()
13-dic-2011 17.00.37 org.apache.catalina.core.StandardContext startInternal
GRAVE: Error getConfigured
13-dic-2011 17.00.37 org.apache.catalina.core.StandardContext startInternal
GRAVE: Context [/Preventivi] startup failed due to previous errors
13-dic-2011 17.00.37 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
13-dic-2011 17.00.37 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8443"]
13-dic-2011 17.00.37 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
13-dic-2011 17.00.37 org.apache.catalina.startup.Catalina start
INFO: Server startup in 319 ms

I've run my webapp project in Eclipse, but today I received the message in console. Tomcat return me a 404 page error. Maybe the problem is that the folder where I would write doesn't exist. Where is the trick?

我已经在 Eclipse 中运行了我的 webapp 项目,但今天我在控制台中收到了消息。Tomcat 返回 404 页面错误。也许问题是我要写的文件夹不存在。诀窍在哪里?

回答by DiscDev

The easiest solution (and what worked for me) was to delete my tomcat server from the "Servers" view in Eclipse, then create a new server and add all the appropriate modules to it.

最简单的解决方案(也是对我有用的)是从 Eclipse 的“服务器”视图中删除我的 tomcat 服务器,然后创建一个新服务器并向其中添加所有适当的模块。

Sometimes tomcat gets confused and the easiest/least time consuming way to resolve things is to start over.

有时 tomcat 会感到困惑,解决问题的最简单/最省时的方法是重新开始。

回答by Socas

i have the same error, just run this maven command repeatedly and solve the problem.

我有同样的错误,只需重复运行此 maven 命令即可解决问题。

mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0

eclipse was not recognizing that this was a web project, so never deploy the application.

eclipse 没有意识到这是一个 web 项目,所以永远不要部署应用程序。

回答by ROMANIA_engineer

I had the same problem using Tomcat 7 & Eclipse Mars.
I solved it as follows:

我在使用 Tomcat 7 和 Eclipse Mars 时遇到了同样的问题。
我是这样解决的:

  • stop Tomcat
  • open server.xml

    Ctrl+ Shift+ R> type "server.xml" > Open

  • search for "<Context docBase"

    Ctrl+ F> type "<Context" > Find

  • remove all <Context .../>tags from here:

    <?xml version="1.0" encoding="UTF-8"?>
    ...
    <Server port="8005" shutdown="SHUTDOWN">
        ...
        <Service name="Catalina">
            ...
            <Engine defaultHost="localhost" name="Catalina">
                ...
                <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
                    ...
                    <!-- Remove the following lines! -->
                    <Context docBase="App1" path="/App1" reloadable="true" source="org.eclipse.jst.j2ee.server:App1" />
                    <Context docBase="App2" path="/App2" reloadable="true" source="org.eclipse.jst.j2ee.server:App2" />
                </Host>
            </Engine>
        </Service>
    </Server>
    
    • probably at the end of the last line that has to be removed is </Host>(don't remove </Host>!)
  • Go to Servers tab > right click on the project(s) > Remove > OK

    remove

  • Right click on the project > Run As > Run on Server > Finish

    Now it should work!
    If you check the server.xml file, you'll see that a new correct "<Context ... />" line was generated.

  • 停止Tomcat
  • 打开server.xml

    Ctrl+ Shift+ R> 输入“server.xml” > 打开

  • 搜索“ <Context docBase

    Ctrl+ F> 输入“ <Context” > 查找

  • <Context .../>从这里删除所有标签:

    <?xml version="1.0" encoding="UTF-8"?>
    ...
    <Server port="8005" shutdown="SHUTDOWN">
        ...
        <Service name="Catalina">
            ...
            <Engine defaultHost="localhost" name="Catalina">
                ...
                <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
                    ...
                    <!-- Remove the following lines! -->
                    <Context docBase="App1" path="/App1" reloadable="true" source="org.eclipse.jst.j2ee.server:App1" />
                    <Context docBase="App2" path="/App2" reloadable="true" source="org.eclipse.jst.j2ee.server:App2" />
                </Host>
            </Engine>
        </Service>
    </Server>
    
    • 可能在必须删除的最后一行的末尾是</Host>(不要删除</Host>!)
  • 转到服务器选项卡 > 右键单击​​项目 > 删除 > 确定

    消除

  • 右键单击项目 > 运行方式 > 在服务器上运行 > 完成

    现在它应该可以工作了!
    如果您检查 server.xml 文件,您将看到生成了一个新的正确的“ <Context ... />”行。

回答by Bnrdo

This might be late but for the benefit of the those who might encounter the same problem in the future, I'll share what I experienced.

这可能为时已晚,但为了将来可能遇到相同问题的人的利益,我将分享我的经历。

I got this problem after I deleted the WebContentfolder of the Dynamic Web ProjectI just created in place of webappfolder which is the standard folder of my company. I found out that, in Project Properties > Deployment Assembly, WebContentfolder is still used as the root of the web application (Deploy Path : "/"). Thus, Eclipse doesn't copy the project to .metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebappsbecause the root specified in Deployment Assemblydoes not exist anymore.

之后我删除我得到这个问题WebContent的文件夹Dynamic Web Project只是代替创建我webapp的文件夹这是我公司的标准文件夹。我发现,在Project Properties > Deployment Assembly,WebContent文件夹中仍然用作 Web 应用程序的根目录(Deploy Path : "/")。因此,Eclipse 不会将项目复制到,.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps因为 中指定的根Deployment Assembly不再存在。

I fixed it by editing that entry then correcting it with the folder I am using in place of the default WebContent(the webappfolder)

我通过编辑该条目来修复它,然后使用我正在使用的文件夹代替默认文件夹WebContentwebapp文件夹)进行更正

回答by ilinca

If using Eclipse STS

如果使用 Eclipse STS

  1. open the server view

  2. select the server that you're trying to publish to

  3. right click -> clean

  1. 打开服务器视图

  2. 选择您要发布到的服务器

  3. 右键单击 -> 清理

I had this problem come up a couple of times and this always seemed to fix it. I suppose the other solutions work too but they seem more complicated to me.

我遇到过这个问题几次,这似乎总能解决它。我想其他解决方案也有效,但对我来说它们似乎更复杂。

enter image description here

enter image description here

回答by proko

Looking at the exception you get, this looks like a problem with publishing your WEB-App (eg. Eclipse WTP could mess something up). First things that come in my mind:

看看你得到的异常,这看起来像是发布你的 WEB 应用程序的问题(例如 Eclipse WTP 可能会搞砸)。我想到的第一件事:

Check your Tomcat server settings: go to Servers - double click on your server. Get your 'Server Locations - Server Path' and check if it exists and check the user/group read/write permissions. eg. ls -lh somepath/.medadata/.plugins/.org.eclipse.wst.server.core/tmp0 You must be owner or at least in same group for the folder.

检查您的 Tomcat 服务器设置:转到服务器 - 双击您的服务器。获取您的“服务器位置 - 服务器路径”并检查它是否存在并检查用户/组读/写权限。例如。ls -lh somepath/.medadata/.plugins/.org.eclipse.wst.server.core/tmp0 您必须是该文件夹的所有者或至少在同一组中。

Clean the eclipse workspace. (Project - clean all)

清理 Eclipse 工作区。(项目 - 全部清理)

Clean/Republish your wep-app (right click on server, clean, publish).

清理/重新发布您的 wep 应用程序(右键单击服务器,清理,发布)。

Check if the application is published, there should be a folder named Preventini in /home/claudio/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ Also check the permissions here again (see above).

检查应用程序是否已发布,在/home/claudio/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/中应该有一个名为Preventini的文件夹,并再次检查此处的权限(请参阅以上)。

回答by Kamal Singh Kirar

This could happen because "Tomcat\conf\Catalina" folder. Please delete this folder.

这可能是因为“ Tomcat\conf\Catalina”文件夹。请删除此文件夹。

Thanks Kamal

谢谢卡马尔

回答by imsolo

Happened to me a couple of times.

发生在我身上几次。

Windows > Show view > Servers>

窗口 > 显示视图 > 服务器 >

A List of servers will be displayed at bottom Right click on it and delete.

服务器列表将显示在底部右键单击并删除。

Now while running your project, Manually re select the server from list of existing servers and run.

现在在运行您的项目时,从现有服务器列表中手动重新选择服务器并运行。

回答by harry

I got this problem when I imported a project and run it with Tomcat. I fixed it when I opened .project file and added some code:

当我导入一个项目并使用 Tomcat 运行它时,我遇到了这个问题。我在打开 .project 文件并添加了一些代码时修复了它:

<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>

回答by AmanicA

I had to remove an offending project/module from the tomcat config view, under the modules tab.

我不得不从 tomcat 配置视图中的模块选项卡下删除有问题的项目/模块。