You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Reto Badertscher <rb...@i-netsystems.com> on 2001/06/15 09:43:38 UTC

Unabel to find template

Just included velocity into my own framework. All works ok, but when it's
time to render a template (I'm trying with the sample1) i just get:
Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : adding VMs from VM
library template : VM_global_library.vm
Thu Jun 14 23:29:48 CEST 2001  [error] ResourceManager : unable to find
resource 'VM_global_library.vm' in any resource loader.
Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : error using  VM library
template VM_global_library.vm :
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'VM_global_library.vm'
Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInline = true :
VMs can be defined inline in templates
Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInlineToOverride =
false : VMs defined inline may NOT replace previous VM definitions
Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInlineLocal =
false : VMs defined inline will be  global in scope if allowed.
Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : messages on  : VM
system will output logging messages
Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : initialization
complete.
Thu Jun 14 23:29:48 CEST 2001   [info] Velocity successfully started.
Thu Jun 14 23:29:57 CEST 2001  [error] ResourceManager : unable to find
resource 'sample1.vm' in any resource loader.

I'm using Tomcat 3.2.
I put my template in the following locations webapps\iFrameTest,
webapps\iFrameTest\lib, webapps\iFrameTest\classes without any success (teh
template is correctly spelled).
BTW: I would like to see the locations in log where velocity tries to find
the template.
The velocity jar is in webapps\iFrameTest\lib with the following settings:

resource.loader = file

file.resource.loader.description = Velocity File Resource Loader
file.resource.loader.class =
org.apache.velocity.runtime.resource.loader.FileResourceLoader
file.resource.loader.path = .
file.resource.loader.cache = false
file.resource.loader.modificationCheckInterval = 2

Thanks in advance for any help.

i[net-systems
i-netsystems gmbh
Seestr. 325
CH-8035 Zuerich
Switzerland


Re: List iterator - Use once only?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
pat comcen wrote:
> 
> Can someonen enlighten me on this
> iterate once only behaviour of Velocity?
> 
> Is it true that a list can only be iterated over once?

No. As long as you don't put a 'naked Iterator' into the context, you
can iterate until the cows come home.

So if you use an object array ( ex String[]), a List, a Vector ,etc, all
will be fine.

Only when you put an Iterator into the context will you have a problem. 
The reason is that the Iterator class as no 'reset'.  So once you go to
the end, you are done.

For the other classes, Velocity will get a new iterator each time for a
#foreach() , so there is no problem.

> I'm sure this was discusseed at some point
> though I couldn't find a mention in my
> some 1,500 stash of Turbine/Velocity mails..
> 
> I suppose I need to understand exactly what an iterator
> is..

That would help. :)

It would be a rare thing if you needed to drop in a solitary Iterator,
rather than a class that exposes a List interface or an array [].

We added it for the rare instance when all you have is an iterator...

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

List iterator - Use once only?

Posted by pat comcen <ps...@comcen.com.au>.
Can someonen enlighten me on this
iterate once only behaviour of Velocity?

Is it true that a list can only be iterated over once?

I'm sure this was discusseed at some point
though I couldn't find a mention in my
some 1,500 stash of Turbine/Velocity mails..

I suppose I need to understand exactly what an iterator
is..

Thankyou,

Patrick.



Re: avoiding linebreaks

Posted by Christoph Reck <Ch...@dlr.de>.
I've found a nicer desing-pattern for joining that avoids 
the #if in favour of a #set that does not depend on the 
velocity count:

#macro( join $list $sep )#set( $s_ = "" )
#foreach( $elem_ in $list )$s_$elem_#set( $s_ = $sep )#end
#end

And you use it as:
 
#join($elems, ",")

:) Christoph


Jeremy Leader wrote:
> 
> How about a macro (off the top of my head):
> 
> #macro (join $list $sep)#foreach($elem in $list)#if($velocityCount>1)$sep#end$elem$end#end
> 
> (I'm not certain if you can string it all on one line like that,
> but I think you'd want to, to avoid extraneous white space in
> the result).
> 
> Then you use it as:
> 
> #join($elems, ",")
> 
> Jeremy Leader
> 
> PS is $velocityCount local to each #foreach?  If I called
> the above macro from inside another #foreach, could the outer
> loop still use $velocityCount and not have to worry about the
> inner loop (inside the macro) messing it up?
> 
> At 11:31 AM 6/20/01 , Robert Kuzelj wrote:
> >hi geir,
> > >
> > > Or, with commas
> > >
> > > #foreach($elem in $elems)#if($velocityCount>1),#end$elem#end
> > >
> > > using velocity's default loop counter, $velocityCount, which starts with
> > > 1
> > >
> >ouch!
> >isnt there a more readable way?
> >i am doing a lot of java-generator and python-generator
> >programming. if have to code all those generators
> >that way, its simply not reusable nor changeable.
> >
> >there was a proposol concerning whitespaces in velo.
> >what about that?
> >
> >ciao robertj

Re: avoiding linebreaks

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Robert Kuzelj wrote:
> 
> hi,
> 
> is there a possebillity to avoid linebraks in
> velocity 1.1?
> 
> what i would do is something like:
> >>>>>>>>>>>>>
> #for ($elem in $elems)
>     $elem
> #end
> >>>>>>>>>>>>>
> which should look like
> 1,2,3,4,5
> given that elems is: [1,2,3,4,5]
> 
> ciao robertj
> 

#for( $elem in $elemns)$elem#end

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: avoiding linebreaks

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Jeremy Leader wrote:
> 
> How about a macro (off the top of my head):
> 
> #macro (join $list $sep)#foreach($elem in $list)#if($velocityCount>1)$sep#end$elem$end#end
> 
> (I'm not certain if you can string it all on one line like that,
> but I think you'd want to, to avoid extraneous white space in
> the result).

+1 - yep that will work fine.

> Then you use it as:
> 
> #join($elems, ",")
> 
> Jeremy Leader
> 
> PS is $velocityCount local to each #foreach?  If I called
> the above macro from inside another #foreach, could the outer
> loop still use $velocityCount and not have to worry about the
> inner loop (inside the macro) messing it up?

Yes - it should work correctly.

geir
 

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: avoiding linebreaks

