Carlota
Carlota

Reputation: 1237

Apache tomcat how to create a link to a url

I have the following default-ssl.conf

ProxyPass /comunes/ http://mapapre.mapa.es/comunes/

In DES environment.

Now I want to create it in my local Apache tomcat.

I modified the file server.xml.

I added

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

        <Context docBase="/comunes/" path="http://mapapre.mapa.es/comunes/" />

      </Host>

When I stat the server, I get a error

Caused by: java.lang.IllegalArgumentException: The main resource set specified [D:\apache-tomcat-9.0.27\webapps\comunes] is not valid
        at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:752)
        at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:709)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

How have I create this link in my local apache?

Upvotes: 1

Views: 1168

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48057

If you read the Context documentation you'll find that you have a fundamental misunderstanding of the path and docBase attributes that you use.

docBase

The Document Base (also known as the Context Root) directory for this web application, or the pathname to the web application archive file (if this web application is being executed directly from the WAR file). You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory of the owning Host.

The value of this field must not be set unless the Context element is defined in server.xml or the docBase is not located under the Host's appBase.

If a symbolic link is used for docBase then changes to the symbolic link will only be effective after a Tomcat restart or by undeploying and redeploying the context. A context reload is not sufficient.

and

path

The context path of this web application, which is matched against the beginning of each request URI to select the appropriate web application for processing. All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are defining the default web application for this Host, which will process all requests not assigned to other Contexts.

This attribute must only be used when statically defining a Context in server.xml. In all other circumstances, the path will be inferred from the filenames used for either the .xml context file or the docBase.

Even when statically defining a Context in server.xml, this attribute must not be set unless either the docBase is not located under the Host's appBase or both deployOnStartup and autoDeploy are false. If this rule is not followed, double deployment is likely to result.

Apart from that, you probably only need to deploy your webapplication in tomcat's webapps/ directory with the name comunes.war (or in the directory webapps/comunes), without any static configuration in server.xml.

Upvotes: 1

Related Questions