Issue 3084: java.lang.ClassNotFoundException: org.bouncycastle.openssl.PEMReader
Status:  Released
Owner: ----
Closed:  Feb 2015
Reported by zhongjie...@gmail.com, Jan 4, 2015
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.    *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS!  *****
************************************************************

Affected Version:2.9.4

What steps will reproduce the problem?
1.upgrade from 2.8.3 to 2.9.4
2.gerrit.sh start
3. start failed

What is the expected output? What do you see instead?
[2015-01-04 18:43:12,878] ERROR com.google.gerrit.pgm.Daemon : Unable to start daemon
java.lang.NoClassDefFoundError: org/bouncycastle/openssl/PEMReader
        at com.google.gerrit.sshd.HostKeyProvider.get(HostKeyProvider.java:75)
        at com.google.gerrit.sshd.HostKeyProvider.get(HostKeyProvider.java:31)
        at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
        at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:73)
        at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:66)
        at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:63)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1066)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
        at com.google.inject.Scopes$1$1.get(Scopes.java:65)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:107)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:88)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:269)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1066)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
        at com.google.inject.Scopes$1$1.get(Scopes.java:65)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
        at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
        at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
        at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:107)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:88)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:269)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1066)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
        at com.google.inject.Scopes$1$1.get(Scopes.java:65)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
        at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1066)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
        at com.google.inject.Scopes$1$1.get(Scopes.java:65)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
        at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
        at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1059)
        at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
        at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
        at com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:225)
        at com.google.gerrit.pgm.Daemon.createSshInjector(Daemon.java:394)
        at com.google.gerrit.pgm.Daemon.initSshd(Daemon.java:380)
        at com.google.gerrit.pgm.Daemon.start(Daemon.java:284)
        at com.google.gerrit.pgm.Daemon.run(Daemon.java:203)
        at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:64)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:166)
        at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:93)
        at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:50)
        at Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.openssl.PEMReader
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 58 more
                                                                                    


Please provide any additional information below.

Jan 7, 2015
Project Member #1 huga...@gmail.com
When you ran the init, did it downloaded the bouncycastle jars? Can you validate that you have those 2 jars in your [gerrit_site]/lib directory: bcpkix-jdk15on-149.jar  bcprov-jdk15on-149.jar
Jan 11, 2015
#2 zhongjie...@gmail.com
yes, It downloaded the two jars, I unzipped the two jars, there is no
PEMReader class in the two jars.
and I hvae tried install gerrot-2.9.4.war in a new server, it's ok
It looks like just there is a problem in the upgrade. I replace the two jar
with bcprov-jdk15-140.jar, then this problem is gone.
Jan 16, 2015
#3 zhongjie...@gmail.com
yes,I downloaded the two jars, I.have tried a new install in a new server,
it's ok. but this upgrade failed.
2015-1-7 下午10:18于 <gerrit@googlecode.com>写道:
Jan 21, 2015
Project Member #4 david.pu...@sonymobile.com
On the upgraded server are the old bouncycastle jar files still in the $SITE/lib folder?

Feb 26, 2015
#5 tsu...@lagat.org
I know this is old, but I had the same issue when upgrading to 2.11-rc0 and removing everything from $SITE/lib before initializing gerrit fixed it, so thanks, David.
Feb 26, 2015
Project Member #6 david.pu...@sonymobile.com
Thanks for confirmation.  I'll look into how this can be improved.  At the very least, we can mention this in the release notes.

Feb 26, 2015
Project Member #7 david.pu...@sonymobile.com
https://gerrit-review.googlesource.com/#/c/65491/
Status: ChangeUnderReview
Feb 27, 2015
Project Member #8 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Submitted
Labels: FixedIn-2.11
Apr 16, 2015
Project Member #9 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: Released