Posted by Jon Stevens <jo...@latchkey.com>.
on 6/20/01 12:41 PM, "Jeremy Leader" <jl...@alumni.caltech.edu> wrote:

> PS is $velocityCount local to each #foreach?  If I called
> the above macro from inside another #foreach, could the outer
> loop still use $velocityCount and not have to worry about the
> inner loop (inside the macro) messing it up?

Yes, it is locally defined correctly.

-jon


Re: avoiding linebreaks

Posted by Jeremy Leader <jl...@alumni.caltech.edu>.
How about a macro (off the top of my head):

#macro (join $list $sep)#foreach($elem in $list)#if($velocityCount>1)$sep#end$elem$end#end

(I'm not certain if you can string it all on one line like that,
but I think you'd want to, to avoid extraneous white space in
the result).

Then you use it as:

#join($elems, ",")

Jeremy Leader

PS is $velocityCount local to each #foreach?  If I called
the above macro from inside another #foreach, could the outer
loop still use $velocityCount and not have to worry about the
inner loop (inside the macro) messing it up?

At 11:31 AM 6/20/01 , Robert Kuzelj wrote:
>hi geir,
> > 
> > Or, with commas
> > 
> > #foreach($elem in $elems)#if($velocityCount>1),#end$elem#end
> > 
> > using velocity's default loop counter, $velocityCount, which starts with
> > 1
> > 
>ouch!
>isnt there a more readable way?
>i am doing a lot of java-generator and python-generator
>programming. if have to code all those generators
>that way, its simply not reusable nor changeable.
>
>there was a proposol concerning whitespaces in velo.
>what about that?
>
>ciao robertj
>
>
>=====
>itemj
>http://www.itemj.com
>Robert Kuzelj          mobil 0177  5302230
>Ramonvillestr.6        tel   06039 930223
>61184 Karben           fax   06039 2224
>
>__________________________________________________
>Do You Yahoo!?
>Get personalized email addresses from Yahoo! Mail
>http://personal.mail.yahoo.com/ 



Re: avoiding linebreaks

Posted by Robert Kuzelj <ro...@yahoo.com>.
hi geir,
> 
> Or, with commas
> 
> #foreach($elem in $elems)#if($velocityCount>1),#end$elem#end
> 
> using velocity's default loop counter, $velocityCount, which starts with
> 1
> 
ouch!
isnt there a more readable way?
i am doing a lot of java-generator and python-generator
programming. if have to code all those generators
that way, its simply not reusable nor changeable.

there was a proposol concerning whitespaces in velo.
what about that?

ciao robertj


=====
itemj
http://www.itemj.com
Robert Kuzelj          mobil 0177  5302230
Ramonvillestr.6        tel   06039 930223
61184 Karben           fax   06039 2224

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: avoiding linebreaks

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Robert Kuzelj wrote:
> 
> hi,
> 
> is there a possebillity to avoid linebraks in
> velocity 1.1?
> 
> what i would do is something like:
> >>>>>>>>>>>>>
> #for ($elem in $elems)
>     $elem
> #end
> >>>>>>>>>>>>>
> which should look like
> 1,2,3,4,5
> given that elems is: [1,2,3,4,5]
> 
> ciao robertj

Or, with commas

#foreach($elem in $elems)#if($velocityCount>1),#end$elem#end

using velocity's default loop counter, $velocityCount, which starts with
1

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: avoiding linebreaks

Posted by Edward Muller <em...@learningpatterns.com>.
New to Velocity myself...

But I think that would be great (modifying the whitespace rules)!

> The simplest way to avoid linebreaks in
> velocity is to escape them with a #* comment *#.
> 
> #for ($elem in $elems)#*
> *#$elem#*
> *##end
> 
> I have proposed previously to enhance the whitespace
> handling to make any standalone directive (with 
> whitespaces around it and nothing else) to not emit 
> anything to the output. Currently #end and #set
> directives gobble up only trailing whitespaces 
> including the EOL.
> 
> This would change the behaviour of current templates,
> but would be much more consistent and desireable.
> 
> :) Christoph
> 
> 
> Robert Kuzelj wrote:
>> 
>> hi,
>> 
>> is there a possebillity to avoid linebraks in
>> velocity 1.1?
>> 
>> what i would do is something like:
>> >>>>>>>>>>>>>
>> #for ($elem in $elems)
>>     $elem
>> #end
>> >>>>>>>>>>>>>
>> which should look like
>> 1,2,3,4,5
>> given that elems is: [1,2,3,4,5]
>> 
>> ciao robertj
>> 
>> =====
>> itemj
>> http://www.itemj.com
>> Robert Kuzelj          mobil 0177  5302230
>> Ramonvillestr.6        tel   06039 930223
>> 61184 Karben           fax   06039 2224
>> 
>> __________________________________________________
>> Do You Yahoo!?
>> Get personalized email addresses from Yahoo! Mail
>> http://personal.mail.yahoo.com/


-- 
Edward Muller
Director of Information Services
LearningPatterns.com Inc.

Direct: 212-486-9064 x 115
Fax: 212-202-3822
Email: emuller@learningpatterns.com

http://www.learningpatterns.com


Re: avoiding linebreaks

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Joaquim Ramos de Carvalho wrote:
> 
> My company created a small template language for bibliographic
> applications where this problem was very important. The way we handled
> it was by two special commands (the syntax is different, I am putting it
> as they would look in velocity)
> 

[SNIP]

> This is not a feature request, just a note on how the problem was
> handled in a similar situation. Note,however that an addition of this
> type would be backwards compatible with existing templates.
> 
> In fact in the usage we make of Velocity linebreaks are not a problem
> because we keep logic to a minimum in templates and push things to
> context objects. In our in house template language the templates had
> heavy logic and thus could produce dozens of blank lines -- hence the
> output/echo solutionm which is in fact was a sympton of poor
> Logic/presentation separation.
> 

:)

I was reading this thinking "Hm, interesting, but it seems like a
band-aid for having so much business/application logic in the
templates...."

Have you switched to Velocity?

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: avoiding linebreaks

Posted by Joaquim Ramos de Carvalho <jr...@bookmarc.pt>.
My company created a small template language for bibliographic 
applications where this problem was very important. The way we handled 
it was by two special commands (the syntax is different, I am putting it 
as they would look in velocity)

