velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nutter, Charles O." <Charles.Nut...@fns.usda.gov>
Subject URL and Classpath resource loaders
Date Wed, 06 Aug 2003 19:25:21 GMT
I have a couple quick questions:

1. From looking at the mailing lists, it seems the URLResourceLoader has been on the drawing
board for a considerable amount of time. Any chance of this making it into a release distribution
someday?

2. ClasspathResourceLoader is half of what I need; it loads resources using the ClassLoader,
but it doesn't use the correct one for my purposes. In 1.3.1 it appears to use this.getClass().getClassLoader(),
which would be the ClassLoader that loaded Velocity. In my case, that ClassLoader is in the
upper eschelons of the container, close to the topmost system classloader. However, my templates
are in an EJB JAR, which would have a classloader at a much lower level. As a result, Velocity's
ClasspathResourceLoader cannot find my templates. What should I do?

URLResourceLoader would seem to be an option, but it is less than ideal to include code that
will be perceived as "development" as part of installation instructions for this application.
JarResourceLoader requires I know the path to and the name of the jar file that will contain
the templates at compile time, which is not the case. The templates may be deployed in a number
of different locations, and the name of the EJB jar may change.

So the simple, bottom-line question is this:

How do I load a template in a jar not available to the classloader that Velocity was loaded
in?

And the underlying question is:

Why does Velocity try to load everything from the classloader it was loaded in, rather than
in the classloader it is called from?

- Charlie

Mime
View raw message