Eclipse tomcat error: Document base does not exist

2019-01-16 07:53发布

问题:

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?

回答1:

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.

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



回答2:

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

mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0

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



回答3:

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

  • 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

  • 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.



回答4:

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 WebContent folder of the Dynamic Web Project I just created in place of webapp folder which is the standard folder of my company. I found out that, in Project Properties > Deployment Assembly, WebContent folder 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/wtpwebapps because the root specified in Deployment Assembly does not exist anymore.

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



回答5:

If using Eclipse STS

  1. open the server view

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

  3. right click -> clean

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.



回答6:

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

Thanks Kamal



回答7:

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:

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.

Clean the eclipse workspace. (Project - clean all)

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

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).



回答8:

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.



回答9:

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



回答10:

i have solved this error by adding removing and adding again the jar files from WebContent/WEB-INF/lib folder. and i did the same in properties of project ie(Right click on project->Build Path->configure build Path) by selecting Add External Jar option.



回答11:

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:

<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>


回答12:

Go to Tomcat Manager Select web app -> undeploy it



回答13:

Today I was working with some other project and getting some errors in starting server (tomcat7), so first I cleaned the server and tried but no luck, then I deleted the server and made new one.

The project on which I was working was started working fine, but another project started giving me the same exception, I again deleted the server and tried but the same case, even I was unable to hit the tomcat landing page i.e. localhost:8888/. I really don't know how and why all that happened.

I tried several things like clean,add/remove then I started searching SO.

After some research I thought to give one more chance then I started server again this time both of my projects started working fine but still getting 404 on tomcat page



回答14:

As a trivial problem, the project that you're trying to start can be closed (this could be missable, if you have many projects into the workspace!). Just do right click -> Open Project, in this case.



回答15:

I came across this problem today, then solve it by editing the server.xml in directory of %tomcat_home%\conf, just as below:

<Context docBase="E:\apache-tomcat-7.0.52\webapps\ROOT" path="/ROOT" reloadable="true" source="org.eclipse.jst.j2ee.server:pc-ui"/>

I don't know whether it is MyEclipse that have genarated the "Context" element in element of "Host", but I change it according to the error info diaplayed in IDE console.



回答16:

I got this error a few times. I got it because my project wasn't building correctly after running the "mvn eclipse:eclipse" line. Make sure your project is being built correctly, then add and remove the project from the server.



回答17:

This could happen if you execute maven to build a java project

mvn eclipse:eclipse 

Instead of executing maven to build a web java project as:

mvn eclipse eclipse -Dwtpversion=2.0


回答18:

You can look into tomcat\conf\Catalina\localhost,if you can see the xml file which its name matches your error message.You can just delete the xml file and restart your tomcat.



回答19:

Try , right click tomcat --> Add / Remove , then in opened window , remove All projects in Configured side..

Then restart tomcat .



回答20:

Before adopting any other solution, make sure that the project is open.