Serving resources from different bundles with HttpContextId defined [message #1719061] |
Mon, 04 January 2016 19:30 |
Sean Willis Messages: 1 Registered: January 2016 |
Junior Member |
|
|
I have run into this problem when trying to upgrade Equinox from Eclipse version 4.2.2 to 4.5.1. Some context into the change that has caused a problem for me can be seen here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=475268. Basically when using the default HttpContext for servlets, session attributes cannot be shared between each servlet. To get around this I have defined a HttpContext that is common among all of the servlets. After this I have encountered the following problem (https://bugs.eclipse.org/bugs/show_bug.cgi?id=475268#c10):
I have run into this issue as well. My application used to share session attributes without specifying an httpcontextId. I have tried Martin's workaround by specifying an httpcontextId for each servlet, filter and resource that is contributed in each bundle's plugin.xml. The app has servlets and resources contributed in a variety of bundles. I will show an example of two bundles, A and B:
BUNDLE A plugin.xml-
<extension
point="org.eclipse.equinox.http.registry.httpcontexts">
<httpcontext
id="com.example.sharedContext">
</httpcontext>
</extension>
<extension
point="org.eclipse.equinox.http.registry.servlets">
<servlet
httpcontextId="com.example.sharedContext "
alias="/example/servlet1"
class="com.example.servlet1">
</servlet>
</extension>
A filter for "/" will write an authentication token to the session attributes the first time it is reached. Subsequent times it will check for this token and send user to the login page if it is not there.
<extension
point="org.eclipse.equinox.http.registry.filters">
<filter
httpcontextId="com.example.sharedContext"
alias="/"
class="com.example.authFilter">
</filter>
</extension>
The problem is when we are making a resource contribution from another bundle:
BUNDLE B plugin.xml-
<extension
point="org.eclipse.equinox.http.registry.resources">
<resource
httpcontextId="com.example.sharedContext"
alias="/example.indexpage"
base-name="/res">
</resource>
</extension>
Bundle B folders that exist and intend to be served:
res/html
res/js
res/css
When trying to access "/example.indexpage/html/header.htm", there is a 404 error. Is this resource contribution trying serving files from "Bundle A" that don't exist? My intention is to serve the files from bundle B, but this does not seem to happen. When I do not specify a httpcontextId for bundle B's resource contribution, the file is properly served, but then the authentication filter will not be able to see the token in the session attributes since it is now in a different context from the other servlets.
Looking at the documentation for the extension point "org.eclipse.equinox.http.registry.httpcontexts", a resource-mapping can be specified. The doc says that if no bundle name is provided then it will use the current bundle as the bundle to load resources from (eg. Bundle A would be serving resources from it's own non-existent "/res" folder when the intention is to serve resources from "/res" in Bundle B). Is there a workaround to restore this behavior? My app relies heavily on the mechanism that I have described.
Any help on this issue is appreciated.
[Updated on: Tue, 05 January 2016 21:58] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03360 seconds