apache / pulsar

Apache Pulsar - distributed pub-sub messaging system
https://pulsar.apache.org/
Apache License 2.0
14.12k stars 3.57k forks source link

[Bug] Getting class not found exception when I try to initialise PulsarClient/PulsarAdmin #21296

Open selvatlc opened 11 months ago

selvatlc commented 11 months ago

Search before asking

Version

Environments

 karaf - 4.4.3
openjdk version "17.0.6" 2023-01-17
 Maven - 3.9.1

Used Dependencies

        <dependency>
            <groupId>org.apache.pulsar</groupId>
            <artifactId>pulsar-client-all</artifactId>
            <version>3.1.0</version>
        </dependency>

Sample Snippet

        pulsarAdmin = PulsarAdmin.builder().serviceHttpUrl(adminUrl).build();
        pulsarClient = PulsarClient.builder().serviceUrl(clientUrl).build();

Minimal reproduce step

When I try to execute the code by creating a normal JAR and execute it on terminal using java -jar , i'm getting valid response.

If i create an OSGI bundle and installed my code on KARAF, i'm getting class not found exception. Need your help on this

What did you expect to see?

Pulsar client and admin should be created without making any errors

What did you see instead?


java.lang.ClassNotFoundException: org.apache.pulsar.client.api.PulsarClient not found by wrap_file__Users_kumarselvadg_.m2_repository_org_apache_pulsar_pulsar-client-all_3.1.0_pulsar-client-all-3.1.0.jar [201]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1591)
    at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1976)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1358)
    at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1612)
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1528)
    at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1976)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:375)
    at com.tlc.queue.internal.pulsar.PulsarService.start(PulsarService.java:67)
    at com.tlc.queue.QueueAccess.start(QueueAccess.java:92)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:849)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2429)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2335)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:1006)
    at org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38)
    at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:65)
    at org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:55)
    at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
    at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
    at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
    at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
    at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
    at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
    at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
    at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

Anything else?

No response

Are you willing to submit a PR?

michalcukierman commented 11 months ago

The bug is not with the Pulsar Clients, but with the way you've created the bundle. Please check the answer I've provided you in the discussion you've opened.

github-actions[bot] commented 10 months ago

The issue had no activity for 30 days, mark with Stale label.