By the call of Class.getClassLoader() before retrieving the resource-Stream
you do "navigate to the root" of your classpath. Keeping that in mind, the
call you described provided the parameter "my.xsl" should deliver the
InputStream pointing to src/main/resources/my.xsl as wayne described of ANY
jar you declared as dependency(and of the project itself). But only if you
build your project with maven in advance(so that the resources get copied)
and did not fiddle with the resource plugin configuration of your
dependency to much.

You load resources from the "package" as I understand your description if
you use Class.getResourceAsStream(). So if your qualified classname is like
"net.test.MyClass" and you call MyClass.getResourceAsStream("my.xsl") the
method will look up your resource in the classpath as well, but in the
package of "net.test".
By the way, if you want to load resources not provided in your classpath,
try using FileInputStream or the like.
And in an related matter to tests, src/test/resources are neither in the
classpath at "non-test"-runtime nor available for dependent projects.


Best regards

2012/6/21 Wayne Fay <wayne...@gmail.com>

> > I have tried using
> > MyXsltUtility.getClass().getClassLoader().getResourceAsStream(...) but
> that
> > looks for the .xsl inside of a *package*. This is the problem. How do I
> get
> > access to the *resources* folder, as the .xsl file does not live inside
> of
> > the java class package structure?
>
> Open up the jar created by your utility project (with Winzip etc) and
> find the xsl file inside it.
>
> Whether you realize it or not, your resources are in the "java class
> path structure." All resources in the jar file are in this structure
> -- essentially you get a merge of src/main/resources and src/main/java
> all under a single path structure.
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>

Reply via email to