velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sasasamamama <sasasamam...@ya.ru>
Subject ResourceNotFoundException in IntelliJ IDEA
Date Mon, 21 Mar 2011 20:44:21 GMT

Hi,

I have a Velocity template ValueTmpl.vm which can't be found by the Velocity
ResourceManager. A minimal example:


package generate;

import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;

public class Generate {
    public static void main(String[] args) throws Exception {
        VelocityContext context = new VelocityContext();
        context.put("key", "value");
        Writer writer = new FileWriter(new File("Result.java"));
        createTemplate("generate/templates/ValueTmpl.vm").merge(context,
writer);
        writer.close();
    }

    private static Template createTemplate(String vmTemplateFile) {
        VelocityEngine ve = new VelocityEngine();
        ve.setProperty(Velocity.RESOURCE_LOADER, "class");
        ve.setProperty("class.resource.loader.class",
               
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        ve.init();
        return ve.getTemplate(vmTemplateFile);
    }
}


The generate folder is in the root of the src directory. I get the following
error:


21.03.2011 13:09:01 org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource
'generate/templates/ValueTmpl.vm' in any resource loader.
Exception in thread "main"
org.apache.velocity.exception.ResourceNotFoundException


Does someone know what the problem can be? Should I change something in the
project settings?

Thanks in advance!


(I am sorry if this is the second time you get this message -- seems like
the last one failed to be sent)
-- 
View this message in context: http://old.nabble.com/ResourceNotFoundException-in-IntelliJ-IDEA-tp31202777p31202777.html
Sent from the Velocity - User mailing list archive at Nabble.com.


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


Mime
View raw message