You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Terry <tw...@softhome.net> on 2004/06/22 02:46:28 UTC

velocity installation problem

Hi, I hope someone can point me in the right direction,

I went through the examples in velocity and couldn't get
servlet_example1, servlet_example2, or the forumdemo to work.  I went
through the ant build scripts and generated the war file etc.  But, the
forumdemo wouldn't work.

I searched the mailing list and thought that I found what I needed to
get the forumdemo working to go, to go, but it didn't work.

<servlet-mapping>
<servlet-name>forum</servlet-name>
<url-pattern>>/servlet/forum</url-pattern>
</servlet-mapping>

I was hoping that someone could send me a working forumdemo.war file
so I may try and see if that works in my jakarta-tomcat-5.0.25 so I
could tell that my problem possibly lies in some version of the
servlet.jar that I am using to compile my servlets is wrong.

----------------------------------------------------------------------
you can download my war file from
http://www.geocities.com/twalsworth/war/mywar.jar (you may need to
rename it from mywar.jar to mywar.war)
----------------------------------------------------------------------

It deploys fine and I can see it in Tomcats 'Manager'

-------------------------
here is my servlet (I'm using velocity.properties stored in the
web-inf/conf folder
-------------------------

public class HelloHttpServlet extends VelocityServlet
{

    /**
     *  lets override the loadConfiguration() so we can do some 
     *  fancier setup of the template path
     */
    protected Properties loadConfiguration(ServletConfig config )
        throws IOException, FileNotFoundException
    {
    	System.out.println("***" + INIT_PROPS_KEY + "***");
        String propsFile = config.getInitParameter(INIT_PROPS_KEY);
        
        /*
         *  now convert to an absolute path relative to the webapp root
         *  This will work in a decently implemented servlet 2.2 
         *  container like Tomcat.
         */

        if ( propsFile != null )
        {
            String realPath =
getServletContext().getRealPath(propsFile);
        
            if ( realPath != null )
            {
                propsFile = realPath;
            }
        }
        
       Properties p = new Properties(); 
       p.load( new FileInputStream(propsFile) );
      

       /*
        *  now, lets get the two elements we care about, the 
        *  template path and the log, and fix those from relative
        *  to the webapp root, to absolute on the filesystem, which is
        *  what velocity needs
        */

       String path = p.getProperty("file.resource.loader.path");

       if (path != null)
       {
           path = getServletContext().getRealPath( path );
           p.setProperty( "file.resource.loader.path", path );
       }
        
       path = p.getProperty("runtime.log");

       if (path != null)
       {
           path = getServletContext().getRealPath( path );
           p.setProperty("runtime.log", path );
       }

       return p;
    }
 
    /**
     *  <p>
     *  main routine to handle a request.  Called by
     *  VelocityServlet, your responsibility as programmer
     *  is to simply return a valid Template
     *  </p>
     *
     *  @param ctx a Velocity Context object to be filled with
     *             data.  Will be used for rendering this 
     *             template
     *  @return Template to be used for request
     */   
    public Template handleRequest( HttpServletRequest request, 
	HttpServletResponse response, Context ctx )
    {        
        /*
         *  set up some data to put into the context
         */

        String p1 = "Bob";
        String p2 = "Harold";
        
        Vector personList = new Vector();
        personList.addElement( p1 );
        personList.addElement( p2 );

        /*
         *  Add the list to the context.
         *  This is how it's passed to the template.
         */

        ctx.put("theList", personList );
        
        /*
         *  get the template.  There are three possible
         *  exceptions.  Good to know what happened.
         */

        Template outty = null;
        
        try
        {
            outty =  getTemplate("sample.vm");
        }
        catch( ParseErrorException pee )
        {
            System.out.println("SampleServlet : parse error for template
" + pee);
        }
        catch( ResourceNotFoundException rnfe )
        {
            System.out.println("SampleServlet : template not found " +
rnfe);
        }
        catch( Exception e )
        {
            System.out.println("Error " + e);
        }
        return outty;
    }
}

-----------------------------
here is my web.xml
-----------------------------

   <servlet>
      <servlet-name>SimpleServlet</servlet-name>
      <display-name>Simple Servlet</display-name>
     <servlet-class>some.servlets.HelloHttpServlet</servlet-class>

      <init-param>
         <param-name>properties</param-name>
         <param-value>/WEB-INF/conf/velocity.properties</param-value>
      </init-param>

   </servlet>

   <servlet-mapping>
      <servlet-name>SimpleServlet</servlet-name>
      <url-pattern>/simple/*</url-pattern>
   </servlet-mapping>

---------------------------------------------------------------------------
here is my velocity.properties that I put inside the WEB-INF/conf folder
---------------------------------------------------------------------------

file.resource.loader.path = /template
runtime.log = /forumdemo_velocity.log

---------------------------------------------------------------------------
and here is the screen display from my jakarta-tomcat-5.0.25 container
when I pull up the http://localhost:8080/mywar/simple servlet screen
---------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

javax.servlet.ServletException: Error initializing Velocity: java.lang.NullPointerException
	org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:197)
	org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
	org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
	java.lang.Thread.run(Thread.java:534)

root cause

java.lang.NullPointerException
	java.io.FileInputStream.<init>(FileInputStream.java:103)
	java.io.FileInputStream.<init>(FileInputStream.java:66)
	some.servlets.HelloHttpServlet.loadConfiguration(HelloHttpServlet.java:81)
	org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:191)
	org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
	org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
	java.lang.Thread.run(Thread.java:534)

note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.25 logs.

---------------------------------------------------------------------------
and here is the log file that shows more information about the error
message.
---------------------------------------------------------------------------


2004-06-21 20:37:31
StandardContext[/balancer]org.apache.webapp.balancer.BalancerFilter:
init(): ruleChain: [org.apache.webapp.balancer.RuleChain:
[org.apache.webapp.balancer.rules.URLStringMatchRule: Target string:
News / Redirect URL: http://www.cnn.com],
[org.apache.webapp.balancer.rules.RequestParameterRule: Target param
name: paramName / Target param value: paramValue / Redirect URL:
http://www.yahoo.com],
[org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL:
http://jakarta.apache.org]]
2004-06-21 20:37:31 StandardContext[/mywar]Servlet /mywar threw load()
exception
javax.servlet.ServletException: Error initializing Velocity:
java.lang.NullPointerException
	at
org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:197)
	at
org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
	at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
	at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
	at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
	at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
	at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
	at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
	at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
	at
org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
	at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
	at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:613)
	at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964)
	at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
	at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
	at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
	at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
	at
org.apache.catalina.core.StandardService.start(StandardService.java:476)
	at
org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
----- Root Cause -----
java.lang.NullPointerException
	at java.io.FileInputStream.<init>(FileInputStream.java:103)
	at java.io.FileInputStream.<init>(FileInputStream.java:66)
	at
some.servlets.HelloHttpServlet.loadConfiguration(HelloHttpServlet.java:81)
	at
org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:191)
	at
org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
	at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
	at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
	at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
	at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
	at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
	at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
	at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
	at
org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
	at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
	at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:613)
	at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964)
	at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
	at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
	at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
	at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
	at
org.apache.catalina.core.StandardService.start(StandardService.java:476)
	at
org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

2004-06-21 20:37:32 StandardContext[/jsp-examples]ContextListener:
contextInitialized()
2004-06-21 20:37:32 StandardContext[/jsp-examples]SessionListener:
contextInitialized()
2004-06-21 20:37:32 StandardContext[/servlets-examples]ContextListener:
contextInitialized()
2004-06-21 20:37:32 StandardContext[/servlets-examples]SessionListener:
contextInitialized()



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


Re: velocity installation problem

Posted by Terry <tw...@softhome.net>.
I am also using Velocity-1.4.jar and velocity-dep-1.4.jar.

and I'm compiling with java version "1.4.2_04"

many thanks,
-Terry

On Mon, 2004-06-21 at 20:46, Terry wrote:
> Hi, I hope someone can point me in the right direction,
> 
> I went through the examples in velocity and couldn't get
> servlet_example1, servlet_example2, or the forumdemo to work.  I went
> through the ant build scripts and generated the war file etc.  But, the
> forumdemo wouldn't work.
> 
> I searched the mailing list and thought that I found what I needed to
> get the forumdemo working to go, to go, but it didn't work.
> 
> <servlet-mapping>
> <servlet-name>forum</servlet-name>
> <url-pattern>>/servlet/forum</url-pattern>
> </servlet-mapping>
> 
> I was hoping that someone could send me a working forumdemo.war file
> so I may try and see if that works in my jakarta-tomcat-5.0.25 so I
> could tell that my problem possibly lies in some version of the
> servlet.jar that I am using to compile my servlets is wrong.
> 
> ----------------------------------------------------------------------
> you can download my war file from
> http://www.geocities.com/twalsworth/war/mywar.jar (you may need to
> rename it from mywar.jar to mywar.war)
> ----------------------------------------------------------------------
> 
> It deploys fine and I can see it in Tomcats 'Manager'
> 
> -------------------------
> here is my servlet (I'm using velocity.properties stored in the
> web-inf/conf folder
> -------------------------
> 
> public class HelloHttpServlet extends VelocityServlet
> {
> 
>     /**
>      *  lets override the loadConfiguration() so we can do some 
>      *  fancier setup of the template path
>      */
>     protected Properties loadConfiguration(ServletConfig config )
>         throws IOException, FileNotFoundException
>     {
>     	System.out.println("***" + INIT_PROPS_KEY + "***");
>         String propsFile = config.getInitParameter(INIT_PROPS_KEY);
>         
>         /*
>          *  now convert to an absolute path relative to the webapp root
>          *  This will work in a decently implemented servlet 2.2 
>          *  container like Tomcat.
>          */
> 
>         if ( propsFile != null )
>         {
>             String realPath =
> getServletContext().getRealPath(propsFile);
>         
>             if ( realPath != null )
>             {
>                 propsFile = realPath;
>             }
>         }
>         
>        Properties p = new Properties(); 
>        p.load( new FileInputStream(propsFile) );
>       
> 
>        /*
>         *  now, lets get the two elements we care about, the 
>         *  template path and the log, and fix those from relative
>         *  to the webapp root, to absolute on the filesystem, which is
>         *  what velocity needs
>         */
> 
>        String path = p.getProperty("file.resource.loader.path");
> 
>        if (path != null)
>        {
>            path = getServletContext().getRealPath( path );
>            p.setProperty( "file.resource.loader.path", path );
>        }
>         
>        path = p.getProperty("runtime.log");
> 
>        if (path != null)
>        {
>            path = getServletContext().getRealPath( path );
>            p.setProperty("runtime.log", path );
>        }
> 
>        return p;
>     }
>  
>     /**
>      *  <p>
>      *  main routine to handle a request.  Called by
>      *  VelocityServlet, your responsibility as programmer
>      *  is to simply return a valid Template
>      *  </p>
>      *
>      *  @param ctx a Velocity Context object to be filled with
>      *             data.  Will be used for rendering this 
>      *             template
>      *  @return Template to be used for request
>      */   
>     public Template handleRequest( HttpServletRequest request, 
> 	HttpServletResponse response, Context ctx )
>     {        
>         /*
>          *  set up some data to put into the context
>          */
> 
>         String p1 = "Bob";
>         String p2 = "Harold";
>         
>         Vector personList = new Vector();
>         personList.addElement( p1 );
>         personList.addElement( p2 );
> 
>         /*
>          *  Add the list to the context.
>          *  This is how it's passed to the template.
>          */
> 
>         ctx.put("theList", personList );
>         
>         /*
>          *  get the template.  There are three possible
>          *  exceptions.  Good to know what happened.
>          */
> 
>         Template outty = null;
>         
>         try
>         {
>             outty =  getTemplate("sample.vm");
>         }
>         catch( ParseErrorException pee )
>         {
>             System.out.println("SampleServlet : parse error for template
> " + pee);
>         }
>         catch( ResourceNotFoundException rnfe )
>         {
>             System.out.println("SampleServlet : template not found " +
> rnfe);
>         }
>         catch( Exception e )
>         {
>             System.out.println("Error " + e);
>         }
>         return outty;
>     }
> }
> 
> -----------------------------
> here is my web.xml
> -----------------------------
> 
>    <servlet>
>       <servlet-name>SimpleServlet</servlet-name>
>       <display-name>Simple Servlet</display-name>
>      <servlet-class>some.servlets.HelloHttpServlet</servlet-class>
> 
>       <init-param>
>          <param-name>properties</param-name>
>          <param-value>/WEB-INF/conf/velocity.properties</param-value>
>       </init-param>
> 
>    </servlet>
> 
>    <servlet-mapping>
>       <servlet-name>SimpleServlet</servlet-name>
>       <url-pattern>/simple/*</url-pattern>
>    </servlet-mapping>
> 
> ---------------------------------------------------------------------------
> here is my velocity.properties that I put inside the WEB-INF/conf folder
> ---------------------------------------------------------------------------
> 
> file.resource.loader.path = /template
> runtime.log = /forumdemo_velocity.log
> 
> ---------------------------------------------------------------------------
> and here is the screen display from my jakarta-tomcat-5.0.25 container
> when I pull up the http://localhost:8080/mywar/simple servlet screen
> ---------------------------------------------------------------------------
> 
> type Exception report
> 
> message
> 
> description The server encountered an internal error () that prevented
> it from fulfilling this request.
> 
> exception
> 
> javax.servlet.ServletException: Error initializing Velocity: java.lang.NullPointerException
> 	org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:197)
> 	org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
> 	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
> 	org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
> 	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
> 	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
> 	org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
> 	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
> 	java.lang.Thread.run(Thread.java:534)
> 
> root cause
> 
> java.lang.NullPointerException
> 	java.io.FileInputStream.<init>(FileInputStream.java:103)
> 	java.io.FileInputStream.<init>(FileInputStream.java:66)
> 	some.servlets.HelloHttpServlet.loadConfiguration(HelloHttpServlet.java:81)
> 	org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:191)
> 	org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
> 	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
> 	org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
> 	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
> 	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
> 	org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
> 	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
> 	java.lang.Thread.run(Thread.java:534)
> 
> note The full stack trace of the root cause is available in the Apache
> Tomcat/5.0.25 logs.
> 
> ---------------------------------------------------------------------------
> and here is the log file that shows more information about the error
> message.
> ---------------------------------------------------------------------------
> 
> 
> 2004-06-21 20:37:31
> StandardContext[/balancer]org.apache.webapp.balancer.BalancerFilter:
> init(): ruleChain: [org.apache.webapp.balancer.RuleChain:
> [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string:
> News / Redirect URL: http://www.cnn.com],
> [org.apache.webapp.balancer.rules.RequestParameterRule: Target param
> name: paramName / Target param value: paramValue / Redirect URL:
> http://www.yahoo.com],
> [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL:
> http://jakarta.apache.org]]
> 2004-06-21 20:37:31 StandardContext[/mywar]Servlet /mywar threw load()
> exception
> javax.servlet.ServletException: Error initializing Velocity:
> java.lang.NullPointerException
> 	at
> org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:197)
> 	at
> org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
> 	at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
> 	at
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
> 	at
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
> 	at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
> 	at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
> 	at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
> 	at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
> 	at
> org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
> 	at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
> 	at
> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:613)
> 	at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431)
> 	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964)
> 	at
> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
> 	at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> 	at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
> 	at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
> 	at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
> 	at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
> 	at
> org.apache.catalina.core.StandardService.start(StandardService.java:476)
> 	at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
> 	at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
> 	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
> ----- Root Cause -----
> java.lang.NullPointerException
> 	at java.io.FileInputStream.<init>(FileInputStream.java:103)
> 	at java.io.FileInputStream.<init>(FileInputStream.java:66)
> 	at
> some.servlets.HelloHttpServlet.loadConfiguration(HelloHttpServlet.java:81)
> 	at
> org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:191)
> 	at
> org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
> 	at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
> 	at
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
> 	at
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3991)
> 	at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4335)
> 	at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
> 	at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
> 	at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
> 	at
> org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
> 	at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
> 	at
> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:613)
> 	at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431)
> 	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964)
> 	at
> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
> 	at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> 	at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
> 	at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
> 	at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
> 	at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
> 	at
> org.apache.catalina.core.StandardService.start(StandardService.java:476)
> 	at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
> 	at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
> 	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
> 
> 2004-06-21 20:37:32 StandardContext[/jsp-examples]ContextListener:
> contextInitialized()
> 2004-06-21 20:37:32 StandardContext[/jsp-examples]SessionListener:
> contextInitialized()
> 2004-06-21 20:37:32 StandardContext[/servlets-examples]ContextListener:
> contextInitialized()
> 2004-06-21 20:37:32 StandardContext[/servlets-examples]SessionListener:
> contextInitialized()
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


Re: velocity installation problem

Posted by Terry <tw...@softhome.net>.
Hi, I can't seem to tell.  I try and manully say where the properties
file is, and I get get a something still similar to a null pointer.

I tried to check if I had mistyped /WEB-INF/conf/velocity.properties
between whats in my web.xml file and the actual directory
/WEB/conf/velocity.properties and everything appears to be typed
correctly.

I'm also using Mandrake Linux 10 Official...
--------------------------
original lines of code
--------------------------

70        if ( propsFile != null )
71        {
72            String realPath =
getServletContext().getRealPath(propsFile);
73        
74            if ( realPath != null )
75            {
76                propsFile = realPath;
77            }
78        }
79        
80       Properties p = new Properties(); 
81       p.load( new FileInputStream(propsFile) );

---------------------------
changed lines of code
---------------------------
81       p.load( new
FileInputStream("/WEB-INF/conf/velocity.properties") );

--------------------------
browser error message
---------------------------

HTTP Status 500 - 

________________________________________________________________________

type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

javax.servlet.ServletException: Error initializing Velocity: java.io.FileNotFoundException: /WEB-INF/conf/velocity.properties (No such file or directory)
	org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:197)
	org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
	org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
	java.lang.Thread.run(Thread.java:534)

root cause

java.io.FileNotFoundException: /WEB-INF/conf/velocity.properties (No such file or directory)
	java.io.FileInputStream.open(Native Method)
	java.io.FileInputStream.<init>(FileInputStream.java:106)
	java.io.FileInputStream.<init>(FileInputStream.java:66)
	some.servlets.HelloHttpServlet.loadConfiguration(HelloHttpServlet.java:81)
	org.apache.velocity.servlet.VelocityServlet.initVelocity(VelocityServlet.java:191)
	org.apache.velocity.servlet.VelocityServlet.init(VelocityServlet.java:162)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
	org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
	java.lang.Thread.run(Thread.java:534)

note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.25 logs.


________________________________________________________________________
Apache Tomcat/5.0.25

On Mon, 2004-06-21 at 22:10, Dave Newton wrote:
> On Mon, 21 Jun 2004 22:00:38 -0400 Terry <tw...@softhome.net> wrote:
> > 80       Properties p = new Properties(); 
> > 81       p.load( new FileInputStream(propsFile) );
> 
> Is propsFile null?
> 
> Dave
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


Re: velocity installation problem

Posted by Dave Newton <da...@solaraccess.com>.
On Mon, 21 Jun 2004 22:00:38 -0400 Terry <tw...@softhome.net> wrote:
> 80       Properties p = new Properties(); 
> 81       p.load( new FileInputStream(propsFile) );

Is propsFile null?

Dave

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


Re: velocity installation problem

Posted by Terry <tw...@softhome.net>.
80       Properties p = new Properties(); 
81       p.load( new FileInputStream(propsFile) );

On Mon, 2004-06-21 at 21:42, Dave Newton wrote:
> On Mon, 21 Jun 2004 20:46:28 -0400 Terry <tw...@softhome.net> wrote:
> > [...]
> > 	some.servlets.HelloHttpServlet.loadConfiguration(HelloHttpServlet.java:81)
> 
> Which is line 81?
> 
> Dave
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


Re: velocity installation problem

Posted by Dave Newton <da...@solaraccess.com>.
On Mon, 21 Jun 2004 20:46:28 -0400 Terry <tw...@softhome.net> wrote:
> [...]
> 	some.servlets.HelloHttpServlet.loadConfiguration(HelloHttpServlet.java:81)

Which is line 81?

Dave

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


Re: mergeTemplate not finding the vm file from crontab

Posted by Michael Heuer <he...@acm.org>.
with "mypackage/Template.wm" the call to getClass().getResource(...)
fails but the velocity resource loader is ok.

   michael


On Fri, 25 Jun 2004, Geir Magnusson Jr wrote:

> what happens if you remove leading /?
>
> On Jun 23, 2004, at 5:24 PM, Michael Heuer wrote:
>
> >
> > I'm actually running into a similar problem, in an application with the
> > ClasspathResourceLoader.  I have templates in a jar on the classpath
> > in a
> > package mypackage.  The classloader can find the template but velocity
> > can not.
> >
> >   System.out.println(Velocity.getProperty("resource.loader"));
> >
> > System.out.println(Velocity.getProperty("class.resource.loader.class"))
> > ;
> >   java.net.URL url = getClass().getResource("/mypackage/Template.wm");
> >   System.out.println("found resource, url=" + url);
> >   Template template = Velocity.getTemplate("/mypackage/Template.wm");
> >
> > [class]
> > org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> > found resource, url=jar:file:/.../templates.jar!/mypackage/Template.wm
> > org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> > resource '/mypackage/Template.wm'
> >         at
> > org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(R
> > esourceManagerImpl.java:458)
> >         at
> > org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Re
> > sourceManagerImpl.java:341)
> >
> >    michael
> >
> >
> > On Tue, 22 Jun 2004, Will Glass-Husain wrote:
> >
> >> You don't give an absolute path to Velocity.  Instead, specify the
> >> path to
> >> the root of the template tree when configuring velocity, then pass in
> >> template paths relative to this path.
> >>
> >> http://jakarta.apache.org/velocity/developer-
> >> guide.html#Configuring%20Resource%20Loaders
> >>
> >> This can be a little confusing when you start out but look at the
> >> example in
> >> the section above.
> >>
> >> WILL
> >>
> >> ----- Original Message -----
> >> From: "Ilan Azbel" <ia...@mdio.net>
> >> To: "Velocity Users List" <ve...@jakarta.apache.org>
> >> Sent: Tuesday, June 22, 2004 1:03 AM
> >> Subject: mergeTemplate not finding the vm file from crontab
> >>
> >>
> >>> Hello,
> >>>
> >>> I have written a small application that produces html output using
> >> velocity
> >>> mergeTemplate() method (as described in the manual).
> >>>
> >>> It all works perfectly for me when I run the application from the
> >> operating
> >>> system prompt. However, when I schedule the same application to rub
> >>> from
> >> the
> >>> crontab I get the following exception:
> >>>
> >>> org.apache.velocity.exception.ResourceNotFoundException: Unable to
> >>> find
> >>> resource '/usr/tdk-2.2/bin/CustomReportEmail.vm'
> >>>         at
> >>>
> >> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(
> >> Resour
> >>> ceManagerImpl.java:501)
> >>>         at
> >>>
> >> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(R
> >> esourc
> >>> eManagerImpl.java:384)
> >>>         at
> >>>
> >> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstanc
> >> e.java
> >>> :814)
> >>>         at
> >>>
> >> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingle
> >> ton.ja
> >>> va:355)
> >>>         at
> >> org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:482)
> >>>         at
> >>> com.autochartist.patterns.om.AlertEmailer.main(AlertEmailer.java:92)
> >>>
> >>> I have tried to provide the mergeTemplate method with the full path
> >>> of the
> >>> .vm file, but still no luck.
> >>>
> >>> Any ideas where I should put the vm file?
> >>>
> >>> Thanks
> >>> Ilan
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >>> For additional commands, e-mail:
> >>> velocity-user-help@jakarta.apache.org
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
> --
> Geir Magnusson Jr                                   203-247-1713(m)
> geir@4quarters.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>


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


Re: mergeTemplate not finding the vm file from crontab

Posted by Geir Magnusson Jr <ge...@4quarters.com>.
what happens if you remove leading /?

On Jun 23, 2004, at 5:24 PM, Michael Heuer wrote:

>
> I'm actually running into a similar problem, in an application with the
> ClasspathResourceLoader.  I have templates in a jar on the classpath  
> in a
> package mypackage.  The classloader can find the template but velocity
> can not.
>
>   System.out.println(Velocity.getProperty("resource.loader"));
>    
> System.out.println(Velocity.getProperty("class.resource.loader.class")) 
> ;
>   java.net.URL url = getClass().getResource("/mypackage/Template.wm");
>   System.out.println("found resource, url=" + url);
>   Template template = Velocity.getTemplate("/mypackage/Template.wm");
>
> [class]
> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> found resource, url=jar:file:/.../templates.jar!/mypackage/Template.wm
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource '/mypackage/Template.wm'
>         at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(R 
> esourceManagerImpl.java:458)
>         at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Re 
> sourceManagerImpl.java:341)
>
>    michael
>
>
> On Tue, 22 Jun 2004, Will Glass-Husain wrote:
>
>> You don't give an absolute path to Velocity.  Instead, specify the  
>> path to
>> the root of the template tree when configuring velocity, then pass in
>> template paths relative to this path.
>>
>> http://jakarta.apache.org/velocity/developer- 
>> guide.html#Configuring%20Resource%20Loaders
>>
>> This can be a little confusing when you start out but look at the  
>> example in
>> the section above.
>>
>> WILL
>>
>> ----- Original Message -----
>> From: "Ilan Azbel" <ia...@mdio.net>
>> To: "Velocity Users List" <ve...@jakarta.apache.org>
>> Sent: Tuesday, June 22, 2004 1:03 AM
>> Subject: mergeTemplate not finding the vm file from crontab
>>
>>
>>> Hello,
>>>
>>> I have written a small application that produces html output using
>> velocity
>>> mergeTemplate() method (as described in the manual).
>>>
>>> It all works perfectly for me when I run the application from the
>> operating
>>> system prompt. However, when I schedule the same application to rub  
>>> from
>> the
>>> crontab I get the following exception:
>>>
>>> org.apache.velocity.exception.ResourceNotFoundException: Unable to  
>>> find
>>> resource '/usr/tdk-2.2/bin/CustomReportEmail.vm'
>>>         at
>>>
>> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource( 
>> Resour
>>> ceManagerImpl.java:501)
>>>         at
>>>
>> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(R 
>> esourc
>>> eManagerImpl.java:384)
>>>         at
>>>
>> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstanc 
>> e.java
>>> :814)
>>>         at
>>>
>> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingle 
>> ton.ja
>>> va:355)
>>>         at
>> org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:482)
>>>         at
>>> com.autochartist.patterns.om.AlertEmailer.main(AlertEmailer.java:92)
>>>
>>> I have tried to provide the mergeTemplate method with the full path  
>>> of the
>>> .vm file, but still no luck.
>>>
>>> Any ideas where I should put the vm file?
>>>
>>> Thanks
>>> Ilan
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail:  
>>> velocity-user-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


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


Re: mergeTemplate not finding the vm file from crontab

Posted by Michael Heuer <he...@acm.org>.
I'm actually running into a similar problem, in an application with the
ClasspathResourceLoader.  I have templates in a jar on the classpath in a
package mypackage.  The classloader can find the template but velocity
can not.

  System.out.println(Velocity.getProperty("resource.loader"));
  System.out.println(Velocity.getProperty("class.resource.loader.class"));
  java.net.URL url = getClass().getResource("/mypackage/Template.wm");
  System.out.println("found resource, url=" + url);
  Template template = Velocity.getTemplate("/mypackage/Template.wm");

[class]
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
found resource, url=jar:file:/.../templates.jar!/mypackage/Template.wm
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource '/mypackage/Template.wm'
        at
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:458)
        at
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:341)

   michael


On Tue, 22 Jun 2004, Will Glass-Husain wrote:

> You don't give an absolute path to Velocity.  Instead, specify the path to
> the root of the template tree when configuring velocity, then pass in
> template paths relative to this path.
>
> http://jakarta.apache.org/velocity/developer-guide.html#Configuring%20Resource%20Loaders
>
> This can be a little confusing when you start out but look at the example in
> the section above.
>
> WILL
>
> ----- Original Message -----
> From: "Ilan Azbel" <ia...@mdio.net>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Tuesday, June 22, 2004 1:03 AM
> Subject: mergeTemplate not finding the vm file from crontab
>
>
> > Hello,
> >
> > I have written a small application that produces html output using
> velocity
> > mergeTemplate() method (as described in the manual).
> >
> > It all works perfectly for me when I run the application from the
> operating
> > system prompt. However, when I schedule the same application to rub from
> the
> > crontab I get the following exception:
> >
> > org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> > resource '/usr/tdk-2.2/bin/CustomReportEmail.vm'
> >         at
> >
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Resour
> > ceManagerImpl.java:501)
> >         at
> >
> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Resourc
> > eManagerImpl.java:384)
> >         at
> >
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java
> > :814)
> >         at
> >
> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.ja
> > va:355)
> >         at
> org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:482)
> >         at
> > com.autochartist.patterns.om.AlertEmailer.main(AlertEmailer.java:92)
> >
> > I have tried to provide the mergeTemplate method with the full path of the
> > .vm file, but still no luck.
> >
> > Any ideas where I should put the vm file?
> >
> > Thanks
> > Ilan
> >
> >
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>


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


Re: mergeTemplate not finding the vm file from crontab

Posted by Will Glass-Husain <wg...@forio.com>.
You don't give an absolute path to Velocity.  Instead, specify the path to
the root of the template tree when configuring velocity, then pass in
template paths relative to this path.

http://jakarta.apache.org/velocity/developer-guide.html#Configuring%20Resource%20Loaders

This can be a little confusing when you start out but look at the example in
the section above.

WILL

----- Original Message ----- 
From: "Ilan Azbel" <ia...@mdio.net>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, June 22, 2004 1:03 AM
Subject: mergeTemplate not finding the vm file from crontab


> Hello,
>
> I have written a small application that produces html output using
velocity
> mergeTemplate() method (as described in the manual).
>
> It all works perfectly for me when I run the application from the
operating
> system prompt. However, when I schedule the same application to rub from
the
> crontab I get the following exception:
>
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource '/usr/tdk-2.2/bin/CustomReportEmail.vm'
>         at
>
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Resour
> ceManagerImpl.java:501)
>         at
>
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Resourc
> eManagerImpl.java:384)
>         at
>
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java
> :814)
>         at
>
org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.ja
> va:355)
>         at
org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:482)
>         at
> com.autochartist.patterns.om.AlertEmailer.main(AlertEmailer.java:92)
>
> I have tried to provide the mergeTemplate method with the full path of the
> .vm file, but still no luck.
>
> Any ideas where I should put the vm file?
>
> Thanks
> Ilan
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


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


mergeTemplate not finding the vm file from crontab

Posted by Ilan Azbel <ia...@mdio.net>.
Hello,

I have written a small application that produces html output using velocity
mergeTemplate() method (as described in the manual).

It all works perfectly for me when I run the application from the operating
system prompt. However, when I schedule the same application to rub from the
crontab I get the following exception:

org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource '/usr/tdk-2.2/bin/CustomReportEmail.vm'
        at
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Resour
ceManagerImpl.java:501)
        at
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Resourc
eManagerImpl.java:384)
        at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java
:814)
        at
org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.ja
va:355)
        at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:482)
        at
com.autochartist.patterns.om.AlertEmailer.main(AlertEmailer.java:92)

I have tried to provide the mergeTemplate method with the full path of the
.vm file, but still no luck.

Any ideas where I should put the vm file?

Thanks
Ilan








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


Re: velocity installation problem

Posted by Terry <tw...@softhome.net>.
Hi, thanks for bringing up to my attention the VelocityTools project.

I've already installed and have working properly on my system.

This is what I was looking for, many thanks.
-Terry

On Mon, 2004-06-21 at 22:23, Nathan Bubna wrote:
> Terry said:
> > Hi, I hope someone can point me in the right direction,
> >
> > I went through the examples in velocity and couldn't get
> > servlet_example1, servlet_example2, or the forumdemo to work.  I went
> > through the ant build scripts and generated the war file etc.  But, the
> > forumdemo wouldn't work.
> ...
> > you can download my war file from
> > http://www.geocities.com/twalsworth/war/mywar.jar (you may need to
> > rename it from mywar.jar to mywar.war)
> ...
> >             String realPath =
> > getServletContext().getRealPath(propsFile);
> ...
> 
> 
> AFAIK, ServletContext.getRealPath(String) is unreliable, and will typically
> not work with most servlet engines when deploying an application was a war.
> 
> if you want to get a velocity webapp working, i highly recommend checking out
> the example webapps that come with the VelocityTools project.  Those use the
> VelocityViewServlet which does not rely on getRealPath() and is the planned
> replacement for the now-deprecated VelocityServlet.   bottom line, the core of
> the Velocity project has passed off web application support to the
> VelocityTools project.   if you intend to do web development with Velocity,
> you should probably skip the servlet examples and forumdemo and go right to
> the VelocityTools apps.  they should work out-of-the-box with any servlet
> engine.
> 
> Nathan Bubna
> nathan@esha.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


Re: velocity installation problem

Posted by Nathan Bubna <na...@esha.com>.
Terry said:
> Hi, I hope someone can point me in the right direction,
>
> I went through the examples in velocity and couldn't get
> servlet_example1, servlet_example2, or the forumdemo to work.  I went
> through the ant build scripts and generated the war file etc.  But, the
> forumdemo wouldn't work.
...
> you can download my war file from
> http://www.geocities.com/twalsworth/war/mywar.jar (you may need to
> rename it from mywar.jar to mywar.war)
...
>             String realPath =
> getServletContext().getRealPath(propsFile);
...


AFAIK, ServletContext.getRealPath(String) is unreliable, and will typically
not work with most servlet engines when deploying an application was a war.

if you want to get a velocity webapp working, i highly recommend checking out
the example webapps that come with the VelocityTools project.  Those use the
VelocityViewServlet which does not rely on getRealPath() and is the planned
replacement for the now-deprecated VelocityServlet.   bottom line, the core of
the Velocity project has passed off web application support to the
VelocityTools project.   if you intend to do web development with Velocity,
you should probably skip the servlet examples and forumdemo and go right to
the VelocityTools apps.  they should work out-of-the-box with any servlet
engine.

Nathan Bubna
nathan@esha.com


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