You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Manish Khettry <ma...@bdnacorp.com> on 2002/03/23 00:31:11 UTC
Can't load resources in Velocity using the ClasspathResourceLoader
I'm trying to load a velocity template which I've placed in my classpath.
I set the property resource.loader.1.class to
org.apache...ClasspathResourceLoader. When I try to make the call to get the
template and it fails with a ResourceNotFoundException; i.e.
ve.setProperty(...);
ve.init();
Template t = ve.getTemplate("com.bdna.rule.builder.processFootprint");
However I can load the resource using ClassLoader.getResourceAsStream; i.e.
InputStream is =
cl.getResourceAsStream("com.bdna.rule.builder.processFootprint").
processFootprint is file placed in the class path.
Velocity version is 1.2.
Any pointers to what I could be doing wrong would be appreciated.
Thanks,
Manish
-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Thursday, March 21, 2002 11:49 PM
To: velocity-user@jakarta.apache.org
Subject: Re: Iterating through XML Elements - How?
On 3/21/02 6:54 PM, "bob mcwhirter" <bo...@werken.com> wrote:
> On Thu, 21 Mar 2002, Terry Steichen wrote:
>
>> I've generated an XML document (org.w3c.dom.Document) and inserted it
>> into the context. My template can use all the Document methods just
fine.
>> My problem is that when I do something like getElementsByTagName()
>> to return a Nodelist, I can't figure out how to use #foreach() to work
>> with it.
>
> Not certain if this will answer your question as to why foreach isn't
> working as you expect it to, but Jaxen (http://jaxen.org/) can help
> you work with XML object-models (DOM, JDOM, dom4j, EXML). Using
> XPath, you can extract whatever data portions you need.
>
> If you like JDOM, then Anakia (part of Velocity) is also a nice
> way to go. SomeDay(tm), I plan on re-working Anakia to use Jaxen
> instead of werken.xpath, so that more than just JDOM is supported.
All you have to do is release Jaxen...
:)
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
The question is : What is a Mahnamahna?
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
Re: Can't load resources in Velocity using the
ClasspathResourceLoader
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/26/02 1:05 PM, "Manish Khettry" <ma...@bdnacorp.com> wrote:
>
>> From the javadoc on the website!
>
> http://jakarta.apache.org/velocity/api/org/apache/velocity/runtime/resource/
> loader/ClasspathResourceLoader.html
Ah - thx. Fixed.
>
> Also, does it need to be class.resource.loader.class or
> classpath.resource.loader.class?
The idea is that you specify the 'name' you want to refer to it as
resource.loader = <name>
And then use that name
<name>.resource.loader.class = <classname>
So I suggested 'class' as the <name> but you could use 'classpath' if you
wanted, or 'cucumber' if you really wanted to :)
>
> Thanks
> Manish
>
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Saturday, March 23, 2002 6:26 AM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Can't load resources in Velocity using the
> ClasspathResourceLoader
>
>
> On 3/22/02 6:31 PM, "Manish Khettry" <ma...@bdnacorp.com> wrote:
>
>>
>> I'm trying to load a velocity template which I've placed in my classpath.
>>
>> I set the property resource.loader.1.class to
>> org.apache...ClasspathResourceLoader. When I try to make the call to get
> the
>> template and it fails with a ResourceNotFoundException; i.e.
>
> Whoa! "resource.loader.1.class"? That's pre version 1.0 notation.
>
> Where did you find that?
>
> The notation to use will be something like :
>
> resource.loader = class
>
> class.resource.loader.class =
> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
>
> (on one line, of course...)
>
> See the examples/servlet_example2 on how to use this.
>
> geir
>
> --
> Geir Magnusson Jr. geirm@optonline.net
> System and Software Consulting
> Java : the speed of Smalltalk with the simple elegance of C++...
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Can't load resources in Velocity using the ClasspathResourceLoader
Posted by Manish Khettry <ma...@bdnacorp.com>.
>>From the javadoc on the website!
http://jakarta.apache.org/velocity/api/org/apache/velocity/runtime/resource/
loader/ClasspathResourceLoader.html
Also, does it need to be class.resource.loader.class or
classpath.resource.loader.class?
Thanks
Manish
-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Saturday, March 23, 2002 6:26 AM
To: velocity-user@jakarta.apache.org
Subject: Re: Can't load resources in Velocity using the
ClasspathResourceLoader
On 3/22/02 6:31 PM, "Manish Khettry" <ma...@bdnacorp.com> wrote:
>
> I'm trying to load a velocity template which I've placed in my classpath.
>
> I set the property resource.loader.1.class to
> org.apache...ClasspathResourceLoader. When I try to make the call to get
the
> template and it fails with a ResourceNotFoundException; i.e.
Whoa! "resource.loader.1.class"? That's pre version 1.0 notation.
Where did you find that?
The notation to use will be something like :
resource.loader = class
class.resource.loader.class =
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
(on one line, of course...)
See the examples/servlet_example2 on how to use this.
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Java : the speed of Smalltalk with the simple elegance of C++...
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
Re: Can't load resources in Velocity using the ClasspathResourceLoader
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/22/02 6:31 PM, "Manish Khettry" <ma...@bdnacorp.com> wrote:
>
> I'm trying to load a velocity template which I've placed in my classpath.
>
> I set the property resource.loader.1.class to
> org.apache...ClasspathResourceLoader. When I try to make the call to get the
> template and it fails with a ResourceNotFoundException; i.e.
Whoa! "resource.loader.1.class"? That's pre version 1.0 notation.
Where did you find that?
The notation to use will be something like :
resource.loader = class
class.resource.loader.class =
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
(on one line, of course...)
See the examples/servlet_example2 on how to use this.
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Java : the speed of Smalltalk with the simple elegance of C++...
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>