karaf 4.2.6 httpwhiteboard service not deploy servlet context

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

karaf 4.2.6 httpwhiteboard service not deploy servlet context

ntle
Hello,

I'm using karaf 4.2.6 to host a simple web bundle, the bundle is installed,
ServletContextHelper, resource service started but i cannot access any
resource, the web console show my servlet deployed to the wrong context.
Here is the output from the karaf console:

karaf@root()> bundle:list -t 0 -s | grep home
133 | Active   |  80 | 1.0.0.201906212128      |
com.castortech.iris.ba.web.home
karaf@root()> bundle:services 133

Home (133) provides:
--------------------
[com.castortech.iris.ba.web.home.IconsResourceService]
[com.castortech.iris.ba.web.home.IndexPageResourceService]
[org.osgi.service.http.context.ServletContextHelper]
[javax.servlet.ServletContext]
karaf@root()> service:list
org.osgi.service.http.context.ServletContextHelper
[org.osgi.service.http.context.ServletContextHelper]
----------------------------------------------------
 service.id = 226
 osgi.http.whiteboard.context.name = HomeServletContextHelper
 service.bundleid = 133
 service.scope = bundle
 component.name = com.castortech.iris.ba.web.home.HomeServletContextHelper
 osgi.http.whiteboard.context.path = /home
 component.id = 4
Provided by :
 Home (133)
Used by:
 OPS4J Pax Web - Extender - Whiteboard (88)

karaf@root()> service:list
com.castortech.iris.ba.web.home.IconsResourceService
[com.castortech.iris.ba.web.home.IconsResourceService]
------------------------------------------------------
 service.id = 224
 service.bundleid = 133
 service.scope = bundle
 osgi.http.whiteboard.context.select =
