Conflict with commons lib

Hi,

I want to use Apache commons-io V2.4 in a java service. My code works fine in standalone (not webMethods) mode but when I put it on an IS I got an « invocationTargetException ».

After a few research I find an older (V1.4) version of this libraries in « /webMethods/v95/common/lib/ext/ ». To confirm my idea I replace this lib by the recent one and evry thing works fine. Unfortunately this solution is not acceptable as it may cause impact on others ‘apps or on the IS itself.

Is there any way to use my javaservice with the commons-io in the « /code/jar » folder instead of « /webMethods/v95/common/lib/ext/ » ‘s one ?

Thanks a lot for answers

Packages in IS have their own class loaders, so …\code\jars\ respectively …\code\jars\static are the place to stores jars used for won coding.
/v95/common/lib/ext is for jars used across different webMethods components and shouldn’t used anyway for own coding. For jars used across different packages of IS there is still \instances<instance>\lib\jars, but this too should only be used if a jar is really needed across IS packages and do not interfere with existing ones.

Try placing the jar within the package level …\code\jars\ or …\code\jars\static OR at the IS level (IS/config/lib/jars)

I have made a new package called « XX_TESTS » to check this point. In this package I create two java services,

  • fist one calling “org.apache.commons.io.FileUtils.sizeOfDirectory(directory)” (exist in commons-IO 1.4)
  • second one calling “org.apache.commons.io.FileUtils. sizeOfDirectoryAsBigInteger (directory)” (new methods since commons-IO 2.4)

I got the same result in all case :

  • No jar provided at all
  • Jar commons-io 2.4 in “/opt/webMethods/v95/IntegrationServer/packages/XX_TESTS/code/jars/”
  • Jar commons-io 2.4 in “/opt/webMethods/v95/IntegrationServer/packages/XX_TESTS/code/jars/static” (this folder was absent, I create it)
  • Jar commons-io 2.4 in “/opt/webMethods/v95/IntegrationServer/lib/jars/
    (with package / IS reload when config change).

In these four case :

  • first service compile fine and give expected result.
  • second service does not compile : “error: cannot find symbol - symbol: method sizeOfDirectoryAsBigInteger(File) - location: class FileUtils”

Should this be a classloader order config error ? I got a similar problems a few years ago with a WebSphere J2EE server and his “parent first” / “parent last” config ?

Thanks for your help

This happens particularly when the first jar file is being recognized in class path and it tries searching the function in 1st jar file and when it does not find it, it throws the error.

You can check which this:

import java.net.;
import org.apache.commons.io.
;

String path= org.apache.commons.io.FileUtils.class.getProtectionDomain().getSourceCode().getLocation().getPath();
String decodedPath= URLDecoder.decode(path,“UTF-8”);