'OSGi - ClassNotFoundException: org.openqa.selenium.logging.LoggingHandler cannot be found by org.seleniumhq.selenium.remote-driver_3.4.0
I am using plugins org.seleniumhq.selenium.api_3.4.0 and org.seleniumhq.selenium.remote-driver_3.4.0 which were created from respective jars in my OSGi project. While executing the tests I am getting the below exception.
[NoClassDefFoundError: org/openqa/selenium/logging/LoggingHandler, ClassNotFoundException: org.openqa.selenium.logging.LoggingHandler cannot be found by org.seleniumhq.selenium.remote-driver_3.4.0
Stack Trace:
java.lang.ClassNotFoundException: org.openqa.selenium.logging.LoggingHandler cannot be found by org.seleniumhq.selenium.remote-driver_3.4.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:464)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:171)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
As per my analysis, the issue is coming because the package org.openqa.selenium.logging is present in both org.seleniumhq.selenium.api_3.4.0 and org.seleniumhq.selenium.remote-driver_3.4.0 jars and the LoggingHandler class is present in org.seleniumhq.selenium.remote-driver_3.4.0 jar only. While installing the bundles during startup, the org.seleniumhq.selenium.api_3.4.0 is installed first. So while searching for the class at runtime, the class loader could not find the LoggingHandler class in the plugin org.seleniumhq.selenium.api_3.4.0.
Upgrading the version might resolve the issue because the class LoggingHandler is present in higher versions of org.seleniumhq.selenium.api_3.4.0 jar but I cannot upgrade the version because of other dependency issues.
Is there any other way in OSGi/RCP world to specify which plugin to refer while trying to find the class at runtime. One way which is suggested usually is to specify the version of the import package in Manifest.MF file but here the version of both the jars is same.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
