velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bradley Wagner <>
Subject Inconsistent and strange NPE when initializing Velocity
Date Wed, 06 Jun 2012 15:37:25 GMT

I sent this message before I had subscribed to the list so I wasn't sure if
the original made it. My apologies if this is a duplicate.

One of our clients running our software is *occasionally* running into the
stack trace at the bottom when Velocity is initialized. A restart tends to
fix this problem. But it pops back up after running the system for a while.

They're running:

   - Velocity 1.7
   - Tomcat 6.0.35
   - Using the 3.2 of the Apache Commons Collections library
   - Running Java 1.6.0_31 in Mac OS X 10.6.8

Unfortunately we don't have the ability to debug this problem remotely, so
we can't see exactly what's going on, but having looked a bit at the
Extended Properties class, it doesn't seem like it should be possible to
get an NPE at that line, because of the containsKey() check a few lines

at org.apache.commons.collections.ExtendedProperties.clearProperty(
at org.apache.commons.collections.ExtendedProperties.setProperty(
at org.apache.commons.collections.ExtendedProperties.combine(
at org.apache.velocity.runtime.RuntimeInstance.setProperties(
at org.apache.velocity.runtime.RuntimeInstance.init(
at org.apache.velocity.runtime.RuntimeSingleton.init(
at com.hannonhill.cascade.velocity.VelocityEngineUtil.generateMessage(

Also, here's the code that's calling the Velocity.init:

        Properties velocityProps = VelocityProperties.getProperties();


Velocity Properties are just loading the following file contents into a
properties object:

# This controls if Runtime.error(), info() and warn() messages include the
# whole stack trace. The last property controls whether invalid references
# are logged.
runtime.log.error.stacktrace = false
runtime.log.warn.stacktrace = false = false
runtime.log.invalid.reference = true
# Configuration for the Log4JLogSystem.
# You must define the runtime.log.logsystem.class property to be:
#   org.apache.velocity.runtime.log.Log4JLogSystem
# You must also include Log4J's .jar files into your classpath. They are
# included with the Velocity distribution in the build/lib directory.
# There are several different options that you can configure.
# Uncomment the ones that you want and also define their settings.
# T E M P L A T E  E N C O D I N G
# F O R E A C H  P R O P E R T I E S
# These properties control how the counter is accessed in the #foreach
# directive. By default the reference $velocityCount will be available
# in the body of the #foreach directive. The default starting value
# for this reference is 1.
#---------------------------------------------------------------------------- = velocityCount
directive.foreach.counter.initial.value = 1
# T E M P L A T E  L O A D E R S
resource.loader = class
class.resource.loader.description = Velocity Classpath Resource Loader
class.resource.loader.class =

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message