You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Claude Brisson <cl...@renegat.net> on 2007/03/20 23:17:16 UTC

Re: BrowserSnifferTool.init() not getting called from within Spring framework

Yes, really strange.

And does the DispatchServlet properly call init(ViewContext) on other
tools?

One thought: you could try to see what happens when you put the sniffer
tool in the session scope (which happens to be more efficient by the
way).

  Claude

Le mardi 20 mars 2007 à 17:42 -0400, Charles Harvey III a écrit :
> Spring 1.2.8 and Velocity Tools 1.2 (I tried 1.3 and there were loads of 
> problems
> so I will make that move later).
> 
> I put a log statement into the constructor and it gets called 8 times.  See,
> with Spring, I load a DispatcherServlet for different servlet paths.  
> Each one
> of those has its own toolbox (not sure if that's good or bad or 
> indifferent).
> So, 8 toolboxes get loaded up so I see logs for 8 AlloyBrowserSnifferTool
> constructors.  But none for init().
> 
> Very strange indeed.
> 
> 
> Charlie
> 
> 
> 
> Nathan Bubna said the following on 3/20/2007 5:26 PM:
> > That's really odd.  Especially if the other tools are being init'ed.
> > I'm not sure what would cause this, as i don't use Spring's Velocity
> > support much.   But, out of curiousity, what version of Spring and
> > what version of VelocityTools?
> >
> > Also, try putting a log out into your local copy of
> > BrowserSnifferTool's default constructor just to make sure that it is
> > that class that is being instantiated.
> >
> > On 3/20/07, Charles Harvey III <ch...@alloy.com> wrote:
> >> Hello.
> >> This might be a question for the Spring list but I will try here first.
> >> It seems that the BrowserSnifferTool.init( Object o ) method is not 
> >> getting
> >> called upon the start of my webapp.  So when I do $browser.getIe() I get
> >> a NullPointerException.  This is because the userAgent is never set in
> >> the init() method.
> >>
> >> Here is the setup:
> >>
> >> web.xml:
> >> ---------------------------------------------------------------------------- 
> >>
> >> <servlet>
> >>   <servlet-name>app</servlet-name>
> >>
> >> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
> >>
> >>   <load-on-startup>10</load-on-startup>
> >> </servlet>
> >> ---------------------------------------------------------------------------- 
> >>
> >>
> >>
> >> app-servlet.xml:
> >> ---------------------------------------------------------------------------- 
> >>
> >> <bean id="viewResolver"
> >> class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"> 
> >>
> >>   <property name="viewClass"
> >> value="org.springframework.web.servlet.view.velocity.VelocityLayoutView"/> 
> >>
> >>   <property name="cache" value="true"/>
> >>   <property name="prefix" value="/app"/>
> >>   <property name="suffix" value=".vm"/>
> >>   <property name="exposeRequestAttributes" value="true"/>
> >>   <property name="exposeSessionAttributes" value="true"/>
> >>   <property name="exposeSpringMacroHelpers" value="true"/>
> >>   <property name="layoutUrl" value="/layouts/default_layout.vm"/>
> >>   <property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
> >> </bean>
> >> ---------------------------------------------------------------------------- 
> >>
> >>
> >> toolbox.xml:
> >> ---------------------------------------------------------------------------- 
> >>
> >> <tool>
> >>   <key>browser</key>
> >>   <scope>request</scope>
> >>   <class>org.apache.velocity.tools.view.tools.BrowserSnifferTool</class>
> >> </tool>
> >> ---------------------------------------------------------------------------- 
> >>
> >>
> >>
> >> Every other tool seems to work but this one.  I don't get it.  There 
> >> is a:
> >> private String userAgent = null; in BrowserSnifferTool and it gets 
> >> called by
> >> almost every method.  Thing is, it stays null because init( Object o )
> >> is never
> >> called.  I copied BrowserSnifferTool to my project and put log
> >> statements into
> >> the init() method, just to make sure it was getting called - no dice.
> >>
> >>
> >> Any ideas on this are much appreciated.
> >>
> >>
> >>
> >> Charlie
> >>
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> For additional commands, e-mail: user-help@velocity.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
> 


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