Question

I am trying to deploy a web service in Tomcat7 using maven.

Below I provide some configuration info:

web.xml

...
<servlet-mapping>
   <servlet-name>CXFServlet</servlet-name>
   <url-pattern>/services/*</url-pattern>
</servlet-mapping>
...

pom.xml

...
<build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <server>TomcatServer</server>
                    <path>/services/userinfo</path>
...

Given the <url-pattern>/services/*</url-pattern> and <path>/services/userinfo</path> configuration, the URL http://localhost:8080/services/userinfo shows 404.

If using instead <url-pattern>/*</url-pattern> everything works as expected (i.e. http://localhost:8080/services/userinfo shows the list of available methods).

The question:

Why /services/* doesn't work in my case?

Was it helpful?

Solution

The path in your tomcat-maven-plugin configuration

<path>/services/userinfo</path>

defines where you are deploying the webapp (the context root). In this case, you are deploying it to

http://localhost:8080/services/userinfo

Check out the webapps directory in your Tomcat installation.

Since you are defining the CXFServlet mapping as /services/*, the CXF service list would show at

http://localhost:8080/services/userinfo/services/

When you re-defined the mapping to /*, it just appeared to work as expected, but that was only because the context root you used and the service listing path you expected were the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top