To follow up, I also tried the approach outlined in the User Guide
4.7.2.3.2 JAX-RS application with a custom Application subclass.
I created a class which extends ResourceConfig. I did not place an
@ApplicationPath annotation on it. Instead in my web.xml I have the
following:
<servlet>
<servlet-name>com.foo.MyApplication</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>com.foo.MyApplication</servlet-name>
<url-pattern>/root1/*</url-pattern>
<url-pattern>/root2/*</url-pattern>
</servlet-mapping>
Deploying this however, results in an IllegalStateException:
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: java.lang.IllegalStateException:
Servlet with name com.foo.MyApplication does not have any servlet-class or
jsp-file configured. Please see server.log for more details.
This is with Glassfish 4.1 / servlet 3.0.
I noticed in the Jersey examples repo the servlet3-webapp example extends
Application. The User Guide says the class simply needs to extend
Application so extending ResourceConfig should be ok in this case shouldn't
it?
Thanks,
-Noah
On Tue, Feb 3, 2015 at 3:52 PM, NBW <emailnbw_at_gmail.com> wrote:
> In Jersey 1.x using servlet 2.5 I've been able to set up multiple
> application paths in the web.xml by having multiple <url-pattern> elements
> in the <servlet-mapping> for the Jersey 1.x ServletContainer servlet.
>
> I was looking at the approach of extending ResourceConfig in Servlet 3
> which includes annotating the class with @ApplicationPath and specifying
> the path as the value to the annotation. It seems that only accepts one
> path/path expression. If I wanted another one that was at a different root
> would I need to make a second class that also extended ResourceConfig?
> Would there be an issue if there was any package namespace overlap between
> the two?
>
> Thanks,
>
> -Noah
>