1)
#output(arg)    where arg is "on", "off", "hold" or "restore".
     #ouput(off) would cancel any output from the template. Purely 
computational sequences would be "executed" without any output.
For example:

    #output(off)
   ## holding off ouput to avoid blank lines from inside the loop
    #for ($elem in $elements)
     ## this is just a method call, no interesting output
      $elem.translate($userLanguage)
    #end
   #output (on)

This would produce a single line break after the line (#output(on))

#output(hold) and #output(restore) function like a push and pop of the 
current "output" state. This allows macros or inserted templates to save 
the current output state (from the calling template), change it if they 
need to and them restoring it back to the original state.

The other command is #echo which overrides the current output state for 
a single statement.

For example:
#output(off)
#for ($elem in $elems)
    #echo( $elem)
#end
#output(on)

would produce the value of each $elem and a single linebreak after 
#output(on)

#echo makes it easier to handle situations where you want to avoid most 
of the output and it would be awkward to be using #output(on) 
#output(off) .

This is not a feature request, just a note on how the problem was 
handled in a similar situation. Note,however that an addition of this 
type would be backwards compatible with existing templates.

In fact in the usage we make of Velocity linebreaks are not a problem 
because we keep logic to a minimum in templates and push things to 
context objects. In our in house template language the templates had 
heavy logic and thus could produce dozens of blank lines -- hence the 
output/echo solutionm which is in fact was a sympton of poor 
Logic/presentation separation.

Joaquim



On Thursday, June 21, 2001, at 08:48 AM, Christoph Reck wrote:

> The simplest way to avoid linebreaks in
> velocity is to escape them with a #* comment *#.
>
> #for ($elem in $elems)#*
> *#$elem#*
> *##end
>
> I have proposed previously to enhance the whitespace
> handling to make any standalone directive (with
> whitespaces around it and nothing else) to not emit
> anything to the output. Currently #end and #set
> directives gobble up only trailing whitespaces
> including the EOL.
>
> This would change the behaviour of current templates,
> but would be much more consistent and desireable.
>
> :) Christoph
>
>
> Robert Kuzelj wrote:
>>
>> hi,
>>
>> is there a possebillity to avoid linebraks in
>> velocity 1.1?
>>
>> what i would do is something like:
>>>>>>>>>>>>>>>
>> #for ($elem in $elems)
>>     $elem
>> #end
>>>>>>>>>>>>>>>
>> which should look like
>> 1,2,3,4,5
>> given that elems is: [1,2,3,4,5]
>>
>> ciao robertj
>>
>> =====
>> itemj
>> http://www.itemj.com
>> Robert Kuzelj          mobil 0177  5302230
>> Ramonvillestr.6        tel   06039 930223
>> 61184 Karben           fax   06039 2224
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Get personalized email addresses from Yahoo! Mail
>> http://personal.mail.yahoo.com/
>

Re: avoiding linebreaks

Posted by Christoph Reck <Ch...@dlr.de>.
The simplest way to avoid linebreaks in
velocity is to escape them with a #* comment *#.

#for ($elem in $elems)#*
*#$elem#*
*##end

I have proposed previously to enhance the whitespace
handling to make any standalone directive (with 
whitespaces around it and nothing else) to not emit 
anything to the output. Currently #end and #set
directives gobble up only trailing whitespaces 
including the EOL.

This would change the behaviour of current templates,
but would be much more consistent and desireable.

:) Christoph


Robert Kuzelj wrote:
> 
> hi,
> 
> is there a possebillity to avoid linebraks in
> velocity 1.1?
> 
> what i would do is something like:
> >>>>>>>>>>>>>
> #for ($elem in $elems)
>     $elem
> #end
> >>>>>>>>>>>>>
> which should look like
> 1,2,3,4,5
> given that elems is: [1,2,3,4,5]
> 
> ciao robertj
> 
> =====
> itemj
> http://www.itemj.com
> Robert Kuzelj          mobil 0177  5302230
> Ramonvillestr.6        tel   06039 930223
> 61184 Karben           fax   06039 2224
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/

RE: avoiding linebreaks

Posted by David Rees <dr...@ebetinc.com>.
> is there a possebillity to avoid linebraks in
> velocity 1.1?
>
> what i would do is something like:
> >>>>>>>>>>>>>
> #for ($elem in $elems)
>     $elem
> #end
> >>>>>>>>>>>>>
> which should look like
> 1,2,3,4,5
> given that elems is: [1,2,3,4,5]

Best thing to do then is this:

#for ($elem in $elems)$elem#end

Not as readable, but does the trick.

There was some discussion about this previously in the archives, you may
want to check them.

-Dave


avoiding linebreaks

Posted by Robert Kuzelj <ro...@yahoo.com>.
hi,

is there a possebillity to avoid linebraks in
velocity 1.1?

what i would do is something like:
>>>>>>>>>>>>>
#for ($elem in $elems)
    $elem
#end
>>>>>>>>>>>>>
which should look like
1,2,3,4,5
given that elems is: [1,2,3,4,5]

ciao robertj


