Is Jaspersoft Studio 6.21.2 using an old version of StringUtils? How to fix that?

49 views Asked by At

I am using Jaspersoft Studio 6.21.2. My project has a report that has a field with this value expression:

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

The method defaultIfBlank was added to version 2.6 of StringUtils, so I added commons-lang-2.6.jar as an external jar to my project.

Compiling the report produces the following error: The defaultIfBlank(String) method is not defined for type StringUtils, as if Jaspersoft Studio was using an older version of StringUtils, even though the project has commons-lang-2.6.jar as an external jar.

I actually found a StringUtils class in velocity-1.7-dep.jar of "Jaspersoft Studio-6.21.2 \ configuration \ org.eclipse.osgi \ 20 \ 0 \ .cp \ lib" directory. And as expected, that class does not have the method defaultIfBlank, so it must be from a version prior to 2.6.

Even after deleting that velocity-1.7-dep.jar and restarting Jaspersoft Studio, the problem persisted. I could not find another StringUtils class in another jar in Jaspersoft Studio directory. That left me with no idea where the StringUtils class comes from. So I added another field to the report with this value expression:

StringUtils.class.getCanonicalName() + ", version " +
StringUtils.class.getPackage().getImplementationVersion() + "\n" +
StringUtils.class.getClassLoader().getResource("org/apache/commons/lang/StringUtils.class")

This is the output:

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

So it seems it keeps using the same old version of the StringUtils class. There must be some way to make Studio use the StringUtils class in commons-lang-2.6.jar, but I haven't been able to find it yet. I would really appreciate some help solving this problem.

UPDATE: @tpiec answer partially solves the problem (see next update). The velocity-1.7-dep.jar should not be deleted nor replaced; its commons folder should be deleted.

UPDATE: After deleting the commons folder the Dataset and Query dialog does not work; it fails to load WordUtils. It looks like that dialog does not use the project libraries and therefore cannot load WordUtils from the manually added commons-lang-2.6.jar

0

There are 0 answers