Claudio Pomo
Claudio Pomo

Reputation: 2472

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

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?

Upvotes: 44

Views: 96279

Answers (20)

Kamal Singh Kirar
Kamal Singh Kirar

Reputation: 49

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

Upvotes: 4

john ding
john ding

Reputation: 397

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.

Upvotes: 0

otaviodecampos
otaviodecampos

Reputation: 1914

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

Upvotes: -1

JavaSheriff
JavaSheriff

Reputation: 7687

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

Upvotes: 0

dev4life
dev4life

Reputation: 892

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.

Upvotes: 0

ROMANIA_engineer
ROMANIA_engineer

Reputation: 56724

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

    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.

Upvotes: 10

harry
harry

Reputation: 31

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>

Upvotes: 2

tiger
tiger

Reputation: 1

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.

Upvotes: 0

Andrea
Andrea

Reputation: 6123

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.

enter image description here

Upvotes: 0

imsolo
imsolo

Reputation: 29

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.

Upvotes: 2

SSH
SSH

Reputation: 1627

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

Upvotes: 0

Priyan
Priyan

Reputation: 103

Go to Tomcat Manager Select web app -> undeploy it

Upvotes: 0

user4181812
user4181812

Reputation: 11

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.

Upvotes: 1

ilinca
ilinca

Reputation: 1343

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.

enter image description here

Upvotes: 5

DiscDev
DiscDev

Reputation: 39052

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.

Upvotes: 48

canmurat
canmurat

Reputation: 159

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

Then restart tomcat .

Upvotes: -1

AmanicA
AmanicA

Reputation: 5513

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

Upvotes: 1

Socas
Socas

Reputation: 301

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.

Upvotes: 20

Bnrdo
Bnrdo

Reputation: 5474

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)

Upvotes: 6

proko
proko

Reputation: 1210

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

Upvotes: 3

Related Questions