=====
itemj
http://www.itemj.com
Robert Kuzelj          mobil 0177  5302230
Ramonvillestr.6        tel   06039 930223
61184 Karben           fax   06039 2224

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: AW: AW: AW: Unable to find template

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
jido@respublica.fr wrote:
> 
> Thanks for the info Geir.
> 
> Looking at the source, it seems that VM_global_library.vm is loaded
> together with other templates, so we can't discriminate it from the
> others. However, is being unable to load a template really a 'failure'?
> Seems to me that logging a warning would be enough.
> I wouldn't change VelocimacroFactory.java, just ResourceLoader.java
> 
> 446c446
> <                 Runtime.error(
> ---
>  >                 Runtime.warn(
> 
> VelocimacroFactory.java issues only an INFO line, so it's already fine.
> What do you think?
>

The ResourceLoader.java must emit an error when it can't find a template
because it's assumed that when it's asked, someone really wants one,
rather than it being a suggestion.

Further, it can't really tell that it's the VM Factory trying to set up.

I see your point that the output is kind of bothersome, so we can clean
up the output from VMFactory so it isn't so scary.  Just dropping the
default value might cause problems for people that depend on it, so we
probably don't want to do that.

geir


-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: AW: AW: AW: Unable to find template

Posted by ji...@respublica.fr.
Thanks for the info Geir.

Looking at the source, it seems that VM_global_library.vm is loaded 
together with other templates, so we can't discriminate it from the 
others. However, is being unable to load a template really a 'failure'? 
Seems to me that logging a warning would be enough.
I wouldn't change VelocimacroFactory.java, just ResourceLoader.java

446c446
<                 Runtime.error(
---
 >                 Runtime.warn(

VelocimacroFactory.java issues only an INFO line, so it's already fine.
What do you think?

-- Denis.


On Monday, June 18, 2001, at 08:00  pm, Geir Magnusson Jr. wrote:

> jido@respublica.fr wrote:
>>
>> On Saturday, June 16, 2001, at 02:57  am, Geir Magnusson Jr. wrote:
>>
>>> jido@respublica.fr wrote:
>>>>
>>>> Velocity should be able to intercept the error and issue only a
>>>> warning,
>>>> because the missing file doesn't do any harm :D
>>>>
>>>
>>> I was thinking that as I wrote it, but once inside the engine, it 
>>> can't
>>> figure out if it is the 'default' value of the VM lib, or a user
>>> specified one.
>>>
>>
>> Which source is it in? I'd like to have a look.
>> Can't you throw a specific exception in this case?
>
> VelocimacroFactory.java
>
> Yes, we can throw an exception, as init() will throw.
>
> If we do that, I think we should remove the default VM_global_lib.vm
>
>
> --
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> You have a genius for suggesting things I've come a cropper with!
>

Re: AW: AW: AW: Unable to find template

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
jido@respublica.fr wrote:
> 
> On Saturday, June 16, 2001, at 02:57  am, Geir Magnusson Jr. wrote:
> 
> > jido@respublica.fr wrote:
> >>
> >> Velocity should be able to intercept the error and issue only a
> >> warning,
> >> because the missing file doesn't do any harm :D
> >>
> >
> > I was thinking that as I wrote it, but once inside the engine, it can't
> > figure out if it is the 'default' value of the VM lib, or a user
> > specified one.
> >
> 
> Which source is it in? I'd like to have a look.
> Can't you throw a specific exception in this case?

VelocimacroFactory.java

Yes, we can throw an exception, as init() will throw.

If we do that, I think we should remove the default VM_global_lib.vm

> > Point noted - at least the message should look less scary.
> 
> :-)
> 
> -- Denis.
> 
> >
> > geir
> >
> >> -- Denis.
> >>
> >> On Friday, June 15, 2001, at 01:10  pm, Geir Magnusson Jr. wrote:
> >>
> >>> Reto Badertscher wrote:
> >>>>
> >>>> Hei Geir,
> >>>>
> >>>> after correction it seems ok - what about error using  VM library
> >>>> template
> >>>> VM_global_library.vm  is
> >>>> this needed?
> >>>
> >>> No - that is the default filename if you want to have Velocimacros
> >>> loaded at startup automatically so any template can use them.
> >>>
> >>> If the file isn't found, it squawks about it, but there is no harm
> >>> done.
> >>>
> >>> geir
> >>>
> >
> > --
> > Geir Magnusson Jr.                           geirm@optonline.net
> > System and Software Consulting
> > Developing for the web?  See http://jakarta.apache.org/velocity/
> > You have a genius for suggesting things I've come a cropper with!
> >

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: AW: AW: AW: Unable to find template

Posted by ji...@respublica.fr.
On Saturday, June 16, 2001, at 02:57  am, Geir Magnusson Jr. wrote:

> jido@respublica.fr wrote:
>>
>> Velocity should be able to intercept the error and issue only a 
>> warning,
>> because the missing file doesn't do any harm :D
>>
>
> I was thinking that as I wrote it, but once inside the engine, it can't
> figure out if it is the 'default' value of the VM lib, or a user
> specified one.
>

Which source is it in? I'd like to have a look.
Can't you throw a specific exception in this case?

> Point noted - at least the message should look less scary.

:-)

-- Denis.

>
> geir
>
>> -- Denis.
>>
>> On Friday, June 15, 2001, at 01:10  pm, Geir Magnusson Jr. wrote:
>>
>>> Reto Badertscher wrote:
>>>>
>>>> Hei Geir,
>>>>
>>>> after correction it seems ok - what about error using  VM library
>>>> template
>>>> VM_global_library.vm  is
>>>> this needed?
>>>
>>> No - that is the default filename if you want to have Velocimacros
>>> loaded at startup automatically so any template can use them.
>>>
>>> If the file isn't found, it squawks about it, but there is no harm 
>>> done.
>>>
>>> geir
>>>
>
> --
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> You have a genius for suggesting things I've come a cropper with!
>

Re: AW: AW: AW: Unable to find template

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
jido@respublica.fr wrote:
> 
> Velocity should be able to intercept the error and issue only a warning,
> because the missing file doesn't do any harm :D
>

I was thinking that as I wrote it, but once inside the engine, it can't
figure out if it is the 'default' value of the VM lib, or a user
specified one.  

Point noted - at least the message should look less scary.

geir

> -- Denis.
> 
> On Friday, June 15, 2001, at 01:10  pm, Geir Magnusson Jr. wrote:
> 
> > Reto Badertscher wrote:
> >>
> >> Hei Geir,
> >>
> >> after correction it seems ok - what about error using  VM library
> >> template
> >> VM_global_library.vm  is
> >> this needed?
> >
> > No - that is the default filename if you want to have Velocimacros
> > loaded at startup automatically so any template can use them.
> >
> > If the file isn't found, it squawks about it, but there is no harm done.
> >
> > geir
> >

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: AW: AW: AW: Unable to find template

Posted by ji...@respublica.fr.
Velocity should be able to intercept the error and issue only a warning, 
because the missing file doesn't do any harm :D

-- Denis.

On Friday, June 15, 2001, at 01:10  pm, Geir Magnusson Jr. wrote:

> Reto Badertscher wrote:
>>
>> Hei Geir,
>>
>> after correction it seems ok - what about error using  VM library 
>> template
>> VM_global_library.vm  is
>> this needed?
>
> No - that is the default filename if you want to have Velocimacros
> loaded at startup automatically so any template can use them.
>
> If the file isn't found, it squawks about it, but there is no harm done.
>
> geir
>

Re: AW: AW: AW: Unable to find template

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Reto Badertscher wrote:
> 
> Hei Geir,
> 
> after correction it seems ok - what about error using  VM library template
> VM_global_library.vm  is
> this needed?

No - that is the default filename if you want to have Velocimacros
loaded at startup automatically so any template can use them.

If the file isn't found, it squawks about it, but there is no harm done. 

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

AW: AW: AW: Unable to find template

Posted by Reto Badertscher <rb...@i-netsystems.com>.
Hei Geir,

after correction it seems ok - what about error using  VM library template
VM_global_library.vm  is
this needed?

Thanks again

Reto

Log after changes:
Fri Jun 15 14:01:28 CEST 2001 AvalonLogSystem initialized using logfile
c:\jakarta-tomcat\webapps\iFrameTest\velocity.log
Fri Jun 15 14:01:28 CEST 2001   [info]   [info] Default Properties File:
org\apache\velocity\runtime\defaults\velocity.properties
Fri Jun 15 14:01:28 CEST 2001   [info] Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
Fri Jun 15 14:01:28 CEST 2001   [info] FileResourceLoader : initialization
starting.
Fri Jun 15 14:01:28 CEST 2001   [info] FileResourceLoader : adding path
'c:/jakarta-tomcat/webapps/iFrameTest/templates'
Fri Jun 15 14:01:29 CEST 2001   [info] FileResourceLoader : initialization
complete.
Fri Jun 15 14:01:29 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Literal
Fri Jun 15 14:01:29 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Macro
Fri Jun 15 14:01:29 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Parse
Fri Jun 15 14:01:29 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Include
Fri Jun 15 14:01:29 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Foreach
Fri Jun 15 14:01:29 CEST 2001   [info] Created: 20 parsers.
Fri Jun 15 14:01:29 CEST 2001   [info] Velocimacro : initialization
starting.
Fri Jun 15 14:01:29 CEST 2001   [info] Velocimacro : adding VMs from VM
library template : VM_global_library.vm
Fri Jun 15 14:01:29 CEST 2001  [error] ResourceManager : unable to find
resource 'VM_global_library.vm' in any resource loader.
Fri Jun 15 14:01:29 CEST 2001   [info] Velocimacro : error using  VM library
template VM_global_library.vm :
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'VM_global_library.vm'
Fri Jun 15 14:01:29 CEST 2001   [info] Velocimacro : allowInline = true :
VMs can be defined inline in templates
Fri Jun 15 14:01:29 CEST 2001   [info] Velocimacro : allowInlineToOverride =
false : VMs defined inline may NOT replace previous VM definitions
Fri Jun 15 14:01:29 CEST 2001   [info] Velocimacro : allowInlineLocal =
false : VMs defined inline will be  global in scope if allowed.
Fri Jun 15 14:01:29 CEST 2001   [info] Velocimacro : messages on  : VM
system will output logging messages
Fri Jun 15 14:01:29 CEST 2001   [info] Velocimacro : initialization
complete.
Fri Jun 15 14:01:29 CEST 2001   [info] Velocity successfully started.
Fri Jun 15 14:01:29 CEST 2001   [info] ResourceManager : found sample1.vm
with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader


Re: AW: AW: Unable to find template

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Reto Badertscher wrote:
> 
> Thanks
> 
> i see the point, for my own stuff i'm working with getRealPath() - i
> wrongliy assumed that velocity did something similar (i had the same problem
> with the logfile).

It can't, and we don't want it to - because Velocity is not just for
servlets - if we did things like that internally, it would tie Velocity
to servlets too tightly.

Another easy way is to use the JarResourceLoader to load templates from
specific jars, or the ClasspathResourceLoader to automatically load from
jars in WEB-INF/lib (my favorite... no config...)
 
> About the default properties - they are stored in the jar file.
> I read the properties by my own (with getRealPath()).
> 

Good - some people mess with the defaults, and get into trouble - they
are there to guarantee a value for all parts of Velocity so it can come
up working if you don't specify any props yourself.


-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

AW: AW: Unable to find template

Posted by Reto Badertscher <rb...@i-netsystems.com>.
Thanks

i see the point, for my own stuff i'm working with getRealPath() - i
wrongliy assumed that velocity did something similar (i had the same problem
with the logfile).

About the default properties - they are stored in the jar file.
I read the properties by my own (with getRealPath()).

Thanks again

Reto

-----Ursprungliche Nachricht-----
Von: gmj@mta2.srv.hcvlny.cv.net [mailto:gmj@mta2.srv.hcvlny.cv.net]Im
Auftrag von Geir Magnusson Jr.
Gesendet: Freitag, 15. Juni 2001 13:28
An: velocity-user@jakarta.apache.org
Betreff: Re: AW: Unable to find template


Reto Badertscher wrote:
>
> Hello Geir,
>
> thanks for your response.
> 1) using velocity-1.1-rc2

Ok. good.

> 2) I'm using my servlet (controller) which invokes by a worker the sample1
> template. I'm overloading
>    loadConfiguration and return the properties to velocity.

