[
https://issues.apache.org/jira/browse/FELIX-4589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14080652#comment-14080652
]
Victor Bashurov commented on FELIX-4589:
----------------------------------------
Creating a new project from scratch with identical architecture I realized that
your workaround works well, seems like something wrong with my actual project
where this workaround cannot be applied, I'll take a look, thank you.
However another strange behavior I found out trying to forward the query from
my servlet bundle to the main spring MVC application which also plays a role of
a servlet bridge.
My spring MVC application has the following web.xml
<servlet-mapping>
<servlet-name>dispatcher</servlet-name> // for spring DispatcherServlet
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>module</servlet-name> // for OSGI bridge ProxyServlet
<url-pattern>/module/*</url-pattern>
</servlet-mapping>
My OSGI bundle servlet is accessible via
http://localhost:8080/samplebridge/module/bforwards and I'd like to forward its
requests to the spring MVC application (there is a controller in spring MVC
that handles '/hi' and accessible independently via
http://localhost:8080/samplebridge/hi)
Code of OSGI servlet bunle below:
ServletContext sc = getServletContext();
sc = sc.getContext("/samplebridge");
RequestDispatcher rd = sc.getRequestDispatcher("/hi");
rd.forward(request, response);
Forwarding doesn't work, but replacing 'forward' with 'include' works fine
If you need the source code of this issue it here:
https://bitbucket.org/vbashur/diff/src (projects that start with 'sample*')
> Problem with forwarding from one servlet to another
> ---------------------------------------------------
>
> Key: FELIX-4589
> URL: https://issues.apache.org/jira/browse/FELIX-4589
> Project: Felix
> Issue Type: Bug
> Components: HTTP Service
> Affects Versions: http-2.3.0
> Reporter: Victor Bashurov
>
> Like in an issue FELIX-2774
> (https://issues.apache.org/jira/browse/FELIX-2774) I'd like to have a several
> servlet bunles installed with embedded OSGI framework. I'm using servlet
> bridge for request's management between sevlets bundles. In order to pass the
> information between servlets I want to use request dispatcher to forward (or
> include) http queries from one servlet to another.
> Even when I have two servlets registered in one bundle I cannot make a
> forwarding from one servlet to another.
> ServiceTracker
> httpService.registerServlet(TestServlet.SERVLET_ALIAS, new
> TestServlet("Test servlet"), null, null);
> httpService.registerServlet(ForwardServlet.SERVLET_ALIAS, new
> ForwardServlet("Forward servlet"), null, null);
> Trying to do the following in a TestServlet doGet method will cause error:
> RequestDispatcher rd =
> getServletContext().getRequestDispatcher(ForwardServlet.SERVLET_ALIAS);
> rd.forward(req, res);
> For org.apache.felix.http.bridge-2.0.2.jar error will be NullPointerException
> on 'rd' variable, for version 2.2.0 the same, but for version 2.3.0 it's
> going to be endless loop and stackoverflow error.
> More code about the problem here: https://bitbucket.org/vbashur/diff/src
> (servletbundle project)
--
This message was sent by Atlassian JIRA
(v6.2#6252)