Apache Struts 2 Documentation > Home > FAQs > JRockit

These are possible issues and solutions that may be encountered when using the JRocket Java VM:

java.lang.NoClassDefFoundError: org/apache/velocity/app/VelocityEngine

When loading the Struts 2 filter, you may get this exception in your logs, preventing Struts 2 from starting correctly:

<Oct 3, 2007 8:07:21 AM EDT> <Error> <HTTP> <BEA-101165> <Could not load user defined filter in web.xml: org.apache.struts2.dispatcher.FilterDispatcher.
java.lang.NoClassDefFoundError: org/apache/velocity/app/VelocityEngine
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2259)
at java.lang.Class.getDeclaredFields(Class.java:1715)
at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:102) 
...
Cause

The JRocket VM seems to load classes differently than the Sun JVM by more eagerly loading classes that aren't meant to be loaded. Velocity-related classes, such as the one used by the VelocityManager class that is the ultimate cause of this exception, should only be loaded lazily, as Velocity is officially an optional dependency for Struts. JRocket seems to trigger the loading earlier on startup.

Workaround

Add the Velocity jars in your application's classpath and the problem will go away. If you are using Maven 2, insert the following XML into your POM:

<dependency>
  <groupId>velocity</groupId>
  <artifactId>velocity</artifactId>
  <version>1.4</version>
</dependency>
<dependency>
  <groupId>velocity-tools</groupId>
  <artifactId>velocity-tools-view</artifactId>
  <version>1.2</version>
</dependency>