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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to