You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Larry Siden <ls...@gmail.com> on 2004/11/09 22:43:45 UTC

ant DVSL task can't find VM_global_library.vm

I have written the following ant task (a few paths have been replaced
by ellipses):

<project ...>
        ...
	<taskdef name="dvsl" classname="org.apache.tools.dvsl.DVSLTask">
		<classpath>
			<fileset dir="${lib.dir}">
				<include name="velocity-dvsl-*.jar" />
				<include name="velocity-dep-*.jar" />
				<include name="dom4j-*.jar" />
			</fileset>
		</classpath>
	</taskdef>

	<property name="dvsl.toolbox.classpath" location="..." />

	<target name="svjp-general.html">
		<exec command="pwd"/>
		<delete file="${target.dir}/svjp-ui-tabbed.html" quiet="true"
failonerror="false" />
		<dvsl basedir="."
			in="${target.dir}/svjp-ui-tabbed.xml" 
			out="${target.dir}/svjp-ui-tabbed.html" 
			style="${target.dir}/svjp-ui-tabbed.dvsl" 
			toolboxfile="${target.dir}/toolbox.properties"
			classpath="${dvsl.toolbox.classpath}">
			<velconfig name="velocimacro.library" 
value="${basedir}\veltemplate\VM_global_library.vm"/>
		</dvsl>
	</target>
...
</project>

Giving this to ant -v ... yields the following log:

