本文介绍了POI 3.7 java.lang.IncompatibleClassChangeError 实例化字体时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到带有以下代码段的 java.lang.IncompatibleClassChangeError:

I am getting a java.lang.IncompatibleClassChangeError with the following snippet:

Workbook workbook = new HSSFWorkbook();
Font arial = workbook.createFont(); // java.lang.IncompatibleClassChangeError thrown here

我将 POI 3.7 与 WebSphere 7 Portal Server 一起使用.相同的代码(据我所知,相同的 jars)与 Netbeans 控制台应用程序一起工作.似乎 3.7 jar 是类路径中唯一的一个.该项目还使用 JasperReports 4.1.2.我可以提供更多信息吗?

I am using POI 3.7 with WebSphere 7 Portal Server. The same code (and as far as I can tell, the same jars) worked with Netbeans console application. It also seems that the 3.7 jar is the only one in the classpath. The project also uses JasperReports 4.1.2. Can I provide more information?

推荐答案

我几乎可以肯定您的类路径上有旧版本的 POI

I'm almost certain that you have an older version of POI on your classpath

POI 常见问题 中有一个部分专门介绍了这种情况.您将需要使用那里的代码来确定额外的 POI 副本来自何处,并清除旧 jar

There's a section in the POI FAQ that covers this very case. You'll want to use the code from there to identify where the extra copy of POI is coming from, and zap the old jar

这篇关于POI 3.7 java.lang.IncompatibleClassChangeError 实例化字体时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 07:32