You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Adam Ryan <ad...@gmail.com> on 2015/03/05 00:53:38 UTC

Erroneous duplicate servlet mapping exception (IllegalArgumentException)

Hi,

I had my tomcat webapp running fine (using Tomcat 8.0.9) in Eclipse Luna,
and I decided to have a play around with the build path. After changing a
few things and then changing everything back to its previous state, I am
now getting an IllegalArgumentException:

"The servlets named [api.rest.BaseServlet] and [src.api.rest.BaseServlet]
are both mapped to the url-pattern [/BaseServlet] which is not permitted"

I understand what the exception is telling me, but I only have one class
named BaseServlet, which is in the api.rest package. I have no idea why
"src" is being prepended to my package name in the second instance above.
Whatever the reason is, it is causing my Tomcat server to not start up.

I have defined the BaseServlet class in my web.xml file as follows:

    <servlet>
        <servlet-name>BaseServlet</servlet-name>
        <servlet-class>api.rest.BaseServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>BaseServlet</servlet-name>
        <url-pattern>/BaseServlet</url-pattern>
    </servlet-mapping>

But as I said, this used to work until today. I must have not changed
something back to its original state in my build path, but I can't figure
out what. I'm hoping I don't have to recreate my project and tomcat server
just to make this work.

Any help is appreciated.

Thanks,
Adam

Re: Erroneous duplicate servlet mapping exception (IllegalArgumentException)

Posted by Violeta Georgieva <mi...@gmail.com>.
Hi,

2015-03-05 1:53 GMT+02:00 Adam Ryan <ad...@gmail.com>:
>
> Hi,
>
> I had my tomcat webapp running fine (using Tomcat 8.0.9) in Eclipse Luna,
> and I decided to have a play around with the build path. After changing a
> few things and then changing everything back to its previous state, I am
> now getting an IllegalArgumentException:
>
> "The servlets named [api.rest.BaseServlet] and [src.api.rest.BaseServlet]
> are both mapped to the url-pattern [/BaseServlet] which is not permitted"
>
> I understand what the exception is telling me, but I only have one class
> named BaseServlet, which is in the api.rest package. I have no idea why
> "src" is being prepended to my package name in the second instance above.
> Whatever the reason is, it is causing my Tomcat server to not start up.
>
> I have defined the BaseServlet class in my web.xml file as follows:
>
>     <servlet>
>         <servlet-name>BaseServlet</servlet-name>
>         <servlet-class>api.rest.BaseServlet</servlet-class>
>     </servlet>
>
>     <servlet-mapping>
>         <servlet-name>BaseServlet</servlet-name>
>         <url-pattern>/BaseServlet</url-pattern>
>     </servlet-mapping>
>
> But as I said, this used to work until today. I must have not changed
> something back to its original state in my build path, but I can't figure
> out what. I'm hoping I don't have to recreate my project and tomcat server
> just to make this work.
>
> Any help is appreciated.

You said you changed the build path.
Did you change the sources location?
Did you change the package name?
Do you have WebServlet annotation defined for your servlet?
Check the classes that you are deploying.

Regards,
Violeta

> Thanks,
> Adam