First, perhaps you had a typo in that your servlet was mapped to /devices when it should have been mapped to /sensor3 which would have made the url with the context at /devices, /devices/devices and not /devices/sensor3 ?
- Ray On Tue, Aug 16, 2016 at 7:42 AM, Daghan ACAY <daghana...@hotmail.com> wrote: > I think I found a solution. All I did was to change the > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH of the > DeviceContextHelper > to "=/" as follows. It also allow me to change the context name in servlet, > filter and the helper. I still appreciate if someone explain why context > path did not work for the DeviceContextHelper. So solution in DS as > follows for others to benefit: > > > ServletContextHelper Code (full code) > > @Component(service = ServletContextHelper.class, scope = > ServiceScope.BUNDLE, property = { > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + > "=your_context_name", > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH + "=/" }) > public class DeviceContextHelper extends ServletContextHelper { > @Override > public boolean handleSecurity(HttpServletRequest request, > HttpServletResponse response) throws IOException { > return true; > } > } > > > SERVLET CODE > @Component(service = Servlet.class, property = { > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=(" > + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "= > your_context_name)", > HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN + "=/devices" }) > public class DeviceRestProvider extends HttpServlet { > .... > > } > > > > FILTER CODE > > > @Component(property = { HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN > + "=/*", > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=(" > + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "= > your_context_name)" }) > public class DeviceFilter implements Filter { > ... > > } > > thanks in advance > > -Daghan > > > ------------------------------ > *From:* osgi-dev-boun...@mail.osgi.org <osgi-dev-boun...@mail.osgi.org> > on behalf of Daghan ACAY <daghana...@hotmail.com> > *Sent:* Tuesday, August 16, 2016 11:15 AM > *To:* osgi-dev@mail.osgi.org > *Subject:* [osgi-dev] Osgi Web Whiteboard specification > > > Dear all, > > > I am trying to use OSGi HTTP Whiteboard specifications to handle security > on Servlets using DS. I found this page http://felix.apache.org/ > documentation/subprojects/apache-felix-http-service.html and also this > example http://svn.apache.org/repos/asf/felix/trunk/http/ > samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/ > > > Here is how far I got using "default" context. (using another context > stops servlet from working, which I wish to get working ideally) > > > ServletContextHelper Code (full code) > > @Component(service = ServletContextHelper.class, scope = > ServiceScope.BUNDLE, property = { > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=default", > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH + "=/devices" }) > public class DeviceContextHelper extends ServletContextHelper { > @Override > public boolean handleSecurity(HttpServletRequest request, > HttpServletResponse response) throws IOException { > return true; > } > } > > > > SERVLET CODE > @Component(service = Servlet.class, property = { > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=(" > + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=default)", > HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN + "=/devices" }) > public class DeviceRestProvider extends HttpServlet { > .... > > } > > > > FILTER CODE > > > @Component(property = { HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN > + "=/*", > HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=(" > + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=default)" }) > public class DeviceFilter implements Filter { > ... > > } > > > With this code call to http://localhost:8080/devices/sensor3 > > > I receive the following > -------------- > HTTP ERROR: 404 > > Problem accessing /devices/sensor3. Reason: > > File devices/sensor3 could not be found > > ------------------------------ > *Powered by Jetty://* > > *--------------------* > > > *Can you let me know what I am doing wrong?* > > > *Cheers* > > *-Daghan* > > > > > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev > -- *Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile> (@rotty3000) Senior Software Architect *Liferay, Inc.* <http://www.liferay.com> (@Liferay) Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev