You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2022/08/29 17:17:20 UTC

Need web whiteboard debugging tips

Platform: java 11, karaf 4.4.1, OSGi 8

I have a small karaf web whiteboard demo application that used to work,
that doesn't work anymore
 https://github.com/steinarb/frontend-karaf-demo

I need some useful tips for debugging this demo application.

I can debug into karaf, is there a place I could set a breakpoint to see
what the requests look like and where they end up?

Are there console commands I could use?

I have used service:list but what I see there looks normal:
 https://gist.github.com/steinarb/d6458984374474aff558a461e7fe1d83

What happens, is the following:

When I request
 http://localhost:8181/frontend-karaf-demo
I get a 302 to http://localhost:8181/frontend-karaf-demo/

But for http://localhost:8181/frontend-karaf-demo/ I just get 404.

And the 404 says that it comes from the default servlet, does that means
that it doesn't match the web context of the demo application?

Here's the 404 HTTP request response body:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404 Not Found</h2>
<table>
<tr><th>URI:</th><td>/frontend-karaf-demo/</td></tr>
<tr><th>STATUS:</th><td>404</td></tr>
<tr><th>MESSAGE:</th><td>Not Found</td></tr>
<tr><th>SERVLET:</th><td>default</td></tr>
</table>

</body>
</html>

The web context is defined like this:
 https://github.com/steinarb/frontend-karaf-demo/blob/master/src/main/java/no/priv/bang/demos/frontendkarafdemo/FrontendDemoServletContextHelper.java#L8

The top servlet is defined like this
 https://github.com/steinarb/frontend-karaf-demo/blob/master/src/main/java/no/priv/bang/demos/frontendkarafdemo/ReactServlet.java#L16

Am I doing something obviously wrong here?

Thanks!


Re: Need web whiteboard debugging tips

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hello

Great that you've resolved the issue. Yes - servlet name is very important,
but it should default to FQCN of the servlet.
Pax Web 8 was indeed a major refactoring (to match OSGi R6+ Whiteboard
specification - especially wrt context handling).

There are quite a lot of actual whiteboard examples in
https://github.com/ops4j/org.ops4j.pax.web/tree/main/samples/samples-whiteboard
But also you can see more low-level tests showing different Whiteboard
quirks in
https://github.com/ops4j/org.ops4j.pax.web/tree/main/pax-web-itest/pax-web-itest-server/src/test/java/org/ops4j/pax/web/itest/server/whiteboard

Your HTTP 404 for http://localhost:8181/frontend-karaf-demo/ request is
related to lack of "welcome files" registered to the context. There's no
default here.

regards
Grzegorz Grzybek

pon., 29 sie 2022 o 19:44 Steinar Bang <sb...@dod.no> napisaƂ(a):

> >>>>> Steinar Bang <sb...@dod.no>:
>
> > The web context is defined like this:
> >
> https://github.com/steinarb/frontend-karaf-demo/blob/master/src/main/java/no/priv/bang/demos/frontendkarafdemo/FrontendDemoServletContextHelper.java#L8
>
> > The top servlet is defined like this
> >
> https://github.com/steinarb/frontend-karaf-demo/blob/master/src/main/java/no/priv/bang/demos/frontendkarafdemo/ReactServlet.java#L16
>
> > Am I doing something obviously wrong here?
>
> Looks like I need to have a
>  @HttpWhiteboardServletName("frontend-demo")
> annotation on the ReactServlet.
>
> I put it there and rebuilt the application and now it works.
>
>

Re: Need web whiteboard debugging tips

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> The web context is defined like this:
>  https://github.com/steinarb/frontend-karaf-demo/blob/master/src/main/java/no/priv/bang/demos/frontendkarafdemo/FrontendDemoServletContextHelper.java#L8

> The top servlet is defined like this
>  https://github.com/steinarb/frontend-karaf-demo/blob/master/src/main/java/no/priv/bang/demos/frontendkarafdemo/ReactServlet.java#L16

> Am I doing something obviously wrong here?

Looks like I need to have a
 @HttpWhiteboardServletName("frontend-demo")
annotation on the ReactServlet.

I put it there and rebuilt the application and now it works.