I am trying to utilize hst:sitemapitem to expose rest service. Also i want this sitemap not to be specific to a channel, hence i am trying to add it under hst:default/hst:sitemap as “restapi” also i am adding property “hst:namedpipeline” and set it to “JaxrsRestPlainPipeline” but “http://localhost:8080/site/restapi” is giving me 404. can you please guide how can i do it?
Hi,
In order to expose a rest service, you need to define a new mount under your hst:root mount as explained here [1]. You don’t need to define a new sitemap item.
All the JAX-RS resources defined in your project will be available to the sites/channels mapped to your hst:root mount.
Still, if i want to do the same using sitemapitem under hst:default and don’t use mount is it possible? The Idea is not make it specific to any domain(channel). I want to use it as used for webfiles and binaries.
Hi,
I don’t think using sitemap items to expose REST services is correct by design. Generally sitemaps and the related request-processing are designed to deliver webpages (and/or anything related, like resources).
Regarding the webfiles/binaries, those sitemap items are using a specific properties, hst:containerresource = true [1]. In this case the related request follow specific pipelines: not sure how they are related in this context.
You’re right. It has been possible and should be possible to configure a named pipeline in sitemap item level.
Back to your original question, I guess you set only restapi sitemap item, but I think you should add _any_ underneath as well. Otherwise, /site/restapi/a/b/c won’t match only with restapi.
What is the @Path annotation(s) in your Plain JAX-RS component? Is any operation matchable by a pathInfo such as /restapi/a/b/c?
Please note that you should include the sitemapitem path, /restapi, somehow either statically or regex way because the pathInfo under a sitemap item include the sitemap item path, unlike mount.
Thanks Woonsan. It worked now. I had @Path for my rest resource however this path didn’t had ‘restapi’ with it. I added it on your advice and it worked.