I use Velocity in Java project to generate source code. I export the project as jar file to use it in an other project.
This is my velocity properties file content:
runtime.log.logsystem.class = org.apache.velocity.runtime.log.SystemLogChute
resource.loader = resources/
classpath.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
I get this error:
Internal compiler error: java.lang.NoClassDefFoundError: org/apache/velocity/exception/ResourceNotFoundException at java.lang.Class.getDeclaredConstructors0(Native Method)
That Class was present during build time but it depends upon environment, if you are working in J2EE environment than you can get NoClassDefFoundError even if class is present because it may not be visible to corresponding class loader.
Put all dependencies to WEB-INF/lib
and add them to CLASSPATH
.
Where to Put the Velocity Jar
First of all you have to decide whether you will use the dependency-free version
of velocity.jar or the version including all dependend jars. If you are not worried
about collisions with Avalon Logkit, Commons Collections or Jakarta Oro, using the jar
containing all dependencies is very convenient.
Putting the velocity jar in WEB-INF/lib your web application
will result in it's classes being available in the classpath for that web application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.