Ah.

> I found out, that velocity takes as root
> - tomcat/bin when started Tomcat via startup.bat
> - kawa when started from within for debugging
>
> if managed to display sample1.vm with appropriate settings of loader path
> '../webapps/iFrameTest/templates' and started Tomcat directly. With
> 'iFrameTest/templates' the the template would not be found, even if it's
in
> WEB_INF/classes or WEB_INF/lib
> How do i manage that velocity takes the application context as root ?

Do you see what the default implementation of loadConfiguration does
when it uses getRealPath() to find the properties file?

The problem may be that when you fill the j.u.Properties with stuff to
return to VelocityServlet.init(), that you are using relative paths.
Velocity needs absolute paths.  So what I like to do is use
getRealPath() to turn the paths relative to my webroot into absolute
paths.

The example/servlet_example2/SampleServlet2.java shows how to do this.


> My logfile:
> Fri Jun 15 12:39:16 CEST 2001 AvalonLogSystem initialized using logfile
> C:\jakarta-tomcat\bin\..\webapps\iFrameTest\velocity.log

This is exactly what's happening - the paths are still relative, and you
are therefore setting everything relative to where you *start tomcat*.

> Fri Jun 15 12:39:16 CEST 2001   [info]   [info] Default Properties File:
> org\apache\velocity\runtime\defaults\velocity.properties

