jeudi 9 juillet 2015

Servlet Exception during Unit Tests in Spring

I have a problem with my project. When I do unit test for Spring Controller using MockMvc and Mockito, I get following error:

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException

It happens due to the this.mockMvc = MockMvcBuilders.standaloneSetup(custCont).build();line. I'm using maven for my dependencies, here they are:

<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
</dependency>
<dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>3.2.3.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
             <groupId>javax</groupId>
             <artifactId>javaee-api</artifactId>
             <version>6.0</version>
    </dependency>
</dependencies>

If you need any more info on the matter, I'd be more than happy to provide. Please, help me figure out what's causing the error.

Aucun commentaire:

Enregistrer un commentaire