Hello

The error is correct - you didn't specify the patterns for error servlets,
thus "/errorServlet" was assumed.

You have two options:

1. add @javax.servlet.annotation.WebServlet annotation and use "value" or
"urlPatterns" params of this annotation - these will be used instead of
"/errorServlet"
2. use "alias" or "urlPatterns" service properties on @Component annotation

I hope this helps.
regards
Grzegorz Grzybek

wt., 6 sie 2019 o 19:28 Nhut Thai Le <[email protected]> napisaƂ(a):

> Hello,
>
> I have a few error page servlets to handle 403, 404 and 500 errors. They
> are annotated according to osgi cmpn R6  as  follow:
> @Component(
> service = Servlet.class,
> enabled=true,
> property = {
> "osgi.http.whiteboard.servlet.errorPage=403",
> "osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name
> =WebviewerServletContextHelper)"
> },
> scope = ServiceScope.PROTOTYPE
> )
> public final class Error403Servlet extends HttpServlet {...}
>
> @Component(
> service = Servlet.class,
> enabled=true,
> property = {
> "osgi.http.whiteboard.servlet.errorPage=404",
> "osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name
> =WebviewerServletContextHelper)"
> },
> scope = ServiceScope.PROTOTYPE
> )
> public final class Error404Servlet extends HttpServlet {..}
>
> @Component(
> service = Servlet.class,
> enabled=true,
> property = {
> "osgi.http.whiteboard.servlet.errorPage=500",
> "osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name
> =WebviewerServletContextHelper)"
> },
> scope = ServiceScope.PROTOTYPE
> )
> public final class Error500Servlet extends HttpServlet {..}
>
> When i start the server, i got this error:
> 13:13:53.716 [paxweb-config-1-thread-1] ERROR o.o.p.w.e.w.i.WebApplication
> - Registration skipped for
> [ServletWebElement{mapping=DefaultServletMapping{httpContextId=WebviewerServletContextHelper,urlPatterns=null,initParams={},servlet=com.castortech.iris.ba.webviewer.internal.Error500Servlet@1399c32a,
> alias=/errorServlet, servletNameError500Servlet}}] due to error during
> registration
> org.osgi.service.http.NamespaceException: alias: '/errorServlet' is
> already in use in this or another context
> at
> org.ops4j.pax.web.service.spi.model.ServerModel.addServletModel(ServerModel.java:124)
> at
> org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:243)
> at
> org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:223)
> at
> org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:207)
> at
> org.ops4j.pax.web.service.internal.HttpServiceProxy.registerServlet(HttpServiceProxy.java:69)
> at
> org.ops4j.pax.web.extender.whiteboard.internal.element.ServletWebElement.register(ServletWebElement.java:88)
> Tracing the code to the ServletWebElement.register(), i see that all my
> error page servlets above have the same alias (/errorServlet) which cause
> pax.web to throw exception and skip registration when it encounter the 2nd
> error page servlet. Is this a known bug and how do I get around this?
> I am using pax-web-extender-whiteboard 7.2.4
>
> Thai Le
>
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - [email protected]
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ops4j/b5bf8863-4c95-4471-a46d-5ed004c2491f%40googlegroups.com
> <https://groups.google.com/d/msgid/ops4j/b5bf8863-4c95-4471-a46d-5ed004c2491f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/CAAdXmhpBzVV6VGYAqP8rtZ8%3DkVL%3DfAuB%3DNtQbsyX-1uwcMBo6g%40mail.gmail.com.

Reply via email to