It also appears that it *can't* find the properties file - this is the
defaults that are included in the jar - they shouldn't be altered. Make
sure you do the getRealPath() technique as well.  Just see what the
default impl does, and SampleServlet2.java does.

> Fri Jun 15 12:39:16 CEST 2001   [info] Resource Loader Instantiated:
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Fri Jun 15 12:39:16 CEST 2001   [info] FileResourceLoader : initialization
> starting.
> Fri Jun 15 12:39:16 CEST 2001   [info] FileResourceLoader : adding path
> '../webapps/iFrameTest/templates'

I am not sure if you are hardwiring the property in your servlet, or
modified the in-jar props file...

But it appears that it's not using an external file...


geir

--
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!


Re: AW: Unable to find template

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Reto Badertscher wrote:
> 
> Hello Geir,
> 
> thanks for your response.
> 1) using velocity-1.1-rc2

Ok. good.

> 2) I'm using my servlet (controller) which invokes by a worker the sample1
> template. I'm overloading
>    loadConfiguration and return the properties to velocity.

Ah.  

> I found out, that velocity takes as root
> - tomcat/bin when started Tomcat via startup.bat
> - kawa when started from within for debugging
> 
> if managed to display sample1.vm with appropriate settings of loader path
> '../webapps/iFrameTest/templates' and started Tomcat directly. With
> 'iFrameTest/templates' the the template would not be found, even if it's in
> WEB_INF/classes or WEB_INF/lib
> How do i manage that velocity takes the application context as root ?

Do you see what the default implementation of loadConfiguration does
when it uses getRealPath() to find the properties file?  

The problem may be that when you fill the j.u.Properties with stuff to
return to VelocityServlet.init(), that you are using relative paths. 
Velocity needs absolute paths.  So what I like to do is use
getRealPath() to turn the paths relative to my webroot into absolute
paths.

The example/servlet_example2/SampleServlet2.java shows how to do this.

 
> My logfile:
> Fri Jun 15 12:39:16 CEST 2001 AvalonLogSystem initialized using logfile
> C:\jakarta-tomcat\bin\..\webapps\iFrameTest\velocity.log

This is exactly what's happening - the paths are still relative, and you
are therefore setting everything relative to where you *start tomcat*.

> Fri Jun 15 12:39:16 CEST 2001   [info]   [info] Default Properties File:
> org\apache\velocity\runtime\defaults\velocity.properties

It also appears that it *can't* find the properties file - this is the
defaults that are included in the jar - they shouldn't be altered. Make
sure you do the getRealPath() technique as well.  Just see what the
default impl does, and SampleServlet2.java does.

> Fri Jun 15 12:39:16 CEST 2001   [info] Resource Loader Instantiated:
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Fri Jun 15 12:39:16 CEST 2001   [info] FileResourceLoader : initialization
> starting.
> Fri Jun 15 12:39:16 CEST 2001   [info] FileResourceLoader : adding path
> '../webapps/iFrameTest/templates'

I am not sure if you are hardwiring the property in your servlet, or
modified the in-jar props file...

But it appears that it's not using an external file...


geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

AW: Unable to find template

Posted by Reto Badertscher <rb...@i-netsystems.com>.
Hello Geir,

thanks for your response.
1) using velocity-1.1-rc2
2) I'm using my servlet (controller) which invokes by a worker the sample1
template. I'm overloading
   loadConfiguration and return the properties to velocity.

I found out, that velocity takes as root
- tomcat/bin when started Tomcat via startup.bat
- kawa when started from within for debugging

if managed to display sample1.vm with appropriate settings of loader path
'../webapps/iFrameTest/templates' and started Tomcat directly. With
'iFrameTest/templates' the the template would not be found, even if it's in
WEB_INF/classes or WEB_INF/lib
How do i manage that velocity takes the application context as root ?

My logfile:
Fri Jun 15 12:39:16 CEST 2001 AvalonLogSystem initialized using logfile
C:\jakarta-tomcat\bin\..\webapps\iFrameTest\velocity.log
Fri Jun 15 12:39:16 CEST 2001   [info]   [info] Default Properties File:
org\apache\velocity\runtime\defaults\velocity.properties
Fri Jun 15 12:39:16 CEST 2001   [info] Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
Fri Jun 15 12:39:16 CEST 2001   [info] FileResourceLoader : initialization
starting.
Fri Jun 15 12:39:16 CEST 2001   [info] FileResourceLoader : adding path
'../webapps/iFrameTest/templates'
Fri Jun 15 12:39:16 CEST 2001   [info] FileResourceLoader : initialization
complete.
Fri Jun 15 12:39:16 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Literal
Fri Jun 15 12:39:16 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Macro
Fri Jun 15 12:39:16 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Parse
Fri Jun 15 12:39:16 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Include
Fri Jun 15 12:39:16 CEST 2001   [info] Loaded Pluggable Directive:
org.apache.velocity.runtime.directive.Foreach
Fri Jun 15 12:39:16 CEST 2001   [info] Created: 20 parsers.
Fri Jun 15 12:39:16 CEST 2001   [info] Velocimacro : initialization
starting.
Fri Jun 15 12:39:16 CEST 2001   [info] Velocimacro : adding VMs from VM
library template : VM_global_library.vm
Fri Jun 15 12:39:16 CEST 2001  [error] ResourceManager : unable to find
resource 'VM_global_library.vm' in any resource loader.
Fri Jun 15 12:39:16 CEST 2001   [info] Velocimacro : error using  VM library
template VM_global_library.vm :
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'VM_global_library.vm'
Fri Jun 15 12:39:16 CEST 2001   [info] Velocimacro : allowInline = true :
VMs can be defined inline in templates
Fri Jun 15 12:39:16 CEST 2001   [info] Velocimacro : allowInlineToOverride =
false : VMs defined inline may NOT replace previous VM definitions
Fri Jun 15 12:39:16 CEST 2001   [info] Velocimacro : allowInlineLocal =
false : VMs defined inline will be  global in scope if allowed.
Fri Jun 15 12:39:16 CEST 2001   [info] Velocimacro : messages on  : VM
system will output logging messages
Fri Jun 15 12:39:16 CEST 2001   [info] Velocimacro : initialization
complete.
Fri Jun 15 12:39:16 CEST 2001   [info] Velocity successfully started.
Fri Jun 15 12:39:16 CEST 2001   [info] ResourceManager : found sample1.vm
with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader
Fri Jun 15 12:40:31 CEST 2001   [info] ResourceManager : found sample1.vm
with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader
Fri Jun 15 12:40:34 CEST 2001   [info] ResourceManager : found sample1.vm
with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader

