You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Matt Raible <ma...@raibledesigns.com> on 2003/10/29 23:43:38 UTC
Loading velocimacros library from inside package
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
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.
Thanks,
Matt
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Loading velocimacros library from inside package
Posted by Matt Raible <ma...@raibledesigns.com>.
Unfortunately, this patch did not help - I guess I'll resort to putting
it in WEB-INF/classes. I think this is a pain in the ass, because now
I have to tell users they need to download two files (globalMacros.vm
and struts-menu.jar) instead of just one. Oh well - thanks for the
help.
Matt
On Oct 30, 2003, at 1:07 PM, Matt Raible wrote:
> I tried that - it didn't work. Possibly because globalMacros.vm is in
> a jar file in WEB-INF/lib. I'll try your patch.
>
> Matt
>
> On Oct 30, 2003, at 1:01 PM, Charles Oliver Nutter wrote:
>
>> At a second glance, there could be another problem...I could be
>> wrong, but I think the resource loader uses filesystem pathing, so it
>> would be
>>
>> net/sf/navigator/displayer/globalMacros.vm
>>
>> You could give that a shot and see if it works. Since you have the
>> webapp loader, it might pick it up ok.
>>
>> - 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.
>
>
> ---------------------------------------------------------------------
> 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
Re: Loading velocimacros library from inside package
Posted by Matt Raible <ma...@raibledesigns.com>.
I tried that - it didn't work. Possibly because globalMacros.vm is in
a jar file in WEB-INF/lib. I'll try your patch.
Matt
On Oct 30, 2003, at 1:01 PM, Charles Oliver Nutter wrote:
> At a second glance, there could be another problem...I could be wrong,
> but I think the resource loader uses filesystem pathing, so it would
> be
>
> net/sf/navigator/displayer/globalMacros.vm
>
> You could give that a shot and see if it works. Since you have the
> webapp loader, it might pick it up ok.
>
> - 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Loading velocimacros library from inside package
Posted by Charles Oliver Nutter <he...@headius.com>.
At a second glance, there could be another problem...I could be wrong,
but I think the resource loader uses filesystem pathing, so it would be
net/sf/navigator/displayer/globalMacros.vm
You could give that a shot and see if it works. Since you have the
webapp loader, it might pick it up ok.
- 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
Re: Loading velocimacros library from inside package
Posted by Charles Oliver Nutter <he...@headius.com>.
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
Re: Loading velocimacros library from inside package
Posted by Matt Raible <ma...@raibledesigns.com>.
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
Re: Loading velocimacros library from inside package
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
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