pache Ant version 1.6.1 compiled on February 12 2004
Buildfile: C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\build.xml
parsing buildfile
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\build.xml
with URI = file:///C:/Views/lsiden_view_2/sdm_svc/SDMservices/GKN/Phase2/DeveloperRepository/SvJP/UI/build.xml
Project base dir set to:
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository
Build sequence for target `svjp-general.html' is [svjp-general.html]
Complete build sequence is [svjp-general.html, ]
svjp-general.html:
     [exec] The command attribute is deprecated. Please use the
executable attribute and nested arg elements.
     [exec] Current OS is Windows 2000
     [exec] Executing 'pwd' with
     [exec] C:/Views/lsiden_view_2/sdm_svc/SDMservices/GKN/Phase2/DeveloperRepository
   [delete] Deleting:
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\svjp-ui-tabbed.html
     [dvsl] Loading stylesheet
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\svjp-ui-tabbed.dvsl
     [dvsl] [info]
**************************************************************
     [dvsl] [info] Starting Jakarta Velocity v1.3.1-rc2
     [dvsl] [info] RuntimeInstance initializing.
     [dvsl] [info] Default Properties File:
org\apache\velocity\runtime\defaults\velocity.properties
     [dvsl] [info] Default ResourceManager initializing. (class
org.apache.velocity.runtime.resource.ResourceManagerImpl)
     [dvsl] [info] Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
     [dvsl] [info] FileResourceLoader : initialization starting.
     [dvsl] [info] FileResourceLoader : adding path '.'
     [dvsl] [info] FileResourceLoader : initialization complete.
     [dvsl] [info] ResourceCache : initialized. (class
org.apache.velocity.runtime.resource.ResourceCacheImpl)
     [dvsl] [info] Default ResourceManager initialization complete.
     [dvsl] [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Literal
     [dvsl] [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Macro
     [dvsl] [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Parse
     [dvsl] [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Include
     [dvsl] [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Foreach
     [dvsl] [info] Loaded User Directive:
org.apache.tools.dvsl.directive.MatchDirective
     [dvsl] [info] Created: 20 parsers.
     [dvsl] [info] Velocimacro : initialization starting.
     [dvsl] [info] Velocimacro : adding VMs from VM library template :
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm
     [dvsl] [error] ResourceManager : unable to find resource
'C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm'
in any resource loader.
     [dvsl] [info] Velocimacro : error using  VM library template
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm
: org.apache.velocity.exception.ResourceNotFoundException: Unable to
find resource 'C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm'
     [dvsl] [info] Velocimacro :  VM library template macro
registration complete.
     [dvsl] [info] Velocimacro : allowInline = true : VMs can be
defined inline in templates
     [dvsl] [info] Velocimacro : allowInlineToOverride = false : VMs
defined inline may NOT replace previous VM definitions
     [dvsl] [info] Velocimacro : allowInlineLocal = false : VMs
defined inline will be  global in scope if allowed.
     [dvsl] [info] Velocimacro : messages on  : VM system will output
logging messages
     [dvsl] [info] Velocimacro : autoload off  : VM system will not
automatically reload global library macros
     [dvsl] [info] Velocimacro : initialization complete.
     [dvsl] [info] Velocity successfully started.
     [dvsl] Processing
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\svjp-ui-tabbed.xml
to C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\svjp-ui-tabbed.html
     [dvsl] Processed
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\svjp-ui-tabbed.xml
in 47 ms.
BUILD SUCCESSFUL
Total time: 1 second

In particular:
C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm
: org.apache.velocity.exception.ResourceNotFoundException: Unable to
find resource

However, this is exactly where VM_global_library.vm is found on my
system!  What am I missing?

FYI: I am using velocity-dvsl-0.45.jar and velocity-dep-1.3.1-rc2.jar.
 I tried upgrading to velocity-dep-1.4.jar but it didn't make any
difference.

I have searched this list for any threads pertaining to this but did
not find any answers specific to my problem.  All of the other
complaints seemed to be about the error message alone, because they
weren't making any use of VM_global_library.vm.  I did a general
Google search as well but found scant little to add to this.

Any help or insight will be appreciated.

-- 
Larry Siden
http://umich.edu/~lsiden/

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


Re: ant DVSL task can't find VM_global_library.vm

Posted by Larry Siden <ls...@gmail.com>.
That worked!  Thank you so much, Shinobu.

I was wondering what the "basedir" attribute was doing in the <dvsl>
tag.  It didn't seem to have any effect on the "in", "out", or "style"
attributes, which is what I originally thought it was for.

On Wed, 10 Nov 2004 14:13:11 +0900, Shinobu Kawai
<sh...@gmail.com> wrote:
> 
> Hi Larry,
> 
> Took a closer look at the log.
> 
> > Buildfile: C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\build.xml
> I see your current directory != ${basedir}.
> 
> ## snip
> 
> > Project base dir set to:
> > C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository
> 
> ## snip
> 
> >      [dvsl] [info] Resource Loader Instantiated:
> > org.apache.velocity.runtime.resource.loader.FileResourceLoader
> >      [dvsl] [info] FileResourceLoader : initialization starting.
> >      [dvsl] [info] FileResourceLoader : adding path '.'
> >      [dvsl] [info] FileResourceLoader : initialization complete.
> Here's where the resources will be searched.
> 
> Try this:
> >       <dvsl basedir="."
> >           in="${target.dir}/svjp-ui-tabbed.xml"
> >           out="${target.dir}/svjp-ui-tabbed.html"
> >           style="${target.dir}/svjp-ui-tabbed.dvsl"
> >           toolboxfile="${target.dir}/toolbox.properties"
> >           classpath="${dvsl.toolbox.classpath}">
>           <velconfig name="file.resource.loader.path" value="${basedir}"/>
>           <velconfig name="velocimacro.library" value="/veltemplate/VM_global_library.vm"/>
> >       </dvsl>
> This will force the FileResourceLoader to look under ${basedir}.
> 
> I think it should work.
> 
> 
> 
> Best regards,
> -- Shinobu Kawai
> 
> --
> Shinobu Kawai <sh...@gmail.com>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 


-- 
Larry Siden
http://umich.edu/~lsiden/

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


Re: ant DVSL task can't find VM_global_library.vm

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Larry,

Took a closer look at the log.

> Buildfile: C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\SvJP\UI\build.xml
I see your current directory != ${basedir}.

## snip

> Project base dir set to:
> C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository

## snip

>      [dvsl] [info] Resource Loader Instantiated:
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
>      [dvsl] [info] FileResourceLoader : initialization starting.
>      [dvsl] [info] FileResourceLoader : adding path '.'
>      [dvsl] [info] FileResourceLoader : initialization complete.
Here's where the resources will be searched.


Try this:
>       <dvsl basedir="."
>           in="${target.dir}/svjp-ui-tabbed.xml" 
>           out="${target.dir}/svjp-ui-tabbed.html" 
>           style="${target.dir}/svjp-ui-tabbed.dvsl" 
>           toolboxfile="${target.dir}/toolbox.properties"
>           classpath="${dvsl.toolbox.classpath}">
          <velconfig name="file.resource.loader.path" value="${basedir}"/>
          <velconfig name="velocimacro.library" value="/veltemplate/VM_global_library.vm"/>
>       </dvsl>
This will force the FileResourceLoader to look under ${basedir}.

I think it should work.

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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


Re: ant DVSL task can't find VM_global_library.vm

Posted by Larry Siden <ls...@gmail.com>.
> One more thing.  Are you calling Ant from
> C:\Views\...\DeveloperRepository?

Yes.  I chose to call it from there because VM_global_lib is in a dir
whose path is above that were the template is found.  It wouldn't
allow me to use a relative path starting with "..".  It seems to think
that that is somehow a security breach (I don't remember the exact
message).  In fact, the only thing that works is to put VM_global_lib
in the same dir with the template and not try to mess with
velocimacro.library at all.  However, my purpose was to share
VM_global_library.vm among several components of a large project.  So
I wanted it to go in a common dir.

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


Re: ant DVSL task can't find VM_global_library.vm

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Larry,

Some clarifications.  :)

> I'm a bit confused by that statement, because an absolute path (e.g.
> C:\...) should resolve to the same resource regardless of the current
> directory.  In any case, the error message " [dvsl] [error]
> ResourceManager : unable to find resource
> 'C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm'
> in any resource loader." shows clearly what the ResourceManager was looking for.
One misunderstanding:  the FileResourceLoader can only find resources via
relative paths.  It doesn't deal with absolute paths.

The error message is saying, the _resource_ "C:\Views\...library.vm" was
not found.  Not the _file_.  If your current directory was
"C:\Views\...\DeveloperRepository", the FileResourceLoader will be
actually looking for:
    C:\Views\...\DeveloperRepository\C:\Views\...library.vm
## Okay, so it wouldn't even work if your current directory was C:\

> FWIW, I think I already tried converting the '\' to '/' AND tried it
> both with and without the ${basedir}/ appended, but I'll give both
> another shot when I get into work tomorrow.
One more thing.  Are you calling Ant from
C:\Views\...\DeveloperRepository?

Of course, I'm just guessing about DVSL, but I know all this is true
about Velocity.  B)

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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


Re: ant DVSL task can't find VM_global_library.vm

Posted by Larry Siden <ls...@gmail.com>.
> ${basedir}\... is converted to the absolute path in the file system, so
> the specified resource can only be found if the current directory was
> the root (C:\).

I'm a bit confused by that statement, because an absolute path (e.g.
C:\...) should resolve to the same resource regardless of the current
directory.  In any case, the error message " [dvsl] [error]
ResourceManager : unable to find resource
'C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm'
in any resource loader." shows clearly what the ResourceManager was looking for.

FWIW, I think I already tried converting the '\' to '/' AND tried it
both with and without the ${basedir}/ appended, but I'll give both
another shot when I get into work tomorrow.

Appreciate your help.

On Wed, 10 Nov 2004 12:21:10 +0900, Shinobu Kawai
<sh...@gmail.com> wrote:
> 
> Hi Larry,
> 
> I'm new to DVSL, so I'm making a lot of guesses here.  ;)
> 
> 
> 
> >               <dvsl basedir="."
> >                       in="${target.dir}/svjp-ui-tabbed.xml"
> >                       out="${target.dir}/svjp-ui-tabbed.html"
> >                       style="${target.dir}/svjp-ui-tabbed.dvsl"
> >                       toolboxfile="${target.dir}/toolbox.properties"
> >                       classpath="${dvsl.toolbox.classpath}">
> >                       <velconfig name="velocimacro.library"
> > value="${basedir}\veltemplate\VM_global_library.vm"/>
> >               </dvsl>
> 
> > In particular:
> > C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm
> > : org.apache.velocity.exception.ResourceNotFoundException: Unable to
> > find resource
> >
> > However, this is exactly where VM_global_library.vm is found on my
> > system!  What am I missing?
> First, Velocity, by default, uses the FileResourceLoader with the
> current path as the template root.
>     http://jakarta.apache.org/velocity/developer-guide.html#Configuring%20Resource%20Loaders
>     http://jakarta.apache.org/velocity/api/org/apache/velocity/runtime/resource/loader/FileResourceLoader.html
> 
> The Velocimacro libraries are also resources, loaded by
> VelocimacroFactory.
>     http://jakarta.apache.org/velocity/api/org/apache/velocity/runtime/VelocimacroFactory.html#initVelocimacro()
> 
> ${basedir}\... is converted to the absolute path in the file system, so
> the specified resource can only be found if the current directory was
> the root (C:\).
> 
> Try removing the "${basedir}\" part, and see what happens.  If my
> assumptions are correct (and if ${basedir} == current dir),  it should
> work.
> 
> 
> 
> Best regards,
> -- Shinobu Kawai
> 
> --
> Shinobu Kawai <sh...@gmail.com>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 


-- 
Larry Siden
http://umich.edu/~lsiden/

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


Re: ant DVSL task can't find VM_global_library.vm

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Larry,

I'm new to DVSL, so I'm making a lot of guesses here.  ;)

> 		<dvsl basedir="."
> 			in="${target.dir}/svjp-ui-tabbed.xml" 
> 			out="${target.dir}/svjp-ui-tabbed.html" 
> 			style="${target.dir}/svjp-ui-tabbed.dvsl" 
> 			toolboxfile="${target.dir}/toolbox.properties"
> 			classpath="${dvsl.toolbox.classpath}">
> 			<velconfig name="velocimacro.library" 
> value="${basedir}\veltemplate\VM_global_library.vm"/>
> 		</dvsl>

> In particular:
> C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm
> : org.apache.velocity.exception.ResourceNotFoundException: Unable to
> find resource
> 
> However, this is exactly where VM_global_library.vm is found on my
> system!  What am I missing?
First, Velocity, by default, uses the FileResourceLoader with the
current path as the template root.
    http://jakarta.apache.org/velocity/developer-guide.html#Configuring%20Resource%20Loaders
    http://jakarta.apache.org/velocity/api/org/apache/velocity/runtime/resource/loader/FileResourceLoader.html

The Velocimacro libraries are also resources, loaded by
VelocimacroFactory.
    http://jakarta.apache.org/velocity/api/org/apache/velocity/runtime/VelocimacroFactory.html#initVelocimacro()

${basedir}\... is converted to the absolute path in the file system, so
the specified resource can only be found if the current directory was
the root (C:\).

Try removing the "${basedir}\" part, and see what happens.  If my
assumptions are correct (and if ${basedir} == current dir),  it should
work.

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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


Re: ant DVSL task can't find VM_global_library.vm

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Claude,

> Not sure it is related, but I already had problems with backslashes and
> ant : the same build was working on linux, but not on windows...
I think you can replace them with forward slashes.  Not that I tried,
but java.io.File itself handles file separators quite gracefully.

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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


Re: ant DVSL task can't find VM_global_library.vm

Posted by Claude Brisson <cl...@savoirweb.com>.
On Tue, 2004-11-09 at 22:43, Larry Siden wrote:
> I have written the following ant task 
[...]
> In particular:
> C:\Views\lsiden_view_2\sdm_svc\SDMservices\GKN\Phase2\DeveloperRepository\veltemplate\VM_global_library.vm
> : org.apache.velocity.exception.ResourceNotFoundException: Unable to
> find resource
> 
> However, this is exactly where VM_global_library.vm is found on my
> system!  What am I missing?

Not sure it is related, but I already had problems with backslashes and
ant : the same build was working on linux, but not on windows...

Update ant and try again ?

Claude



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