Thanks for your help

Reto

-----Ursprungliche Nachricht-----
Von: gmj@mta2.srv.hcvlny.cv.net [mailto:gmj@mta2.srv.hcvlny.cv.net]Im
Auftrag von Geir Magnusson Jr.
Gesendet: Freitag, 15. Juni 2001 11:59
An: velocity-user@jakarta.apache.org
Betreff: Re: Unabel to find template


Heh - you cut off the critical part of the log - the top.  That would
tell us what the template path is set to.  Along with that it would help
to have

1) what version of velocity
2) what you are using as your servlet - are you using the sample servlet
found in examples/servlet_example1, or examples/servlet_example2?

servlet_example2 should be autoconfiguring in tomcat 3.2 - you just
start things up and it will setup the webapp root in the template
path...

I am sure this is all it is...

geir

Reto Badertscher wrote:
>
> Just included velocity into my own framework. All works ok, but when it's
> time to render a template (I'm trying with the sample1) i just get:
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : adding VMs from VM
> library template : VM_global_library.vm
> Thu Jun 14 23:29:48 CEST 2001  [error] ResourceManager : unable to find
> resource 'VM_global_library.vm' in any resource loader.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : error using  VM
library
> template VM_global_library.vm :
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'VM_global_library.vm'
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInline = true :
> VMs can be defined inline in templates
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInlineToOverride
=
> false : VMs defined inline may NOT replace previous VM definitions
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInlineLocal =
> false : VMs defined inline will be  global in scope if allowed.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : messages on  : VM
> system will output logging messages
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : initialization
> complete.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocity successfully started.
> Thu Jun 14 23:29:57 CEST 2001  [error] ResourceManager : unable to find
> resource 'sample1.vm' in any resource loader.
>
> I'm using Tomcat 3.2.
> I put my template in the following locations webapps\iFrameTest,
> webapps\iFrameTest\lib, webapps\iFrameTest\classes without any success
(teh
> template is correctly spelled).
> BTW: I would like to see the locations in log where velocity tries to find
> the template.
> The velocity jar is in webapps\iFrameTest\lib with the following settings:
>
> resource.loader = file
>
> file.resource.loader.description = Velocity File Resource Loader
> file.resource.loader.class =
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> file.resource.loader.path = .
> file.resource.loader.cache = false
> file.resource.loader.modificationCheckInterval = 2
>
> Thanks in advance for any help.
>
> i[net-systems
> i-netsystems gmbh
> Seestr. 325
> CH-8035 Zuerich
> Switzerland

--
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!


Re: Unabel to find template

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Heh - you cut off the critical part of the log - the top.  That would
tell us what the template path is set to.  Along with that it would help
to have

1) what version of velocity
2) what you are using as your servlet - are you using the sample servlet
found in examples/servlet_example1, or examples/servlet_example2?

servlet_example2 should be autoconfiguring in tomcat 3.2 - you just
start things up and it will setup the webapp root in the template
path...

I am sure this is all it is...

geir

