IBM Support

Duplicate classes in managed assets can cause issues like NoSuchMethodException

Troubleshooting


Problem

When you execute your business process, you see a NoSuchMethodException in the Java service. For example:

java.lang.NoSuchMethodException: MyCustomClass.method(java.lang.String, java.lang.String, long) 
at java.lang.Class.throwNoSuchMethodException(Class.java:429) 
at java.lang.Class.getMethod(Class.java:1106) 
at teamworks.connector.JavaReflectionConnector$1.execute(JavaReflectionConnector.java:84) 
at com.lombardisoftware.server.core.ManagedAssetClassLoaderUtil.executeWithManagedAssetClassLoader(ManagedAssetClassLoaderUtil.java:58) 
at teamworks.connector.JavaReflectionConnector.execute(JavaReflectionConnector.java:56) 
at com.lombardisoftware.component.javaconnector.worker.JavaConnectorWorker.invokeJavaMethod(JavaConnectorWorker.java:153)
 
 

This exception seems to be related to one of your service flows that uses the Java connector to call MyCustomClass.method.

You check the Java integration and class but it appears to contain the proper method definition.

Symptom

You might also have other symptoms that suggest the code executing at the runtime does not match what is expected. The behavior can be inconsistent across nodes and environments. The behavior might even change after you upgrade the product.

Cause

If your code is correct, then the issue can be caused by duplicate classes loaded into the system.

The classloader can load only one particular class for a particular scope. If there are multiple versions of the class, then it is partially random which version gets loaded. This behavior could lead to scenarios where you see the error only in some of your environments.

So for example if your application contains these two JAR files:

  1. ManagedAsset1.jar that contains MyCustomClass with a method definition of method(java.lang.String, java.lang.String, long)
  2. ManagedAsset2.jar that contains MyCustomClass with a method definition of method(java.lang.String, java.lang.String, long, java.lang.String)

If the class from ManagedAsset2.jar is loaded, then you would get the mentioned exception. Although if the class from ManagedAsset1.jar is loaded, then everything works.

Resolving The Problem

To resolve the issue, you need to find the duplicate class and remove it. Check all of the managed asset JAR files for an impacted process application and its toolkits to ensure there are no duplicated classes.
There are also cases where you might be conflicting with product JAR files for certain third-party libraries. If this situation occurs, you need to modify your code to ensure it doesn't have a conflict.
You might want to consider some development governance to ensure class names are not duplicated in various JAR files. You also need to ensure that old versions of a managed asset JAR file do not get accidentally included in the application.
These problems can be difficult to debug issues so it is important to ensure that you are not duplicating classes in your managed assets.

Document Location

Worldwide

[{"Line of Business":{"code":"LOB45","label":"Automation"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SS8JB4","label":"IBM Business Automation Workflow"},"ARM Category":[{"code":"a8m50000000CcZRAA0","label":"Development Tools-\u003ERepository-\u003Emanaged assets"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"},{"Line of Business":{"code":"LOB45","label":"Automation"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSFPJS","label":"IBM Business Process Manager"},"ARM Category":[{"code":"a8m50000000CcZRAA0","label":"Development Tools-\u003ERepository-\u003Emanaged assets"}],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Document Information

Modified date:
14 September 2022

UID

ibm16394638