我正在尝试使用以下代码创建类javax.servlet.ServletException的实例
public class MyTroubleViewer {
public static void main(String[] args) {
javax.servlet.ServletException servletException = new javax.servlet.ServletException("Hello");
System.out.println(servletException.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
但我在创建时遇到异常:
Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException
...
Run Code Online (Sandbox Code Playgroud)
Maven帮助我依赖:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?