Search code examples
javaspringspring-mvcapplicationcontext

java.lang.NoClassDefFoundError: org.mvel2.integration.VariableResolverFactory


I am getting this runtime error from the project

[12/5/18 11:54:35:045 EST] 00000104 XmlWebApplica W org.springframework.context.support.AbstractApplicationContext refresh Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/applicationsweb-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org.mvel2.integration.VariableResolverFactory
[12/5/18 11:54:35:048 EST] 00000104 DispatcherSer E org.springframework.web.servlet.FrameworkServlet initServletBean Context initialization failed
                                 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/applicationsweb-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org.mvel2.integration.VariableResolverFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

My ApplicationContext looks like this,

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Resolves views selected for rendering by @Controllers to tiles resources -->
    <beans:bean id="viewResolver" class="org.springframework.web.servlet.view.tiles3.TilesViewResolver"/>

    <beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer" >       
        <beans:property name="completeAutoload" value="true"/>
        <beans:property name="definitions">
            <beans:list>
                  <beans:value>/WEB-INF/defs/tiles-defs.xml</beans:value>                 
            </beans:list>
        </beans:property>
    </beans:bean>
</beans:beans>

I have my spring-webmvc-4.2.6.RELEASE.jar in webInf lib as well as the EAR lib. Any suggestions please?


Solution

  • Error is telling that it could not find some class it means you don't have some jar where the class is located

    Just add this jar file: https://mvnrepository.com/artifact/org.mvel/mvel2