Reto Badertscher wrote:
> 
> Just included velocity into my own framework. All works ok, but when it's
> time to render a template (I'm trying with the sample1) i just get:
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : adding VMs from VM
> library template : VM_global_library.vm
> Thu Jun 14 23:29:48 CEST 2001  [error] ResourceManager : unable to find
> resource 'VM_global_library.vm' in any resource loader.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : error using  VM library
> template VM_global_library.vm :
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'VM_global_library.vm'
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInline = true :
> VMs can be defined inline in templates
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInlineToOverride =
> false : VMs defined inline may NOT replace previous VM definitions
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInlineLocal =
> false : VMs defined inline will be  global in scope if allowed.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : messages on  : VM
> system will output logging messages
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : initialization
> complete.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocity successfully started.
> Thu Jun 14 23:29:57 CEST 2001  [error] ResourceManager : unable to find
> resource 'sample1.vm' in any resource loader.
> 
> I'm using Tomcat 3.2.
> I put my template in the following locations webapps\iFrameTest,
> webapps\iFrameTest\lib, webapps\iFrameTest\classes without any success (teh
> template is correctly spelled).
> BTW: I would like to see the locations in log where velocity tries to find
> the template.
> The velocity jar is in webapps\iFrameTest\lib with the following settings:
> 
> resource.loader = file
> 
> file.resource.loader.description = Velocity File Resource Loader
> file.resource.loader.class =
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> file.resource.loader.path = .
> file.resource.loader.cache = false
> file.resource.loader.modificationCheckInterval = 2
> 
> Thanks in advance for any help.
> 
> i[net-systems
> i-netsystems gmbh
> Seestr. 325
> CH-8035 Zuerich
> Switzerland

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: Unabel to find template

Posted by Keith Vance <kv...@n-link.net>.

-- 
K E I T H  V A N C E
Software Engineer
n-Link Corporation

On Fri, 15 Jun 2001, Reto Badertscher wrote:

> Just included velocity into my own framework. All works ok, but when it's
> time to render a template (I'm trying with the sample1) i just get:
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : adding VMs from VM
> library template : VM_global_library.vm
> Thu Jun 14 23:29:48 CEST 2001  [error] ResourceManager : unable to find
> resource 'VM_global_library.vm' in any resource loader.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : error using  VM library
> template VM_global_library.vm :
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'VM_global_library.vm'
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInline = true :
> VMs can be defined inline in templates
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInlineToOverride =
> false: VMs defined inline may NOT replace previous VM definitions
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : allowInlineLocal =
> false: VMs defined inline will be  global in scope if allowed.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : messages on  : VM
> system will output logging messages
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocimacro : initialization
> complete.
> Thu Jun 14 23:29:48 CEST 2001   [info] Velocity successfully started.
> Thu Jun 14 23:29:57 CEST 2001  [error] ResourceManager : unable to find
> resource 'sample1.vm' in any resource loader.
>
> I'm using Tomcat 3.2.
> I put my template in the following locations webapps\iFrameTest,
> webapps\iFrameTest\lib, webapps\iFrameTest\classes without any success (teh
> template is correctly spelled).
> BTW: I would like to see the locations in log where velocity tries to find
> the template.
> The velocity jar is in webapps\iFrameTest\lib with the following settings:
>
> resource.loader = file
>
> file.resource.loader.description = Velocity File Resource Loader
> file.resource.loader.class =
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> file.resource.loader.path = .

I think this is your error. You don't seem to be putting your templates in
"." but rather in "lib".


> file.resource.loader.cache = false
> file.resource.loader.modificationCheckInterval = 2
>
> Thanks in advance for any help.
>
> i[net-systems
> i-netsystems gmbh
> Seestr. 325
> CH-8035 Zuerich
> Switzerland
>
>


Re: re-initialize velocity.

Posted by Nick Bauman <ni...@cortexity.com>.
We have an init() method for our component-based system to reload its
components and reread it's config. You can trigger it from a secure XML-RPC
call. One of our components uses Velocity and it would be nice to be able to
reconfigure the Velocity engine in that component this way. Without the
reset(), we have to bring down the system and bring it back up again.

> On Fri, 15 Jun 2001, Geir Magnusson Jr. wrote:
> 
>> Andreas Wikberger wrote:
>> >
>> > Hello,
>> >
>> > We are using velocity as a template-engine in a publishing system
>> > with a lots of different components. Velocity is one of many
>> > services in our system.
>> >
>> > What we want to do is to re-initialize/restart velocity without
>> > having to restart the hole system, that is to be able to use the
>> > system with the other services as they are configured and only
>> > restart the velocity service with a new configuration. From what I
>> > have seen/tested it seems impossible to do this because that
>> > Runtime.init() always checks the initialized boolean if it is to be
>> > initialized or not. And I have not found any way to set that boolean
>> > so the Runtime.init() will initialize.
>> >
>> > Is there any possibilities to make a re-initialize of velocity?
>>
>> It's possible.   We could add a reset() method that tosses everything,
>> and then you do the whole init cycle over.
>>
>> geir
> 
> Sounds good. In a future release then?
> 
> Andreas Wikberger
> S p i r o   k o m m u n i k a t i o n   A B
> 
> Stena Center 1C
> 412 92  Göteborg
> phone +46 (0)31 - 772 80 73
> mobile +46 (0)705 - 18 77 48
> andreas@spiro.se
> www.spiro.se


-- 
Nick Bauman
Software Engineer
3600 Dupont
Minneapolis, MN
55412
Mobile Phone: (612) 810-7406
Home Phone: (612) 522-0165


Re: re-initialize velocity.

Posted by Andreas Wikberger <an...@blink.se>.
On Fri, 15 Jun 2001, Geir Magnusson Jr. wrote:

> Andreas Wikberger wrote:
> >
> > Hello,
> >
> > We are using velocity as a template-engine in a publishing system with a
> > lots of different components. Velocity is one of many services in our
> > system.
> >
> > What we want to do is to re-initialize/restart velocity without having to
> > restart the hole system, that is to be able to use the system with the
> > other services as they are configured and only restart the velocity
> > service with a new configuration. From what I have seen/tested it seems
> > impossible to do this because that Runtime.init() always checks the initialized
> > boolean if it is to be initialized or not. And I have not found any way to
> > set that boolean so the Runtime.init() will initialize.
> >
> > Is there any possibilities to make a re-initialize of velocity?
>
> It's possible.   We could add a reset() method that tosses everything,
> and then you do the whole init cycle over.
>
> geir

Sounds good. In a future release then?

Andreas Wikberger
S p i r o   k o m m u n i k a t i o n   A B

Stena Center 1C
412 92  Göteborg
phone +46 (0)31 - 772 80 73
mobile +46 (0)705 - 18 77 48
andreas@spiro.se
www.spiro.se



Re: re-initialize velocity.

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Andreas Wikberger wrote:
> 
> Hello,
> 
> We are using velocity as a template-engine in a publishing system with a
> lots of different components. Velocity is one of many services in our
> system.
> 
> What we want to do is to re-initialize/restart velocity without having to
> restart the hole system, that is to be able to use the system with the
> other services as they are configured and only restart the velocity
> service with a new configuration. From what I have seen/tested it seems
> impossible to do this because that Runtime.init() always checks the initialized
> boolean if it is to be initialized or not. And I have not found any way to
> set that boolean so the Runtime.init() will initialize.
> 
> Is there any possibilities to make a re-initialize of velocity?

It's possible.   We could add a reset() method that tosses everything,
and then you do the whole init cycle over.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

re-initialize velocity.

Posted by Andreas Wikberger <an...@blink.se>.
Hello,

We are using velocity as a template-engine in a publishing system with a
lots of different components. Velocity is one of many services in our
system.

What we want to do is to re-initialize/restart velocity without having to
restart the hole system, that is to be able to use the system with the
other services as they are configured and only restart the velocity
service with a new configuration. From what I have seen/tested it seems
impossible to do this because that Runtime.init() always checks the initialized
boolean if it is to be initialized or not. And I have not found any way to
set that boolean so the Runtime.init() will initialize.

Is there any possibilities to make a re-initialize of velocity?

Andreas Wikberger
S p i r o   k o m m u n i k a t i o n   A B

Stena Center 1C
412 92  Göteborg
phone +46 (0)31 - 772 80 73
mobile +46 (0)705 - 18 77 48
andreas@spiro.se
www.spiro.se