Shaded Jar, Guice and Bouncy Castle JCE provider

275 views
Skip to first unread message

Jason Dusek

unread,
May 15, 2015, 2:44:49 PM5/15/15
to keywhi...@googlegroups.com
When trying to start the Keywhiz server, we see:

DEBUG [2015-05-15 18:42:24,874] keywhiz.KeywhizService: No existing guice injector; creating new one

Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider

        at keywhiz.ServiceModule.configure(ServiceModule.java:83)

        at com.google.inject.AbstractModule.configure(AbstractModule.java:62)

        at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:253)

        at com.google.inject.spi.Elements.getElements(Elements.java:108)

        at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:135)

        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)

        at com.google.inject.Guice.createInjector(Guice.java:96)

        at com.google.inject.Guice.createInjector(Guice.java:73)

        at com.google.inject.Guice.createInjector(Guice.java:62)

        at keywhiz.KeywhizService.run(KeywhizService.java:151)

        at keywhiz.KeywhizService.run(KeywhizService.java:77)

        at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:42)

        at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:76)

        at io.dropwizard.cli.Cli.run(Cli.java:70)

        at io.dropwizard.Application.run(Application.java:73)

        at keywhiz.KeywhizService.main(KeywhizService.java:84)

Caused by: java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider

        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

        ... 16 more

This is even when explicitly including the bcprov Jar on the classpath:

java -classpath bcprov-jdk15on-1.52.jar -jar keywhiz-server-0.7.3-shaded.jar server keywhiz.yaml

Is there anything else we should be doing?

Jason Dusek

unread,
May 15, 2015, 3:48:55 PM5/15/15
to keywhi...@googlegroups.com
I had forgotten the tail of the classpath and the jar, where one silently overrode the other. But this seems to work:

java -classpath bcprov-jdk15on-1.52.jar:keywhiz-server-0.7.3-shaded.jar keywhiz.KeywhizService server keywhiz.yaml

So now I must ask: Is BouncyCastle omitted from the shaded jar due to export restrictions?


--
You received this message because you are subscribed to a topic in the Google Groups "keywhiz-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/keywhiz-users/CqLNCrhRo7E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to keywhiz-user...@googlegroups.com.
To post to this group, send email to keywhi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keywhiz-users/65092956-2ebc-4718-b112-492f268b6e3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin Cummins

unread,
May 15, 2015, 8:29:24 PM5/15/15
to Jason Dusek, keywhi...@googlegroups.com

The bcprov-jdk15on dependency is a JCE crypto provider, so it’s a signed JAR. If it was included in the shaded JAR the signature would be invalid or missing. Our convention is to have a lib-signed/ directory relative to the shaded JAR. If you put the bcprov-jdk15on JAR in that directory, you won’t have to call it out explicitly on the classpath.


--
You received this message because you are subscribed to the Google Groups "keywhiz-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keywhiz-user...@googlegroups.com.

To post to this group, send email to keywhi...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages