velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "M. Hossein Amerkashi" <kkash...@yahoo.com>
Subject Re: toolbox.xml
Date Tue, 03 Jan 2006 20:10:50 GMT
----> Using velocity-tools-1.2.jar

----> Log file:
org.apache.velocity.runtime.exception.ReferenceException:
reference : template = runway.vm [line 4,column 179] :
$dmsTools.dmsToDegWithDir($LAT_ARR_END,7) is not a
valid reference.

---->web.xml
<servlet>
   <servlet-name>velocity</servlet-name>          
<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
     <init-param>
        
<param-name>org.apache.velocity.toolbox</param-name>
        
<param-value>/WEB-INF/toolbox.xml</param-value>
     </init-param>
     <load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
     <servlet-name>velocity</servlet-name>
     <url-pattern>*.vm</url-pattern>
 </servlet-mapping>

--------> templates:
Initially, when welcome.vm page is loaded for testing,
I added the $dmsTool to my template and @ runtime, I
can see that Velocity has loaded the tool into the
context ( package.tools.DMSTools@123defe ). I later
provide a link to user to initiate processing. This
action will call the initVelocity() (see below) and
will start loading data into velocityContext. It is at
this time that I get ReferenceException.




--- Nathan Bubna <nbubna@gmail.com> wrote:

> so, you are using a subclass of VelocityViewServlet,
> right?  what
> version of VelocityTools are you using?  are you
> getting any relevant
> error messages in your logs?
> 
> i'm not sure i understand what you mean when you say
> the tools are
> available on start-up, but not later.  what do your
> logs say at
> startup?  what do they say later?
> 
> overriding initVelocity() should not affect the
> context that is
> created.  what are you doing with the
> velocityContext object you are
> creating and why are you creating it when you
> initialize your velocity
> engine?  that doesn't seem appropriate to me.  if
> you must mess with
> the context, it is best to do so when overriding the
> createContext()
> method.  are you overriding createContext()?
> 
> On 1/3/06, M. Hossein Amerkashi <kkashi01@yahoo.com>
> wrote:
> > Thx for replies.
> > Class / method are public. Using velocity with
> struts.
> >
> >
> > My app is a code generator. On start-up, tools are
> > available, but later are not. Reason is that I do
> > initVelocity (see below) which resets the Context.
> > What needs to be done? Do I need to do context
> > chaining?
> >
> > Thanks
> >
> > private static void initVelocity() throws
> Exception {
> >         if (velocityEngine == null) {
> >             velocityContext = new
> VelocityContext();
> >             Properties velocityProps = new
> > Properties();
> >
> >             velocityEngine = new VelocityEngine();
> >
> >             InputStream inputStream =
> >
>
Engine.class.getResourceAsStream(Constants.VELOCITY_PEROPERTIES_FILE);
> >             velocityProps.load(inputStream);
> >             velocityEngine.init(velocityProps);
> >         }
> >     }
> >
> >
> > --- Nathan Bubna <nbubna@gmail.com> wrote:
> >
> > > as Stas said, make sure that both your tool
> class
> > > and the methods you
> > > wish to call from the template are declared
> public.
> > >
> > > and yeah, more info would be nice.  are you
> using
> > > the
> > > VelocityViewServlet?  are you sure your
> toolbox.xml
> > > is being read?
> > >
> > > On 1/3/06, M. Hossein Amerkashi
> <kkashi01@yahoo.com>
> > > wrote:
> > > > Hi,
> > > >
> > > > I am having difficulty loading custom tools
> using
> > > > toolbox. Basically I have a simple java class
> that
> > > > performs some action and am attempting to load
> it
> > > on
> > > > start-up. The reference is not getting
> processed.
> > > All
> > > > help is appreciated.
> > > >
> > > > <?xml version="1.0"?>
> > > > <toolbox>
> > > > <!-- other tools
> > > >   ...
> > > >   ...
> > > > -->
> > > >     <tool>
> > > >         <key>airportTools</key>
> > > >         <scope>application</scope>
> > > >         <class>package.AirportTools</class>
> > > >     </tool>
> > > > </toolbox>
> > > >
> > > > template:
> > > > $airportTools.getHciForArtcc($ARTCC_ID)
> > > >
> > > >
> > > >
> > > >
> > > > __________________________________
> > > > Yahoo! for Good - Make a difference this year.
> > > > http://brand.yahoo.com/cybergivingweek2005/
> > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
> > > > 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
> > >
> > >
> >
> >
> >
> >
> >
> > __________________________________
> > Yahoo! for Good - Make a difference this year.
> > http://brand.yahoo.com/cybergivingweek2005/
> >
> >
>
---------------------------------------------------------------------
> > 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
> 
> 



	
		
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/

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


Mime
View raw message