You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jaspersoft Studio 6.21.2使用旧版StringUtils问题及修复咨询

Jaspersoft Studio 6.21.2 StringUtils版本冲突问题排查

我使用Jaspersoft Studio 6.21.2开发报表,某字段的取值表达式为:

StringUtils.defaultIfBlank($P{SEARCH_CRITERIA_STRING}, "")

由于defaultIfBlank方法是commons-lang的StringUtils类在2.6版本才新增的,我已将commons-lang-2.6.jar作为外部JAR包添加到项目中,但编译报表时仍报错:

The defaultIfBlank(String) method is not defined for type StringUtils

可见Studio仍在加载旧版本的StringUtils。

排查过程

  • 在Jaspersoft Studio安装目录的Jaspersoft Studio-6.21.2\configuration\org.eclipse.osgi\20\0\.cp\lib路径下,发现velocity-1.7-dep.jar中包含一个不支持defaultIfBlank方法的StringUtils类,版本早于2.6。但删除该JAR包并重启Studio后,问题依旧。
  • 为确认当前加载的StringUtils版本,我添加了一个字段,表达式如下:
StringUtils.class.getCanonicalName() + ", version " +
StringUtils.class.getPackage().getImplementationVersion() + "\n" +
StringUtils.class.getClassLoader().getResource("org/apache/commons/lang/StringUtils.class")

输出结果显示,Studio仍在使用1.7版本的类:

org.apache.commons.lang.StringUtils, version 1.7
bundleresource://21.fwk717974650:1/org/apache/commons/lang/StringUtils.class

更新进展

  • 更新1:@tpiec的建议部分解决问题:无需删除或替换velocity-1.7-dep.jar,只需删除该JAR包内的commons文件夹即可。
  • 更新2:删除commons文件夹后,Dataset and Query对话框无法加载WordUtils类,该对话框似乎不使用项目库,无法从手动添加的commons-lang-2.6.jar中加载该类。

内容的提问来源于stack exchange,提问作者Jorge Campins

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 16:16:05