Based on a 9 horse shoe review, I bought Pro Jakarta Velocity. I have just started the book and I am having troubles with the first example program. It is the Velocity version of the famous "Hello World" program. The code is this:
It compiles, but when I run it I get the following message: -> java org.novaworks.ch02.HelloWorld Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'src/templates/ch02/HelloWorld.vm' at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:458) at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:341) at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:831) at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:813) at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:285) at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:469) at org.novaworks.ch02.HelloWorld.main(Unknown Source) ->
It appears that the program is unable to find the template.
Unfortunately, I am at a loss as to how to solve the problem. Any insight and help would be greatly appreciated.
What directory are you running your java command from?
It sounds like it is expecting you to run that from the pro-jakarta-velocity directory. I'm assuming you downloaded the sample code or you put the hello world template where the code is looking for it: "src/templates/ch02/HelloWorld.vm".
It sounds like it needs to be able to find that path from the place you run the java command. If that doesn't work, is the dir containing the src dir on the classpath?
I downloaded the sample chapter and it says about the template, "Save this file to a location where it will be accessible from your code." Not very helpful.
Joined: Oct 10, 2000
Actually I didn't feel like messing with setting up the classpath to get the ch 2 hello world to run on the command line so I put this into the build.xml that comes in the sample code