Announcement Announcement Module
Collapse
No announcement yet.
ClassNotFoundException: org.springframework.ui.velocity.VelocityEngineFact ory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ClassNotFoundException: org.springframework.ui.velocity.VelocityEngineFact ory

    Hello!

    I'm creating a Spring MVC 3.2.3 application and i'm having some issues with velocity.

    At first, i was using spring-modules-validation that contains spring2.0.3.jar, and it the aplication was working fine when i used maven tomcat:run.

    When i tried to deploy the application on a Tomcat server i started to have some problems with this spring2.0.3.jar, so i excluded it from maven dependencies.

    Now, my application simple can't find VelocityEngineFactory.

    On my POM i have:

    Code:
    <dependencies>
    <!-- Spring core & mvc -->
    <dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-context</artifactId>
    	<version>${spring.version}</version>
    </dependency>
    
    <dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-webmvc</artifactId>
    	<version>${spring.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-orm</artifactId>
    	<version>${spring.version}</version>
    </dependency>
    
    <dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-test</artifactId>
    	<version>${spring.version}</version>
    	<type>jar</type>
    	<scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-beans</artifactId>
    	<version>${spring.version}</version>
    </dependency>
    
    <!-- CGLib for @Configuration -->
    <dependency>
    	<groupId>cglib</groupId>
    	<artifactId>cglib-nodep</artifactId>
    	<version>${cglib.version}</version>
    	<scope>compile</scope>
    </dependency>
    
    <dependency>
    	<groupId>javax.validation</groupId>
    	<artifactId>validation-api</artifactId>
    	<version>1.1.0.Final</version>
    </dependency>
    
    <dependency>
    	<groupId>org.hibernate</groupId>
    	<artifactId>hibernate-validator</artifactId>
    	<version>5.0.1.Final</version>
    </dependency>
    			
    
    
    <!-- Servlet Spec -->
    <dependency>
    	<groupId>javax.servlet</groupId>
    	<artifactId>servlet-api</artifactId>
    	<version>2.4</version>
    	<scope>provided</scope>
    </dependency>
    <dependency>
    	<groupId>javax.servlet.jsp</groupId>
    	<artifactId>jsp-api</artifactId>
    	<version>2.1</version>
    	<scope>provided</scope>
    </dependency>
    
    <!-- Logger -->
    <dependency>
    	<groupId>log4j</groupId>
    	<artifactId>log4j</artifactId>
    	<version>${log4j.version}</version>
    	<type>jar</type>
    	<scope>compile</scope>
    </dependency>
    
    <!-- Velocity - Para usar anotações # e $ nas views -->
    <dependency>
    	<groupId>org.apache.velocity</groupId>
    	<artifactId>velocity</artifactId>
    	<version>1.7</version>
    </dependency>
    <dependency>
    	<groupId>org.apache.velocity</groupId>
    	<artifactId>velocity-tools</artifactId>
    	<version>2.0</version>
    </dependency>
    
    <!-- A seamless aspect-oriented extension to the Java programming language -->
    <dependency>
    	<groupId>org.aspectj</groupId>
    	<artifactId>aspectjrt</artifactId>
    	<version>${aspectj.version}</version>
    </dependency>
    
    <dependency>
    	<groupId>org.aspectj</groupId>
    	<artifactId>aspectjweaver</artifactId>
    	<version>${aspectj.version}</version>
    </dependency>
    
    <!-- Data Mapper package is a high-performance data binding package built 
    	on Jackson JSON processor -->
    <dependency>
    	<groupId>org.codehaus.jackson</groupId>
    	<artifactId>jackson-mapper-asl</artifactId>
    	<version>${jackson.version}</version>
    	<type>jar</type>
    	<scope>compile</scope>
    </dependency>
    
    <!-- Hibernate -->
    <dependency>
    	<groupId>org.hibernate</groupId>
    	<artifactId>hibernate-entitymanager</artifactId>
    	<version>4.1.9.Final</version>
    </dependency>
    
    <!-- SQL Server Driver -->
    <dependency>
    	<groupId>com.microsoft.sqlserver</groupId>
    	<artifactId>sqljdbc4</artifactId>
    	<version>4.0</version>
    </dependency>
    
    <!-- slf4j -->
    <dependency>
    	<groupId>org.slf4j</groupId>
    	<artifactId>slf4j-log4j12</artifactId>
    	<version>1.5.6</version>
    </dependency>
    
    <!-- ModelMapper para mapear objetos para objetos automaticamente. -->
    <dependency>
    	<groupId>org.modelmapper</groupId>
    	<artifactId>modelmapper</artifactId>
    	<version>0.5.5</version>
    </dependency>
    
    <!-- dbcp Connection Pooling -->
    <dependency>
    	<groupId>commons-dbcp</groupId>
    	<artifactId>commons-dbcp</artifactId>
    	<version>1.4</version>
    </dependency>
    
    <!-- Base64 encoder/decoder -->
    <dependency>
    	<groupId>commons-codec</groupId>
    	<artifactId>commons-codec</artifactId>
    	<version>1.8</version>
    </dependency>
    
    <dependency>
    	<groupId>commons-collections</groupId>
    	<artifactId>commons-collections</artifactId>
    	<version>3.2.1</version>
    </dependency>
    <dependency>
    	<groupId>commons-lang</groupId>
    	<artifactId>commons-lang</artifactId>
    	<version>2.6</version>
    </dependency>
    
    
    <!-- Javax Mail -->
    <dependency>
    	<groupId>javax.mail</groupId>
    	<artifactId>mail</artifactId>
    	<version>1.4.7</version>
    </dependency>
    
    
    <!-- Tests -->
    <dependency>
    	<groupId>org.mockito</groupId>
    	<artifactId>mockito-all</artifactId>
    	<version>1.9.5</version>
    	<scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>junit</groupId>
    	<artifactId>junit</artifactId>
    	<version>4.10</version>
    	<scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>org.powermock</groupId>
    	<artifactId>powermock-module-junit4</artifactId>
    	<version>1.5</version>
    	<scope>test</scope>
    </dependency>
    <dependency>
    	<groupId>org.powermock</groupId>
    	<artifactId>powermock-api-mockito</artifactId>
    	<version>1.5</version>
    	<scope>test</scope>
    </dependency>
    
    <!-- API para trabalhar com datas -->
    <dependency>
    	<groupId>joda-time</groupId>
    	<artifactId>joda-time</artifactId>
    	<version>2.2</version>
    </dependency>
    </dependencies>
    On my applicationContext.xml i have:

    Code:
    <bean id="velocityConfig"
    		class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
    		<property name="resourceLoaderPath" value="/WEB-INF/views/" />
    	</bean>
    
    <bean id="viewResolver"
    		class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"
    		p:layoutUrl="layout.jsp" p:suffix=".jsp" />

    And when i run the application i get an error:

    Code:
    GRAVE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emailTask': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.web.servlet.view.velocity.VelocityConfigurer] for bean with name 'velocityConfig' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory
    	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
    	...
    Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.web.servlet.view.velocity.VelocityConfigurer] for bean with name 'velocityConfig' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory
    	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1278)
    	... 43 more
    Caused by: java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	... 57 more
    Caused by: java.lang.ClassNotFoundException: org.springframework.ui.velocity.VelocityEngineFactory
    	... 73 more

    So... I need help! Any ideas?
Working...
X