2018-03-27 22:14:04 UTC - Igor Zubchenok: Hello
I have a real challenge to build my final jar with Pulsar client dependency.
Build succeeds, but when I run my jar file I have 'Error: Could not find or 
load main class'.
All works if I remove the Pulsar dependency.
Could anyone help me with some guide how to understand the problem and find a 
solution??? Please!
----
2018-03-27 22:25:59 UTC - Piotr: I assume you have dissected the jar? Unrared 
it and checked its contents?
----
2018-03-27 22:47:04 UTC - Igor Zubchenok: I checked it has all contents and my 
main and other classes as well as pulsar classes.
----
2018-03-27 22:47:52 UTC - Matteo Merli: are you using shade plugin to get a fat 
jar?
----
2018-03-27 22:48:21 UTC - Matteo Merli: can you compare the list of classes 
included in both cases?
----
2018-03-27 22:50:28 UTC - Igor Zubchenok: I have fat jar with such gradle config
```
jar {
    manifest {
        attributes "Main-Class": "com.zubchenok.EntryPoint"
    }

    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    }
}
```

Going to compare set of files now...
----
2018-03-27 23:05:07 UTC - Igor Zubchenok: Ok, I have file comparison. When I 
add the dependency, new files added to jar.
----
2018-03-27 23:05:22 UTC - Igor Zubchenok: Nothing missed.
----
2018-03-27 23:11:51 UTC - Piotr: checked the manifest?
----
2018-03-27 23:13:30 UTC - Igor Zubchenok: of cause, it's exactly the same
----
2018-03-27 23:32:45 UTC - Igor Zubchenok: Seems the issue with some transitive 
dependency...
----
2018-03-27 23:49:17 UTC - Igor Zubchenok: I found pulsar-client has the 
following dependencies:
```\--- org.apache.pulsar:pulsar-client:1.22.0-incubating
     +--- org.slf4j:slf4j-api:1.7.25
     +--- org.bouncycastle:bcpkix-jdk15on:1.55
     |    \--- org.bouncycastle:bcprov-jdk15on:1.55
     \--- org.bouncycastle:bcprov-jdk15on:1.55
```

I don't have org.bouncycastle dependency anywhere, but I use 
cassandra-driver-core and it has a dependency to org.slf4j:slf4j-api:1.7.25
The same version anyway.
----
2018-03-27 23:50:27 UTC - Matteo Merli: Yes, it’s already a “fat” jar, all the 
usually problematic dependencies are already shaded
----
2018-03-27 23:50:53 UTC - Matteo Merli: you can exclude bouncycastle if you’re 
not going to enable encryption
----
2018-03-27 23:51:04 UTC - Igor Zubchenok: I'll try
----
2018-03-27 23:54:55 UTC - Igor Zubchenok: like a magic :star-struck:
----
2018-03-28 00:01:01 UTC - Igor Zubchenok: Thank you very much for suggestion. I 
still don't know the real reason why it fails anyway.
I have one more question:
My jar grows from from ~30mb to 51mb with pulsar-client and to 65mb with 
pulsar-client and pulsar-client-admin-original.
Why is it so big dependency?
----
2018-03-28 00:01:38 UTC - Matteo Merli: they’re both shading all the 
dependencies
----
2018-03-28 00:02:41 UTC - Matteo Merli: probably many classes could be stripped 
by using the “minimizeJar” option, though it’s tricky to get a real sense of 
whether it’s really working or if it will be missing some used classes
----
2018-03-28 00:24:14 UTC - Igor Zubchenok: I really appreciate your help!
----
2018-03-28 00:57:33 UTC - Matteo Merli: No prob, you're welcome
----

Reply via email to