with "mypackage/Template.wm" the call to getClass().getResource(...)
fails but the velocity resource loader is ok.

   michael


On Fri, 25 Jun 2004, Geir Magnusson Jr wrote:

> what happens if you remove leading /?
>
> On Jun 23, 2004, at 5:24 PM, Michael Heuer wrote:
>
> >
> > I'm actually running into a similar problem, in an application with the
> > ClasspathResourceLoader.  I have templates in a jar on the classpath
> > in a
> > package mypackage.  The classloader can find the template but velocity
> > can not.
> >
> >   System.out.println(Velocity.getProperty("resource.loader"));
> >
> > System.out.println(Velocity.getProperty("class.resource.loader.class"))
> > ;
> >   java.net.URL url = getClass().getResource("/mypackage/Template.wm");
> >   System.out.println("found resource, url=" + url);
> >   Template template = Velocity.getTemplate("/mypackage/Template.wm");
> >
> > [class]
> > org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> > found resource, url=jar:file:/.../templates.jar!/mypackage/Template.wm
> > org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> > resource '/mypackage/Template.wm'
> >         at
> > org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(R
> > esourceManagerImpl.java:458)
> >         at
> > org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Re
> > sourceManagerImpl.java:341)
> >
> >    michael
> >
> >
> > On Tue, 22 Jun 2004, Will Glass-Husain wrote:
> >
> >> You don't give an absolute path to Velocity.  Instead, specify the
> >> path to
> >> the root of the template tree when configuring velocity, then pass in
> >> template paths relative to this path.
> >>
> >> http://jakarta.apache.org/velocity/developer-
> >> guide.html#Configuring%20Resource%20Loaders
> >>
> >> This can be a little confusing when you start out but look at the
> >> example in
> >> the section above.
> >>
> >> WILL
> >>
> >> ----- Original Message -----
> >> From: "Ilan Azbel" <[EMAIL PROTECTED]>
> >> To: "Velocity Users List" <[EMAIL PROTECTED]>
> >> Sent: Tuesday, June 22, 2004 1:03 AM
> >> Subject: mergeTemplate not finding the vm file from crontab
> >>
> >>
> >>> Hello,
> >>>
> >>> I have written a small application that produces html output using
> >> velocity
> >>> mergeTemplate() method (as described in the manual).
> >>>
> >>> It all works perfectly for me when I run the application from the
> >> operating
> >>> system prompt. However, when I schedule the same application to rub
> >>> from
> >> the
> >>> crontab I get the following exception:
> >>>
> >>> org.apache.velocity.exception.ResourceNotFoundException: Unable to
> >>> find
> >>> resource '/usr/tdk-2.2/bin/CustomReportEmail.vm'
> >>>         at
> >>>
> >> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(
> >> Resour
> >>> ceManagerImpl.java:501)
> >>>         at
> >>>
> >> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(R
> >> esourc
> >>> eManagerImpl.java:384)
> >>>         at
> >>>
> >> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstanc
> >> e.java
> >>> :814)
> >>>         at
> >>>
> >> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingle
> >> ton.ja
> >>> va:355)
> >>>         at
> >> org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:482)
> >>>         at
> >>> com.autochartist.patterns.om.AlertEmailer.main(AlertEmailer.java:92)
> >>>
> >>> I have tried to provide the mergeTemplate method with the full path
> >>> of the
> >>> .vm file, but still no luck.
> >>>
> >>> Any ideas where I should put the vm file?
> >>>
> >>> Thanks
> >>> Ilan
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> For additional commands, e-mail:
> >>> [EMAIL PROTECTED]
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> --
> Geir Magnusson Jr                                   203-247-1713(m)
> [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to