You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "DESFORGES, Frederic" <f-...@efluid.fr> on 2017/08/01 11:29:48 UTC

Tomcat 8.x/9.x using and meta-inf/resources

Hi,

I have some trouble using <resources> configuration (used though cargo maven plugin).

What I want to do :
I have some files in a jar in META-INF/resources folder, I have to access to them.
In some case I achieve to make it working but the solution is not really clean in my point of view.

I have reproduced my issues by only adding following to the conf/server.xml files in tomcat8.5.4/8.5.16 and 8.5.16 inside :
This is working : the server started and I can access to test.html (that is in my dependencies jar)
<Resources>
   <JarResources  base="<absolutePath>\0.0.1-SNAPSHOT" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/lib" />
  <PostResources base="<absolutePath>\target\classes" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/classes" />
</Resources>
Note that "<path>\0.0.1-SNAPSHOT" only contains one jar for this test.
This is working so it's ok but, it's really not great to add an entire folder of jar since I have want to add only a specific one.

This is not working : the server started and but I can't access to test.html (library.jar/META-INF/resources/test.html)
<Resources>
   <JarResources  base="<absolutePath>\0.0.1-SNAPSHOT\library.jar" className="org.apache.catalina.webresources.JarResourceSet" webAppMount="/WEB-INF/lib" />
  <PostResources base="<absolutePath>\target\classes" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/classes" />
</Resources>
Other case that are not working :
<Resources>
   <JarResources  base="<absolutePath>\ 0.0.1-SNAPSHOT\library.jar" className="org.apache.catalina.webresources.JarResourceSet" webAppMount="/WEB-INF/classes" />
  <PostResources base="<absolutePath>\target\classes" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/classes" />
</Resources>
<Resources>
   <PostResources base="<absolutePath>\0.0.1-SNAPSHOT\library.jar" className="org.apache.catalina.webresources.JarResourceSet" webAppMount="/WEB-INF/classes" />
  <PostResources base="<absolutePath>\target\classes" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/classes" />
</Resources>
(the last example is ok to not work according to the documentation (only jarResources are eligible for META-INF/resources scanning) )

So my question is that normal behavior of    <JarResources  or do I need more configuration to make it work using  className="org.apache.catalina.webresources.JarResourceSet" ?

Thanks,
Fred


RE: Tomcat 8.x/9.x using and meta-inf/resources

Posted by "DESFORGES, Frederic" <f-...@efluid.fr>.
> Does that work any better?

Yes that's work, thanks for given a clear and precise answer. 

fred




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 8.x/9.x using and meta-inf/resources

Posted by Mark Thomas <ma...@apache.org>.
On 01/08/17 12:29, DESFORGES, Frederic wrote:

<snip/>

> This is not working : the server started and but I can't access to test.html (library.jar/META-INF/resources/test.html)
> <Resources>
>    <JarResources  base="<absolutePath>\0.0.1-SNAPSHOT\library.jar" className="org.apache.catalina.webresources.JarResourceSet" webAppMount="/WEB-INF/lib" />
>   <PostResources base="<absolutePath>\target\classes" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/classes" />
> </Resources>

That is exposing the contents of library.jar to WEB-INF/lib. There are
several problems with that:
- it ignores the META-INF/resources
- the contents of the JAR should be mapped to WEB-INF/classes
- it is adding it as a JAR resource which is an odd priority


> Other case that are not working :
> <Resources>
>    <JarResources  base="<absolutePath>\ 0.0.1-SNAPSHOT\library.jar" className="org.apache.catalina.webresources.JarResourceSet" webAppMount="/WEB-INF/classes" />
>   <PostResources base="<absolutePath>\target\classes" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/classes" />
> </Resources>


This fixes the mapping location but the other issues remain.


> <Resources>
>    <PostResources base="<absolutePath>\0.0.1-SNAPSHOT\library.jar" className="org.apache.catalina.webresources.JarResourceSet" webAppMount="/WEB-INF/classes" />
>   <PostResources base="<absolutePath>\target\classes" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WEB-INF/classes" />
> </Resources>
> (the last example is ok to not work according to the documentation (only jarResources are eligible for META-INF/resources scanning) )


That isn't quite right. JarResources are the result of
META-INF/resources scanning.


> So my question is that normal behavior of    <JarResources  or do I need more configuration to make it work using  className="org.apache.catalina.webresources.JarResourceSet" ?

Everything you describe as as expected.

What I think you want is:
<Resources>
  <PostResources base="<absolutePath>\0.0.1-SNAPSHOT\library1.jar"
      className="org.apache.catalina.webresources.FileResourceSet"
      webAppMount="/WEB-INF/lib/library1.jar"/>
  <PostResources base="<absolutePath>\target\classes"
      className="org.apache.catalina.webresources.DirResourceSet"
      webAppMount="/WEB-INF/classes" />
</Resources>

What the above configuration does is treats library1.jar as if it was
located in WEB-INF/lib and target\classes as if the contents of that
directory were location in WEB-INF/classes.

Does that work any better?

HTH,

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org