(osgi.http.whiteboard.context.name=HomeServletContextHelper)
 osgi.http.whiteboard.resource.pattern = /icons/*
 osgi.http.whiteboard.resource.prefix = /icons
 component.name = com.castortech.iris.ba.web.home.IconsResourceService
 component.id = 2
Provided by :
 Home (133)
Used by:
 OPS4J Pax Web - Extender - Whiteboard (88)

As you can see, the servlet context should be /home and the icon resource
service should be /home/icons/* but on the web console:

<http://karaf.922171.n3.nabble.com/file/t498183/webconsole.png>

I got no error from karaf log. Can someone advise what i am missing?

Thai



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: karaf 4.2.6 httpwhiteboard service not deploy servlet context

jbonofre
Hi,

Same context when you do http:list ?

Regards
JB

On 21/06/2019 23:49, ntle wrote:

> Hello,
>
> I'm using karaf 4.2.6 to host a simple web bundle, the bundle is installed,
> ServletContextHelper, resource service started but i cannot access any
> resource, the web console show my servlet deployed to the wrong context.
> Here is the output from the karaf console:
>
> karaf@root()> bundle:list -t 0 -s | grep home
> 133 | Active   |  80 | 1.0.0.201906212128      |
> com.castortech.iris.ba.web.home
> karaf@root()> bundle:services 133
>
> Home (133) provides:
> --------------------
> [com.castortech.iris.ba.web.home.IconsResourceService]
> [com.castortech.iris.ba.web.home.IndexPageResourceService]
> [org.osgi.service.http.context.ServletContextHelper]
> [javax.servlet.ServletContext]
> karaf@root()> service:list
> org.osgi.service.http.context.ServletContextHelper
> [org.osgi.service.http.context.ServletContextHelper]
> ----------------------------------------------------
>  service.id = 226
>  osgi.http.whiteboard.context.name = HomeServletContextHelper
>  service.bundleid = 133
>  service.scope = bundle
>  component.name = com.castortech.iris.ba.web.home.HomeServletContextHelper
>  osgi.http.whiteboard.context.path = /home
>  component.id = 4
> Provided by :
>  Home (133)
> Used by:
>  OPS4J Pax Web - Extender - Whiteboard (88)
>
> karaf@root()> service:list
> com.castortech.iris.ba.web.home.IconsResourceService
> [com.castortech.iris.ba.web.home.IconsResourceService]
> ------------------------------------------------------
>  service.id = 224
>  service.bundleid = 133
>  service.scope = bundle
>  osgi.http.whiteboard.context.select =
> (osgi.http.whiteboard.context.name=HomeServletContextHelper)
>  osgi.http.whiteboard.resource.pattern = /icons/*
>  osgi.http.whiteboard.resource.prefix = /icons
>  component.name = com.castortech.iris.ba.web.home.IconsResourceService
>  component.id = 2
> Provided by :
>  Home (133)
> Used by:
>  OPS4J Pax Web - Extender - Whiteboard (88)
>
> As you can see, the servlet context should be /home and the icon resource
> service should be /home/icons/* but on the web console:
>
> <http://karaf.922171.n3.nabble.com/file/t498183/webconsole.png>
>
> I got no error from karaf log. Can someone advise what i am missing?
>
> Thai
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: karaf 4.2.6 httpwhiteboard service not deploy servlet context

jbonofre
In reply to this post by ntle
By the way, I think you can workaround adding alias service property.

Regards
JB

On 21/06/2019 23:49, ntle wrote:

> Hello,
>
> I'm using karaf 4.2.6 to host a simple web bundle, the bundle is installed,
> ServletContextHelper, resource service started but i cannot access any
> resource, the web console show my servlet deployed to the wrong context.
> Here is the output from the karaf console:
>
> karaf@root()> bundle:list -t 0 -s | grep home
> 133 | Active   |  80 | 1.0.0.201906212128      |
> com.castortech.iris.ba.web.home
> karaf@root()> bundle:services 133
>
> Home (133) provides:
> --------------------
> [com.castortech.iris.ba.web.home.IconsResourceService]
> [com.castortech.iris.ba.web.home.IndexPageResourceService]
> [org.osgi.service.http.context.ServletContextHelper]
> [javax.servlet.ServletContext]
> karaf@root()> service:list
> org.osgi.service.http.context.ServletContextHelper
> [org.osgi.service.http.context.ServletContextHelper]
> ----------------------------------------------------
>  service.id = 226
>  osgi.http.whiteboard.context.name = HomeServletContextHelper
>  service.bundleid = 133
>  service.scope = bundle
>  component.name = com.castortech.iris.ba.web.home.HomeServletContextHelper
>  osgi.http.whiteboard.context.path = /home
>  component.id = 4
> Provided by :
>  Home (133)
> Used by:
>  OPS4J Pax Web - Extender - Whiteboard (88)
>
> karaf@root()> service:list
> com.castortech.iris.ba.web.home.IconsResourceService
> [com.castortech.iris.ba.web.home.IconsResourceService]
> ------------------------------------------------------
>  service.id = 224
>  service.bundleid = 133
>  service.scope = bundle
>  osgi.http.whiteboard.context.select =
> (osgi.http.whiteboard.context.name=HomeServletContextHelper)
>  osgi.http.whiteboard.resource.pattern = /icons/*
>  osgi.http.whiteboard.resource.prefix = /icons
>  component.name = com.castortech.iris.ba.web.home.IconsResourceService
>  component.id = 2
> Provided by :
>  Home (133)
> Used by:
>  OPS4J Pax Web - Extender - Whiteboard (88)
>
> As you can see, the servlet context should be /home and the icon resource
> service should be /home/icons/* but on the web console:
>
> <http://karaf.922171.n3.nabble.com/file/t498183/webconsole.png>
>
> I got no error from karaf log. Can someone advise what i am missing?
>
> Thai
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: karaf 4.2.6 httpwhiteboard service not deploy servlet context

ntle
In reply to this post by jbonofre
Hi JB,

The same context is listed with http:list

karaf@root()> http:list
ID  | Servlet          | Servlet-Name             | State       | Alias              
| Url
----+------------------+--------------------------+-------------+---------------------+------------------------
100 | ResourceServlet  | /system/console/res:/res | Deployed    |
/system/console/res | [/system/console/res/*]
100 | KarafOsgiManager | ServletModel-8           | Deployed    |
/system/console     | [/system/console/*]
133 | ResourceServlet  | html                     | Deployed    | /                  
| [/]
133 | ResourceServlet  | /icons/*:/icons          | Deployed    | /icons/*          
| [/icons/*]



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: karaf 4.2.6 httpwhiteboard service not deploy servlet context

jbonofre
OK, it's maybe an issue specific to servlet context.

I will add a itest in Karaf.

We already have itests covering servlet whiteboard, but not directly
servlet context.

Regards
JB

On 25/06/2019 15:37, ntle wrote:

> Hi JB,
>
> The same context is listed with http:list
>
> karaf@root()> http:list
> ID  | Servlet          | Servlet-Name             | State       | Alias              
> | Url
> ----+------------------+--------------------------+-------------+---------------------+------------------------
> 100 | ResourceServlet  | /system/console/res:/res | Deployed    |
> /system/console/res | [/system/console/res/*]
> 100 | KarafOsgiManager | ServletModel-8           | Deployed    |
> /system/console     | [/system/console/*]
> 133 | ResourceServlet  | html                     | Deployed    | /                  
> | [/]
> 133 | ResourceServlet  | /icons/*:/icons          | Deployed    | /icons/*          
> | [/icons/*]
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: karaf 4.2.6 httpwhiteboard service not deploy servlet context

ntle
In reply to this post by jbonofre
Thank you JB,

I don't see any alias property in http whiteboard spec. can i just add like
below:

@Component(service = IconsResourceService.class,
        enabled=true,
        property = {
                "alias=/home/icons/*", <----is this correct?
                "osgi.http.whiteboard.resource.pattern=/icons/*",
                "osgi.http.whiteboard.resource.prefix=/icons",
       
"osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name=HomeServletContextHelper)"
        }
)



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: karaf 4.2.6 httpwhiteboard service not deploy servlet context

jbonofre
Yes, alias is pax-web specific.

It's just to try.

Regards
JB

On 25/06/2019 15:56, ntle wrote:

> Thank you JB,
>
> I don't see any alias property in http whiteboard spec. can i just add like
> below:
>
> @Component(service = IconsResourceService.class,
> enabled=true,
> property = {
> "alias=/home/icons/*", <----is this correct?
> "osgi.http.whiteboard.resource.pattern=/icons/*",
> "osgi.http.whiteboard.resource.prefix=/icons",
>
> "osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name=HomeServletContextHelper)"
> }
> )
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: karaf 4.2.6 httpwhiteboard service not deploy servlet context

ntle
Hi JB,

I tried adding alias and also a servlet and i can see the servletContext
(/home) registered with paxweb but webconsole still not show any change. I
am still getting 404 accessing my servlet and resources. To eliminate
possibility of context path conflict, i only install pax-http-whiteboard and
my bundle
Here are what console show:

karaf@root()> feature:install *pax-http-whiteboard*
karaf@root()> kar:install --no-start
file:./../irisba/com.castortech.iris.vision.tycho/target/irisba.kar
karaf@root()> bundle:list -t 0 -s | grep home
95 | Active   |  80 | 1.0.0.201906251633      |
com.castortech.iris.ba.web.home
karaf@root()> bundle:services 95

Home (95) provides:
-------------------
[com.castortech.iris.ba.web.home.IconsResourceService]
[com.castortech.iris.ba.web.home.IndexPageResourceService]
[org.osgi.service.http.context.ServletContextHelper]
[*javax.servlet.ServletContext*]
[javax.servlet.Servlet]
karaf@root()> service:list javax.servlet.ServletContext
[javax.servlet.ServletContext]
------------------------------
 osgi.web.version = 1.0.0.201906251633
 osgi.web.contextpath = */home*   <---correct context path
 service.id = 138
 osgi.web.symbolicname = com.castortech.iris.ba.web.home
 service.bundleid = 95
 service.scope = singleton
 osgi.web.contextname = *HomeServletContextHelper*
