https://issues.apache.org/bugzilla/show_bug.cgi?id=57155

            Bug ID: 57155
           Summary: Allow Context without real docbase in embedded Tomcat
           Product: Tomcat 8
           Version: trunk
          Hardware: PC
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: knst.koli...@gmail.com

Many of Tomcat test cases do the following to create and configure a web
application programmatically:

        // Must have a real docBase - just use temp
        Context ctx =
            tomcat.addContext("", System.getProperty("java.io.tmpdir"));

Essentially, it makes Tomcat to serve the contents of the system temporary
directory. Sometimes it results in failures on CI servers (bug 57154 is an
example).

There shall be a way to configure a context that does not need a real docbase.

I do not see a use case for that when running a standalone Tomcat, because
docbase is needed to provide executable code for the application, but I do see
the use case when running embedded Tomcat. In embedded Tomcat the entire web
application can be configured programmatically.


If I use a non-existent docbase, e.g.

        Context ctx = 
            tomcat.addContext("", "ROOT");

Tomcat startup fails with

[[[
Caused by: org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component
[org.apache.catalina.webresources.StandardRoot@123f26]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at
org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4875)
    at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5004)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: java.lang.IllegalArgumentException: The main resource set specified
[(censored)\test-tmp\webapps\ROOT] is not valid
    at
org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:665)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more
]]]


If I do the following:

        Context ctx =
            tomcat.addContext("", "");

the test passes successfully. Apparently it is using docBase = appBase. An odd
configuration, but it works if there are no other web applications in appBase.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to