velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Cortez <...@jimcortez.com>
Subject Velocity File Resource Path Loading Problem
Date Tue, 21 Jul 2009 04:48:08 GMT
Hello all,
    I am working on a small MVC framework that runs on top of iJetty (a 
Jetty port fot the Android platform). I am having trouble during 
initialization of Velocity. Take a peek at the following code:

====
Log.info("Setting Template Directory: "+Configuration.VIEWS_LOC);
File viewsFolder = new File(Configuration.VIEWS_LOC);
if(!viewsFolder.exists() || !viewsFolder.canRead()){
    success=false;
    Log.warn("Folder "+Configuration.VIEWS_LOC+" does not exist, or 
unreachable!");
} else {
    Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, 
Configuration.VIEWS_LOC);
    Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, 
"ConciergeVelocityLogger");
    try {
        Velocity.init();
    } catch (Exception e) {
        Log.warn("Error initializing Velocity: "+e.getMessage());
        e.printStackTrace();
        success = false;
    }
}
====

That code should show that the templates directory both exists and is 
readable. Here is the output of the error log:

====
I/Jetty   (  709): Setting Template Directory: 
/sdcard/jetty/webapps/concierge/WEB-INF/views
W/Jetty   (  709): Error initializing Velocity: null
W/System.err(  709): java.lang.NullPointerException
W/System.err(  709):    at java.io.Reader.<init>(Reader.java:72)
W/System.err(  709):    at 
java.io.InputStreamReader.<init>(InputStreamReader.java:96)
W/System.err(  709):    at 
org.apache.commons.collections.ExtendedProperties.load(ExtendedProperties.java:543)
W/System.err(  709):    at 
org.apache.commons.collections.ExtendedProperties.load(ExtendedProperties.java:519)
W/System.err(  709):    at 
org.apache.velocity.runtime.RuntimeInstance.setDefaultProperties(RuntimeInstance.java:397)
W/System.err(  709):    at 
org.apache.velocity.runtime.RuntimeInstance.initializeProperties(RuntimeInstance.java:570)
W/System.err(  709):    at 
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:249)
W/System.err(  709):    at 
org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:114)
W/System.err(  709):    at 
org.apache.velocity.app.Velocity.init(Velocity.java:79)
W/System.err(  709):    at 
org.concierge.lib.Configurator.initialize(Configurator.java:34)
W/System.err(  709):    at 
org.concierge.lib.DispatchServlet.doGet(DispatchServlet.java:25)
W/System.err(  709):    at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
W/System.err(  709):    at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
W/System.err(  709):    at 
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
W/System.err(  709):    at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
W/System.err(  709):    at 
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
W/System.err(  709):    at 
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
W/System.err(  709):    at 
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
W/System.err(  709):    at 
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
W/System.err(  709):    at 
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
W/System.err(  709):    at 
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
W/System.err(  709):    at 
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
W/System.err(  709):    at org.mortbay.jetty.Server.handle(Server.java:320)
W/System.err(  709):    at 
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
W/System.err(  709):    at 
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
W/System.err(  709):    at 
org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
W/System.err(  709):    at 
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
W/System.err(  709):    at 
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
W/System.err(  709):    at 
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
W/System.err(  709):    at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
====

I can only assume that there is a problem reading in the template 
directory. The custom logger I created merely redirects the output to a 
stdout log. Does anyone have any idea how to solve this little problem? 
I am using Velocity 1.6.2, iJetty 2.1, and Android 1.5.

Thank you,
Jim Cortez

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


Mime
View raw message