You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Grzegorz Grzybek <gr...@gmail.com> on 2022/11/14 14:05:17 UTC
Re: Unable to create default RequestDispatcher
Hello
There were a lot of changes in Pax Web 8 and in previous versions,
getNamedDispatch() was simply delegated to underlying web server. Now the
servlet context is always OSGi-specific and there indeed may be something
missing.
I've created https://github.com/ops4j/org.ops4j.pax.web/issues/1794 to
track this problem - please give me ~1 day to find the reason of the
problem.
kind regards
Grzegorz Grzybek
pon., 14 lis 2022 o 14:56 Prashanth Ettaboina
<Pr...@motivitylabs.com.invalid> napisał(a):
> Hi Team,
>
> I have updated my KARAF version from 4.2.15 to 4.4.1 and Java from 8 to 11
> in my application.
> Gone through the official Release notes and updated some dependencies as
> well.
>
> Upgraded OSGI-Core from 6.0.0 to 8.0.0.
> Upgraded osgi.compendium 5.0.0 to osgi.cmpn 7.0.0
> Upgraded Jetty from 9.4.43.v20210629 to 9.4.46.v20220331.
> Upgraded pax-web-spi from 4.3.4 to 7.2.11.
> I'm using javax.servlet-api 3.1.0 version in my application.
>
> I'm unable to create default RequestDispatcher.
> Please check the below code lines.
>
> public class ExampleServlet extends HttpServlet {
> protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> RequestDispatcher requestDispatcher =
> getServletContext().getNamedDispatcher("default"); // get
> getServletContext() is calling the method in GenericServlet.
> requestDispatcher.include(request, response);
> }
> }
>
> the above code used to work fine before the version upgrades but now I'm
> getting the requestDispatcher as null.
>
> Can anyone please look at it, let me know if I'm missing something.
>
> Thanks,
> Prashanth Ettaboina
>
>
>
>
Re: Unable to create default RequestDispatcher
Posted by Grzegorz Grzybek <gr...@gmail.com>.
Prashanth - just one thing - what's the method you're using to register
ExampleServlet?
Because according to HttpService and Whiteboard specifications, there's no
"default" servlet registered.
See - in Karaf 4.4.2, I've installed hawtio application
(mvn:io.hawt/hawtio-osgi/2.15.0/war) and this "showcase" bundle from Pax
Web:
karaf@root()> install mvn:org.ops4j.pax.web.samples/showcase/8.0.11
Bundle ID: 79
karaf@root()> start 79
karaf@root()> sample:whiteboard servlet s1 /s1/*
>> Using context for bundle org.ops4j.pax.web.samples.showcase [79]
>> Registering a servlet with "s1" name, "/s1/*" pattern, "(
osgi.http.whiteboard.context.name=default)" context selector and for
org.ops4j.pax.web.samples.showcase [79].
>>>> Registered successfully. You can test it using `curl -i
http://127.0.0.1:8181/s1/anything`
karaf@root()> web:servlet-list
Bundle ID │ Name │ Class
│ Context Path(s) │ URLs │ Type │ Context
Filter
──────────┼───────────────┼───────────────────────────────────────────────────────────────────┼─────────────────┼──────────────┼────────────┼────────────────────────────────────────────
75 │ default │
org.ops4j.pax.web.service.jetty.internal.web.JettyResourceServlet │ /hawtio
│ / │ WAB │ -
75 │ jolokia-agent │
io.hawt.web.servlets.JolokiaConfiguredAgentServlet │ /hawtio
│ /jolokia/* │ WAB │ -
75 │ jolokia-proxy │ io.hawt.web.proxy.ProxyServlet
│ /hawtio │ /proxy/* │ WAB │ -
75 │ keycloak │ io.hawt.web.auth.keycloak.KeycloakServlet
│ /hawtio │ /keycloak/* │ WAB │ -
75 │ login │ io.hawt.web.auth.LoginServlet
│ /hawtio │ /auth/login │ WAB │ -
75 │ logout │ io.hawt.web.auth.LogoutServlet
│ /hawtio │ /auth/logout │ WAB │ -
75 │ plugin │ io.hawt.web.plugin.PluginServlet
│ /hawtio │ /plugin/* │ WAB │ -
75 │ user │ io.hawt.web.auth.keycloak.KeycloakUserServlet
│ /hawtio │ /user/* │ WAB │ -
79 │ s1 │
org.ops4j.pax.web.samples.config.commands.web.TestServlet │ /
│ /s1/* │ Whiteboard │ (osgi.http.whiteboard.context.name
=default)
And there's no "defaul" servlet in "/" context.
"default" servlet is installed by default only for WAB scenarios (WAR).
regards
Grzegorz Grzybek
pon., 14 lis 2022 o 15:05 Grzegorz Grzybek <gr...@gmail.com>
napisał(a):
> Hello
>
> There were a lot of changes in Pax Web 8 and in previous versions,
> getNamedDispatch() was simply delegated to underlying web server. Now the
> servlet context is always OSGi-specific and there indeed may be something
> missing.
>
> I've created https://github.com/ops4j/org.ops4j.pax.web/issues/1794 to
> track this problem - please give me ~1 day to find the reason of the
> problem.
>
> kind regards
> Grzegorz Grzybek
>
> pon., 14 lis 2022 o 14:56 Prashanth Ettaboina
> <Pr...@motivitylabs.com.invalid> napisał(a):
>
>> Hi Team,
>>
>> I have updated my KARAF version from 4.2.15 to 4.4.1 and Java from 8 to
>> 11 in my application.
>> Gone through the official Release notes and updated some dependencies as
>> well.
>>
>> Upgraded OSGI-Core from 6.0.0 to 8.0.0.
>> Upgraded osgi.compendium 5.0.0 to osgi.cmpn 7.0.0
>> Upgraded Jetty from 9.4.43.v20210629 to 9.4.46.v20220331.
>> Upgraded pax-web-spi from 4.3.4 to 7.2.11.
>> I'm using javax.servlet-api 3.1.0 version in my application.
>>
>> I'm unable to create default RequestDispatcher.
>> Please check the below code lines.
>>
>> public class ExampleServlet extends HttpServlet {
>> protected void doGet(HttpServletRequest request,
>> HttpServletResponse response) throws ServletException, IOException {
>> RequestDispatcher requestDispatcher =
>> getServletContext().getNamedDispatcher("default"); // get
>> getServletContext() is calling the method in GenericServlet.
>> requestDispatcher.include(request, response);
>> }
>> }
>>
>> the above code used to work fine before the version upgrades but now I'm
>> getting the requestDispatcher as null.
>>
>> Can anyone please look at it, let me know if I'm missing something.
>>
>> Thanks,
>> Prashanth Ettaboina
>>
>>
>>
>>
Re: Unable to create default RequestDispatcher
Posted by Grzegorz Grzybek <gr...@gmail.com>.
Prashanth - just one thing - what's the method you're using to register
ExampleServlet?
Because according to HttpService and Whiteboard specifications, there's no
"default" servlet registered.
See - in Karaf 4.4.2, I've installed hawtio application
(mvn:io.hawt/hawtio-osgi/2.15.0/war) and this "showcase" bundle from Pax
Web:
karaf@root()> install mvn:org.ops4j.pax.web.samples/showcase/8.0.11
Bundle ID: 79
karaf@root()> start 79
karaf@root()> sample:whiteboard servlet s1 /s1/*
>> Using context for bundle org.ops4j.pax.web.samples.showcase [79]
>> Registering a servlet with "s1" name, "/s1/*" pattern, "(
osgi.http.whiteboard.context.name=default)" context selector and for
org.ops4j.pax.web.samples.showcase [79].
>>>> Registered successfully. You can test it using `curl -i
http://127.0.0.1:8181/s1/anything`
karaf@root()> web:servlet-list
Bundle ID │ Name │ Class
│ Context Path(s) │ URLs │ Type │ Context
Filter
──────────┼───────────────┼───────────────────────────────────────────────────────────────────┼─────────────────┼──────────────┼────────────┼────────────────────────────────────────────
75 │ default │
org.ops4j.pax.web.service.jetty.internal.web.JettyResourceServlet │ /hawtio
│ / │ WAB │ -
75 │ jolokia-agent │
io.hawt.web.servlets.JolokiaConfiguredAgentServlet │ /hawtio
│ /jolokia/* │ WAB │ -
75 │ jolokia-proxy │ io.hawt.web.proxy.ProxyServlet
│ /hawtio │ /proxy/* │ WAB │ -
75 │ keycloak │ io.hawt.web.auth.keycloak.KeycloakServlet
│ /hawtio │ /keycloak/* │ WAB │ -
75 │ login │ io.hawt.web.auth.LoginServlet
│ /hawtio │ /auth/login │ WAB │ -
75 │ logout │ io.hawt.web.auth.LogoutServlet
│ /hawtio │ /auth/logout │ WAB │ -
75 │ plugin │ io.hawt.web.plugin.PluginServlet
│ /hawtio │ /plugin/* │ WAB │ -
75 │ user │ io.hawt.web.auth.keycloak.KeycloakUserServlet
│ /hawtio │ /user/* │ WAB │ -
79 │ s1 │
org.ops4j.pax.web.samples.config.commands.web.TestServlet │ /
│ /s1/* │ Whiteboard │ (osgi.http.whiteboard.context.name
=default)
And there's no "defaul" servlet in "/" context.
"default" servlet is installed by default only for WAB scenarios (WAR).
regards
Grzegorz Grzybek
pon., 14 lis 2022 o 15:05 Grzegorz Grzybek <gr...@gmail.com>
napisał(a):
> Hello
>
> There were a lot of changes in Pax Web 8 and in previous versions,
> getNamedDispatch() was simply delegated to underlying web server. Now the
> servlet context is always OSGi-specific and there indeed may be something
> missing.
>
> I've created https://github.com/ops4j/org.ops4j.pax.web/issues/1794 to
> track this problem - please give me ~1 day to find the reason of the
> problem.
>
> kind regards
> Grzegorz Grzybek
>
> pon., 14 lis 2022 o 14:56 Prashanth Ettaboina
> <Pr...@motivitylabs.com.invalid> napisał(a):
>
>> Hi Team,
>>
>> I have updated my KARAF version from 4.2.15 to 4.4.1 and Java from 8 to
>> 11 in my application.
>> Gone through the official Release notes and updated some dependencies as
>> well.
>>
>> Upgraded OSGI-Core from 6.0.0 to 8.0.0.
>> Upgraded osgi.compendium 5.0.0 to osgi.cmpn 7.0.0
>> Upgraded Jetty from 9.4.43.v20210629 to 9.4.46.v20220331.
>> Upgraded pax-web-spi from 4.3.4 to 7.2.11.
>> I'm using javax.servlet-api 3.1.0 version in my application.
>>
>> I'm unable to create default RequestDispatcher.
>> Please check the below code lines.
>>
>> public class ExampleServlet extends HttpServlet {
>> protected void doGet(HttpServletRequest request,
>> HttpServletResponse response) throws ServletException, IOException {
>> RequestDispatcher requestDispatcher =
>> getServletContext().getNamedDispatcher("default"); // get
>> getServletContext() is calling the method in GenericServlet.
>> requestDispatcher.include(request, response);
>> }
>> }
>>
>> the above code used to work fine before the version upgrades but now I'm
>> getting the requestDispatcher as null.
>>
>> Can anyone please look at it, let me know if I'm missing something.
>>
>> Thanks,
>> Prashanth Ettaboina
>>
>>
>>
>>
Re: Unable to create default RequestDispatcher
Posted by Grzegorz Grzybek <gr...@gmail.com>.
Prashanth - just one thing - what's the method you're using to register
ExampleServlet?
Because according to HttpService and Whiteboard specifications, there's no
"default" servlet registered.
See - in Karaf 4.4.2, I've installed hawtio application
(mvn:io.hawt/hawtio-osgi/2.15.0/war) and this "showcase" bundle from Pax
Web:
karaf@root()> install mvn:org.ops4j.pax.web.samples/showcase/8.0.11
Bundle ID: 79
karaf@root()> start 79
karaf@root()> sample:whiteboard servlet s1 /s1/*
>> Using context for bundle org.ops4j.pax.web.samples.showcase [79]
>> Registering a servlet with "s1" name, "/s1/*" pattern, "(
osgi.http.whiteboard.context.name=default)" context selector and for
org.ops4j.pax.web.samples.showcase [79].
>>>> Registered successfully. You can test it using `curl -i
http://127.0.0.1:8181/s1/anything`
karaf@root()> web:servlet-list
Bundle ID │ Name │ Class
│ Context Path(s) │ URLs │ Type │ Context
Filter
──────────┼───────────────┼───────────────────────────────────────────────────────────────────┼─────────────────┼──────────────┼────────────┼────────────────────────────────────────────
75 │ default │
org.ops4j.pax.web.service.jetty.internal.web.JettyResourceServlet │ /hawtio
│ / │ WAB │ -
75 │ jolokia-agent │
io.hawt.web.servlets.JolokiaConfiguredAgentServlet │ /hawtio
│ /jolokia/* │ WAB │ -
75 │ jolokia-proxy │ io.hawt.web.proxy.ProxyServlet
│ /hawtio │ /proxy/* │ WAB │ -
75 │ keycloak │ io.hawt.web.auth.keycloak.KeycloakServlet
│ /hawtio │ /keycloak/* │ WAB │ -
75 │ login │ io.hawt.web.auth.LoginServlet
│ /hawtio │ /auth/login │ WAB │ -
75 │ logout │ io.hawt.web.auth.LogoutServlet
│ /hawtio │ /auth/logout │ WAB │ -
75 │ plugin │ io.hawt.web.plugin.PluginServlet
│ /hawtio │ /plugin/* │ WAB │ -
75 │ user │ io.hawt.web.auth.keycloak.KeycloakUserServlet
│ /hawtio │ /user/* │ WAB │ -
79 │ s1 │
org.ops4j.pax.web.samples.config.commands.web.TestServlet │ /
│ /s1/* │ Whiteboard │ (osgi.http.whiteboard.context.name
=default)
And there's no "defaul" servlet in "/" context.
"default" servlet is installed by default only for WAB scenarios (WAR).
regards
Grzegorz Grzybek
pon., 14 lis 2022 o 15:05 Grzegorz Grzybek <gr...@gmail.com>
napisał(a):
> Hello
>
> There were a lot of changes in Pax Web 8 and in previous versions,
> getNamedDispatch() was simply delegated to underlying web server. Now the
> servlet context is always OSGi-specific and there indeed may be something
> missing.
>
> I've created https://github.com/ops4j/org.ops4j.pax.web/issues/1794 to
> track this problem - please give me ~1 day to find the reason of the
> problem.
>
> kind regards
> Grzegorz Grzybek
>
> pon., 14 lis 2022 o 14:56 Prashanth Ettaboina
> <Pr...@motivitylabs.com.invalid> napisał(a):
>
>> Hi Team,
>>
>> I have updated my KARAF version from 4.2.15 to 4.4.1 and Java from 8 to
>> 11 in my application.
>> Gone through the official Release notes and updated some dependencies as
>> well.
>>
>> Upgraded OSGI-Core from 6.0.0 to 8.0.0.
>> Upgraded osgi.compendium 5.0.0 to osgi.cmpn 7.0.0
>> Upgraded Jetty from 9.4.43.v20210629 to 9.4.46.v20220331.
>> Upgraded pax-web-spi from 4.3.4 to 7.2.11.
>> I'm using javax.servlet-api 3.1.0 version in my application.
>>
>> I'm unable to create default RequestDispatcher.
>> Please check the below code lines.
>>
>> public class ExampleServlet extends HttpServlet {
>> protected void doGet(HttpServletRequest request,
>> HttpServletResponse response) throws ServletException, IOException {
>> RequestDispatcher requestDispatcher =
>> getServletContext().getNamedDispatcher("default"); // get
>> getServletContext() is calling the method in GenericServlet.
>> requestDispatcher.include(request, response);
>> }
>> }
>>
>> the above code used to work fine before the version upgrades but now I'm
>> getting the requestDispatcher as null.
>>
>> Can anyone please look at it, let me know if I'm missing something.
>>
>> Thanks,
>> Prashanth Ettaboina
>>
>>
>>
>>