See my second post in the thread, there I also attached a sample wab. As I
mentioned, we detected the issue while using Jersey and trying to expose
REST services hosted in jars under WEB-INF/lib. So I looked at how Jersey
is loading resources (see e.g.
com.sun.jersey.api.core.servlet.WebAppResourceConfig) and used a similar
approach:

1. First get all resource paths of jar(s) under WEB-INF/lib

ServletContext servletContext = ...
Set<String> resourcePaths = servletContext.getResourcePaths("/WEB-INF/lib");

2. Then try loading the stream of each resource:
String resourcePath = resourcePaths.iterator().next();
InputStream inputStream = servletContext.getResourceAsStream(resourcePath);

Regards,
   Detelin

2016-12-05 10:09 GMT+02:00 Violeta Georgieva <miles...@gmail.com>:

>
>
> 2016-12-05 9:40 GMT+02:00 Violeta Georgieva <miles...@gmail.com>:
> >
> >
> >
> > 2016-12-05 9:38 GMT+02:00 <detelinyorda...@gmail.com>:
> > >
> > > Hi Violeta,
> > >    Thanks for the quick turnaround, I tested this fix and it seems to
> work for non-jar resources, but when trying to load a jar under
> WEB-INF/lib, it still returns null for the input stream. It looks like
> internally the jar resource url is interpreted as a directory due to the
> "!/" suffix.
> >
> > Ok let me check.
>
> Can you specify how you try to access the jar?
>
>
> >
> > Thanks,
> > Violeta
> >
> > >
> > > Regards,
> > >    Detelin
> > >
> > > 2016-12-02 19:10 GMT+02:00 Violeta Georgieva <miles...@gmail.com>:
> > >>
> > >> Hi Detelin,
> > >>
> > >> Indeed there was a problem in Gemini Web.
> > >> Here [1] you can find a fix for this issue.
> > >>
> > >> Best Regards,
> > >> Violeta
> > >>
> > >> [1] http://git.eclipse.org/c/gemini.web/org.eclipse.gemini.
> web.gemini-web-container.git/commit/?id=2016847082b46fbfb4fe46f3a67433
> f538943bc2
> > >>
> > >>
> > >> 2016-12-02 12:20 GMT+02:00 <detelinyorda...@gmail.com>:
> > >> >
> > >> > Hi again,
> > >> >   Actually, the code that seem to fail is a combination of
> Servlet.Context.getResourcePaths() and ServletContext.getResourceAsStream().
> I'm attaching a modified Gemini Web wab sample with slf4j api jar added in
> WEB-INF/lib and the following code added in SimpleServlet:
> > >> >
> > >> > ServletContext servletContext = ...
> > >> > Set<String> resourcePaths = servletContext.
> getResourcePaths("/WEB-INF/lib");
> > >> > String resourcePath = resourcePaths.iterator().next();
> > >> > InputStream inputStream = servletContext.getResourceAsStream(
> resourcePath);
> > >> > System.out.println(String.format("InputStream for resource '%s'
> is: %s", resourcePath, inputStream));
> > >> >
> > >> > With Gemini Web 2.2.7 this prints:
> > >> >
> > >> > InputStream for resource '/WEB-INF/lib/org.slf4j.api.jar' is:
> org.eclipse.osgi.storage.bundlefile.ZipBundleEntry$
> ZipBundleEntryInputStream@405822b1
> > >> >
> > >> > With Gemini Web 3.0 RC2 the result is:
> > >> >
> > >> > InputStream for resource '/WEB-INF/lib/org.slf4j.api.jar/' is: null
> > >> >
> > >> > So it seems there is also a difference in the getResourcePaths
> method - with Tomcat 8 this returns a resource path with a trailing slash.So
> > >> >
> > >> > Regards,
> > >> >    Detelin
> > >> >
> > >> >
> > >> >
> > >> > 2016-12-02 9:59 GMT+02:00 <detelinyorda...@gmail.com>:
> > >> >>
> > >> >> Hi,
> > >> >>   We recently tried Gemini Web 3.0 RC2 with Tomcat 8.5.5 and
> encountered a resource handling problem for web application bundles. We
> have tested Web application bundles with some jars in WEB-ING/lib which
> provide rest services and noticed that Jersey was not able to load them. At
> the end, it turned out that 
> ServletContext.getResourceAsStream("WEB-INF/lib/foo.jar")
> always returns null, even though ServletContext.getResourcePaths()
> successfully lists the resources.
> > >> >> This can be reproduced with Equinox 3.10 (Luna), Gemini Web 3.0
> RC2 and a simple wab containing a jar in WEB-INF/lib.
> > >> >> Could this be a problem in Gemini Web and/or Tomcat 8's new
> resource handling? I checked Gemini Web jira but did not find anything
> similar, will look further but thought I might just drop an email to see if
> anyone is aware of this issue.
> > >> >>
> > >> >> Regards,
> > >> >>    Detelin
> > >> >
> > >> >
> > >> >
> > >> > _______________________________________________
> > >> > gemini-dev mailing list
> > >> > gemini-dev@eclipse.org
> > >> > To change your delivery options, retrieve your password, or
> unsubscribe from this list, visit
> > >> > https://dev.eclipse.org/mailman/listinfo/gemini-dev
> > >>
> > >> _______________________________________________
> > >> gemini-dev mailing list
> > >> gemini-dev@eclipse.org
> > >> To change your delivery options, retrieve your password, or
> unsubscribe from this list, visit
> > >> https://dev.eclipse.org/mailman/listinfo/gemini-dev
> > >
> > >
> > >
> > > _______________________________________________
> > > gemini-dev mailing list
> > > gemini-dev@eclipse.org
> > > To change your delivery options, retrieve your password, or
> unsubscribe from this list, visit
> > > https://dev.eclipse.org/mailman/listinfo/gemini-dev
>
> _______________________________________________
> gemini-dev mailing list
> gemini-dev@eclipse.org
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/gemini-dev
>
_______________________________________________
gemini-dev mailing list
gemini-dev@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/gemini-dev

Reply via email to