velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Oliver Nutter <head...@headius.com>
Subject Re: Loading velocimacros library from inside package
Date Thu, 30 Oct 2003 19:56:46 GMT
This is a result of the bug in ClasspathResourceLoader where it tries to 
load resources from the classloader that Velocity was loaded in 
(probably the system level or app server level classloader). It should 
be loading from the classloader that the Thread specifies (which would 
be the webapp's class loader in this case), and I've submitted a patch 
to fix it, but I'm not sure why it hasn't been included yet ;)

http://issues.apache.org/bugzilla/show_bug.cgi?id=22419

You can make your own resource loader that will include the fix by 
applying the patch to ClasspathResourceLoader, or you can load Velocity 
at the webapp level instead of at the server or system level. Either way 
should fix the problem.

- Charlie

Matt Raible wrote:

> If I put globalMacros.vm in WEB-INF/classes and set 
> velocimacro.library  to globalMacros.vm - everything works.
>
> If I put globalMacros.vm in the net.sf.navigator.displayer package of 
> a  jar file (that get's put in WEB-INF/lib) and set 
> velocimacro.library to  net.sf.navigator.displayer.globalMacros.vm, I 
> get:
>
> ERROR - SimpleLog4JLogSystem.logVelocityMessage(181) | 
> ResourceManager  : unable to find resource 
> 'net.sf.navigator.displayer.globalMacros.vm'  in any resource loader.
>
> Here's my velocity.properties file:
>
> # specify resource loaders to use
> resource.loader = class, webapp
>
> # NOTE: Leave cache set to false while developing - change to true 
> when  deploying to production.
>
> # for the loader we call 'class', use the ClasspathResourceLoader
> class.resource.loader.description = Velocity Classpath Resource Loader
> class.resource.loader.class =  
> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> class.resource.loader.cache = false
> class.resource.loader.modificationCheckInterval = 60
>
> # for the loader we call 'webapp', use the WebappLoader
> webapp.resource.loader.description = Velocity Webapp Loader
> webapp.resource.loader.class =  
> org.apache.velocity.tools.view.servlet.WebappLoader
> webapp.resource.loader.cache = false
> webapp.resource.loader.modificationCheckInterval = 60
>
> # log invalid template references?
> # set this to false to have a quieter velocity.log
> runtime.log.invalid.reference=true
>
> # remove after completed
> runtime.log.error.stacktrace = true
> runtime.log.warn.stacktrace = true
> runtime.log.info.stacktrace = true
>
> # tell Velocity to use Log4J
> runtime.log.logsystem.class=org.apache.velocity.runtime.log.SimpleLog4JL 
> ogSystem
> runtime.log.logsystem.log4j.category=org.apache.velocity
>
> # velocimacro settings
> velocimacro.library = net.sf.navigator.displayer.globalMacros.vm
> velocimacro.permissions.allow.inline.to.replace.global=true
>
> Thanks,
>
> Matt
>
> On Oct 30, 2003, at 4:39 AM, Geir Magnusson Jr. wrote:
>
>>
>> On Wednesday, October 29, 2003, at 05:43 PM, Matt Raible wrote:
>>
>>> I have a globalMacros.vm file that since in my (expanded) webapp at  
>>> WEB-INF/classes/net/sf/navigator/displayer/.  I'm trying to load it  
>>> using the following:
>>>
>>> velocimacro.library = net.sf.navigator.displayer.globalMacros.vm
>>>
>>> Currently, I have classpath and webapp resource loaders 
>>> configured.   It doesn't find this file in any resource loaders, but 
>>> does find it  when I do:
>>>
>>> velocimacro.library = globalMacros.vm
>>
>>
>> How?
>>
>> Can you send the whole vel.props?
>>
>>>
>>> After reading the documentation, it appears that the classpath  
>>> resource loader will look in WEB-INF/classes and in 
>>> WEB-INF/lib/*.jar  for resources - which would explain my error.  Is 
>>> this correct?  If  so, I guess I'll build a jar file of the relevant 
>>> .class files and go  that route.
>>
>>
>> -- 
>> Geir Magnusson Jr                                   203-247-1713(m)
>> geirm@optonline.net
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message