79274484

Date: 2024-12-12 09:28:45
Score: 1.5
Natty:
Report link

Wow this question is quite old and none of the answers are marked. So I'll try to explain the problem and to provide another solution.

The problem with OSGi classpaths is, that every bundle has it's own private classloader. That bundle classloader must have the template resources on the classpath and the Velocity classes. If the Velocity classes are provided by another bundle, Velocity's ClasspathResourceLoader will not find the template resources because they are not on that bundle's classpath.

So either you have to

  1. ensure that the Velocity's ClasspathResourceLoader is located in the very same classpath as the templates (mentioned by @centic) or
  2. implement and configure a custom ResourceLoader that is able to find the resources (mentioned by @gary-stand-with-ukraine).

For the latter option I would choose another approach and would specialize ClasspathResourceLoader to be configured with the explicit class loader instance which is aware of the resources.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • User mentioned (1): @centic
  • User mentioned (0): @gary-stand-with-ukraine
  • Low reputation (0.5):
Posted by: Kai K.