Java – HTTP Status 500 – Handler processing failed; nested exception is java.lang.NoClassDefFoundError:

javamavennoclassdeffounderrorspringtomcat

I'm trying to integrate external jar file into my project. (mambu-models-V3.8.10.jar)

But I receive such error message:

HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/mambu/loans/shared/model/LoanAccount    


org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/mambu/loans/shared/model/LoanAccount
org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1287)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)    

root cause:

java.lang.ClassNotFoundException: com.mambu.loans.shared.model.LoanAccount
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
java.lang.Class.getDeclaredMethods(Class.java:1962)
com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:662)
com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:356)
com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:151)
com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:585)
com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:543)
com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:529)
com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:847)
com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772)
com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256)
com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205)
com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:853)
com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:967)
com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1000)
com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:961)
com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013)
com.mambu.apisdk.MambuAPIFactory.getLoanService(MambuAPIFactory.java:86)
comm.app.starter.HomeController.Opaaaaana(HomeController.java:167)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:483)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:781)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:721)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)    

Here is my POM xml:

http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.springapp
kapiv2
war
1.0-SNAPSHOT
kapi

<properties>
    <spring.version>4.1.1.RELEASE</spring.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.mambu</groupId>
        <artifactId>mambumodels</artifactId>
        <version>3.8.10</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/lib/mambu-models-V3.8.10.jar
        </systemPath>
        <optional>false</optional>
    </dependency>
   <!-- <dependency>
        <groupId>com.cenqua.clover</groupId>
        <artifactId>clover</artifactId>
        <version>3.0.2</version>
    </dependency>-->

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.2.1</version>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>1.7.1</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>javax.jdo</groupId>
        <artifactId>jdo-api</artifactId>
        <version>3.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
        <version>3.0</version>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.8.5</version>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-dev</artifactId>
        <version>2.7.0</version>
    </dependency>
   <!-- <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>1.5.3</version>
    </dependency>-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.2.1</version>
    </dependency>

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.5</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <finalName>kapi</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

    </plugins>
</build>

There are a lot of results in google if you search NoClassDefFoundError – but none of them hellped me.

could you please tell me why I receive such error?
thanks

Best Solution

The problem was that jar file that was needed for running this function was missing in run time. So I added this to MAVEN

           <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/myTESTapplication/WEB-INF/lib</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                </execution>
            </executions>
        </plugin>