当我将jre从1.6更新到1.8,但不重新编译类文件时。错误发生java.lang.IncompatibleClassChangeError:类[Ljava.lang.StackTraceElement;没有实现请求的接口java.util.List
就我的尝试而言,我得到的结果是粗麻布不兼容。 通过在官方网站(http://hessian.caucho.com/doc/hessian-overview.xtp)中使用简单的hessian示例,并通过jdk 1.6编译Java文件,然后在jre 1.8中运行类文件。当服务器抛出异常时,该错误再次发生。
Client.java
public class Client {
public static void main(String[] args) {
try {
String url = "http://127.0.0.1:8080/BasicService";
HessianProxyFactory factory = new HessianProxyFactory();
BasicAPI basic = null;
basic = (BasicAPI) factory.create(BasicAPI.class, url);
String result = basic.hello();
System.out.println("hello(): " + result);
} catch (Exception e) {
e.printStackTrace();
}catch (Throwable t){
t.printStackTrace();
}
}
}
BasicAPI.java
public interface BasicAPI {
public String hello();
}
BasicService.java
public class BasicService extends HessianServlet implements BasicAPI {
private String _greeting = "Hello, world";
public void setGreeting(String greeting)
{
_greeting = greeting;
}
public String hello()
{
try{
Integer i = Integer.parseInt("ss");
}catch (Exception e){
throw new RuntimeException("aaaaaaa");
}
return _greeting;
}
}
异常信息
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy0.hello(Unknown Source)
at applicationFunction.hessian.helloWorld.Client.main(Client.java:16)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:298)
at com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:194)
at com.caucho.hessian.server.HessianServlet.service(HessianServlet.java:372)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "main" java.lang.IncompatibleClassChangeError: Class [Ljava.lang.StackTraceElement; does not implement the requested interface java.util.List
at java.lang.Throwable.getSuppressed(Throwable.java:1079)
at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:702)
at java.lang.Throwable.printStackTrace(Throwable.java:667)
at java.lang.Throwable.printStackTrace(Throwable.java:643)
at java.lang.Throwable.printStackTrace(Throwable.java:634)
at applicationFunction.hessian.helloWorld.Client.main(Client.java:19)
客户端接受RuntimeException而不是IncompatibleClassChangeError。