Java.lang.IllegalArgumentException: Document base dir does not exist or is not a readable directory

javarelative-pathtomcat

I have seen the same kind of questions in stackoverflow but those questions were not helping me. I wanted to run my app from outside of Tomcat, so I have used "Context" of Tomcat.
In the context I have given the docBase like below.

<Context docBase="../IdP/IdPserver/idp" // which is relative path
         privileged="true"
         antiResourceLocking="false"
         antiJARLocking="false"
         unpackWAR="false" />

The actual location(absolute path) is D://SRDM2.3/srdm/svr//IdP/IdPserver/idp. But it was not working with relative path but is working with absolute path.
I got the following error while using relative path.

SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base D:\SDC-Builds\SRDM2.3.0.6904.10\SRDM\Svr\tomcat\webapps\..\IdP\IdPserver\idp 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:4324)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4493)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Best Solution

Do you think the actual:

D://SRDM2.3/srdm/svr//IdP/IdPserver/idp

is the same as the missing?

D:\SDC-Builds\SRDM2.3.0.6904.10\SRDM\Svr\tomcat\webapps\..\IdP\IdPserver\idp

Resolving the .. in the second one results in

D:\SDC-Builds\SRDM2.3.0.6904.10\SRDM\Svr\tomcat\IdP\IdPserver\idp

You sill need another .., so try this one:

<Context docBase="../../IdP/IdPserver/idp"
Related Question