Provided by :
 Home (95)
Used by:
 OPS4J Pax Web - Runtime (91)

karaf@root()> service:list javax.servlet.Servlet
[javax.servlet.Servlet]
-----------------------
 service.id = 139
 service.bundleid = 95
 service.scope = prototype
 osgi.http.whiteboard.servlet.pattern = /hello
 osgi.http.whiteboard.context.select =
(osgi.http.whiteboard.context.name=*HomeServletContextHelper*)
 component.name = com.castortech.iris.ba.web.home.HelloServlet
 component.id = 5
Provided by :
 Home (95)
Used by:
 OPS4J Pax Web - Extender - Whiteboard (88)

karaf@root()> service:list
com.castortech.iris.ba.web.home.IndexPageResourceService
[com.castortech.iris.ba.web.home.IndexPageResourceService]
----------------------------------------------------------
 *alias = /home*
 service.id = 136
 service.bundleid = 95
 service.scope = prototype
 osgi.http.whiteboard.context.select =
(osgi.http.whiteboard.context.name=*HomeServletContextHelper*)
 osgi.http.whiteboard.resource.pattern = /
 osgi.http.whiteboard.resource.prefix = /index.html
 component.name = com.castortech.iris.ba.web.home.IndexPageResourceService
 component.id = 3
Provided by :
 Home (95)
Used by:
 OPS4J Pax Web - Extender - Whiteboard (88)

karaf@root()> service:list
com.castortech.iris.ba.web.home.IndexPageResourceService
[com.castortech.iris.ba.web.home.IndexPageResourceService]
----------------------------------------------------------
 *alias = /home*
 service.id = 136
 service.bundleid = 95
 service.scope = prototype
 osgi.http.whiteboard.context.select =
(osgi.http.whiteboard.context.name=*HomeServletContextHelper*)
 osgi.http.whiteboard.resource.pattern = /
 osgi.http.whiteboard.resource.prefix = /index.html
 component.name = com.castortech.iris.ba.web.home.IndexPageResourceService
 component.id = 3
Provided by :
 Home (95)
Used by:
 OPS4J Pax Web - Extender - Whiteboard (88)


Surprisingly, accessing /home/hello does return the expected test result
from my servlet but /home/icons/myicon.png or /home/ still return 404. Do
you have other suggestion ?




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: karaf 4.2.6 httpwhiteboard service not deploy servlet context

ntle
I hooked eclipse to karaf debug session and found that the resource is not
found by the bundle.getEntry(name). The resource name passed to
getResource(name) is /index.html/ instead of index.html.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html