java.lang.ClassFormatError - 이클립스에서 JUnit 테스트 실행시 발생

기타|2012. 6. 4. 13:43

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

Maven dependency에 아래와 같이 javaee-web-api가 설정되어 있을 때 발생함

<dependency>  
   <groupId>javax</groupId>  
   <artifactId>javaee-web-api</artifactId>  
   <version>6.0</version>  
   <scope>provided</scope>  
</dependency>

아래와 같이 tomcat-servlet-api로 대체하면 오류가 사라진다.

<dependency>  
   <groupId>org.apache.tomcat</groupId>  
   <artifactId>tomcat-servlet-api</artifactId>  
   <version>7.0.8</version>  
   <scope>provided</scope>  
</dependency>

참고링크

http://www.oracle.com/technetwork/articles/java/unittesting-455385.html

The standard Java EE 6 APIs in the Maven repository were processed by a tool, which removes the method body implementation from the bytecode and makes the javaee-web-api dependency unusable for unit testing.

댓글()