Resolving JAR file and class loading errors

Draft comment:
This topic is shared by BAW, CP4BA. Last updated on 2025-01-20 10:38
If a class loading error occurs while the CaseEventEmitter.war file is running, configure library sharing in the WebSphere® Application Server administration console.

About this task

JAR files not found in the class path
If you observe that events are not emitted and the following exception is thrown in the trace, see Completing post-installation tasks for the case event emitter.
javax.json.JsonException: org.apache.johnzon.core.JsonProviderImpl not found
    at com.ibm.oi.icm.event.emitter.IcmConfigurationProvider.reloadConfigurationIfModified(IcmConfigurationProvider.java:89)
    at com.ibm.oi.icm.event.emitter.IcmConfigurationProvider.<init>(IcmConfigurationProvider.java:60)
    at com.ibm.oi.icm.event.emitter.IcmOiEmitter.getIcmConfig(IcmOiEmitter.java:47)
    at com.ibm.oi.icm.event.emitter.IcmOiEmitter.run(IcmOiEmitter.java:78)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:319)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:191)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.lang.Thread.run(Thread.java:812)
Caused by: javax.json.JsonException: org.apache.johnzon.core.JsonProviderImpl not found
    at javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:132)
    at javax.json.spi.JsonProvider.provider(JsonProvider.java:64)
    at javax.json.Json.createReader(Json.java:68)
    at com.ibm.dba.bai.events.icm.IcmBusinessEventUtil.parseObjectFromJsonString(IcmBusinessEventUtil.java:229)
    at com.ibm.oi.icm.event.emitter.IcmConfigurationProvider.reloadConfigurationIfModified(IcmConfigurationProvider.java:82)
    ... 10 more
Caused by: java.lang.ClassCastException: Cannot cast class org.apache.johnzon.core.JsonProviderImpl to class javax.json.spi.JsonProvider
    at java.lang.Class.cast(Class.java:2622)
    at javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:130)
    ... 14 more
Class loading errors
Errors of type java.lang.NoSuchMethodError indicate class loading errors. Such errors are usually caused by the classes of a JAR file inside the emitter conflicting with the classes that are used by the application server, as shown in the following trace sample. In this case, go through the Procedure that follows.
SRVE0283E: Exception caught while initializing context: java.lang.NoSuchMethodError: javax.json.Json.createPointer(Ljava/lang/String;)Ljavax/json/JsonPointer;
    at com.ibm.dba.oi.events.SimpleJsonPath.toJsonPointer(SimpleJsonPath.java:237)
    at com.ibm.dba.oi.events.BusinessEvent.get(BusinessEvent.java:92)
    at com.ibm.dba.oi.events.BusinessEvent.getAsString(BusinessEvent.java:123)
    at com.ibm.dba.oi.events.BusinessEvent.getAsStringNotNull(BusinessEvent.java:151)
    at com.ibm.dba.oi.events.icm.IcmEvent.getIcmSolutionName(IcmEvent.java:29)
    at com.ibm.oi.icm.event.emitter.IcmOiEmitter.recordLatestEvents(IcmOiEmitter.java:542)
    at com.ibm.oi.icm.event.emitter.IcmOiEmitter.run(IcmOiEmitter.java:296)
    ..

Procedure

  1. Copy the conflicting JAR files to a directory.

    For example, copy geronimo-json_1.1_spec-1.0.jar to C:\sharedLib.

  2. Open the WebSphere Application Server administration console and select Environment > Shared Libraries.
  3. Define the scope for the shared library by selecting the cell and node where your application is deployed.
  4. Click New and enter a name and a class path in the page that is displayed.

    For example, enter emitterLib as the name and C:\sharedLib as the class path.

    Leave the Use an isolated class loader for this shared library checkbox cleared.

  5. Open the deployed emitter application.
    1. Browse to Applications > Application Types > Websphere Enterprise Applications.
    2. Under References, click Shared Library References.
    3. Select the checkbox for the emitter application and click Reference Shared Libraries.
    4. In the page that opens, select the emitterLib class name that you created in step 4.
  6. Restart the application for the changes to take effect.