Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-34930

ClassCastException when trying to start ssh-agent

    Details

    • Similar Issues:

      Description

      I'm getting the following Exception stack trace when in my build log:

      FATAL: [ssh-agent] Unable to start agent
      hudson.util.IOException2: [ssh-agent] Unable to start agent
      	at com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper.createSSHAgentEnvironment(SSHAgentBuildWrapper.java:231)
      	at com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper.preCheckout(SSHAgentBuildWrapper.java:189)
      	at jenkins.scm.SCMCheckoutStrategy.preCheckout(SCMCheckoutStrategy.java:76)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
      	at hudson.model.Run.execute(Run.java:1741)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)
      Caused by: java.lang.RuntimeException: Failed to register BouncyCastle as the defaut JCE provider
      	at org.apache.sshd.common.util.SecurityUtils.register(SecurityUtils.java:102)
      	at org.apache.sshd.common.util.SecurityUtils.isBouncyCastleRegistered(SecurityUtils.java:81)
      	at com.cloudbees.jenkins.plugins.sshagent.jna.JNRRemoteAgent.addIdentity(JNRRemoteAgent.java:80)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:884)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:859)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:818)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:152)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
      	at hudson.remoting.Request$2.run(Request.java:332)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      	at ......remote call to New jenkins slave (i-2bd55aa7)(Native Method)
      	at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
      	at hudson.remoting.UserResponse.retrieve(UserRequest.java:252)
      	at hudson.remoting.Channel.call(Channel.java:781)
      	at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:249)
      	at com.sun.proxy.$Proxy81.addIdentity(Unknown Source)
      	at com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper$SSHAgentEnvironment.<init>(SSHAgentBuildWrapper.java:339)
      	at com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper.createSSHAgentEnvironment(SSHAgentBuildWrapper.java:224)
      	... 7 more
      Caused by: java.lang.InternalError: cannot create instance of org.bouncycastle.jcajce.provider.symmetric.IDEA$Mappings : java.lang.ClassCastException: org.bouncycastle.jcajce.provider.symmetric.IDEA$Mappings cannot be cast to org.bouncycastle.jcajce.provider.util.AlgorithmProvider
      	at org.bouncycastle.jce.provider.BouncyCastleProvider.loadAlgorithms(Unknown Source)
      	at org.bouncycastle.jce.provider.BouncyCastleProvider.setup(Unknown Source)
      	at org.bouncycastle.jce.provider.BouncyCastleProvider.access$000(Unknown Source)
      	at org.bouncycastle.jce.provider.BouncyCastleProvider$1.run(Unknown Source)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(Unknown Source)
      	at org.apache.sshd.common.util.SecurityUtils$BouncyCastleRegistration.run(SecurityUtils.java:114)
      	at org.apache.sshd.common.util.SecurityUtils.register(SecurityUtils.java:96)
      	at org.apache.sshd.common.util.SecurityUtils.isBouncyCastleRegistered(SecurityUtils.java:81)
      	at com.cloudbees.jenkins.plugins.sshagent.jna.JNRRemoteAgent.addIdentity(JNRRemoteAgent.java:80)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:884)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:859)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:818)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:152)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
      	at hudson.remoting.Request$2.run(Request.java:332)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      I did add this line to my java.security file but that didn't help:

      security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider
      

        Attachments

          Issue Links

            Activity

            Hide
            b2jrock b2jrock added a comment -

            If you have the docker-buildstep plugin enabled, you might want to try disabling it.

            Both these plugins include the bouncycastle provider, but they might not have compatible versions:
            /var/lib/jenkins/plugins/ssh-agent/WEB-INF/lib/bcprov-jdk15on-1.53.jar
            /var/lib/jenkins/plugins/docker-build-step/WEB-INF/lib/bcprov-jdk15on-1.51.jar

            Show
            b2jrock b2jrock added a comment - If you have the docker-buildstep plugin enabled, you might want to try disabling it. Both these plugins include the bouncycastle provider, but they might not have compatible versions: /var/lib/jenkins/plugins/ssh-agent/WEB-INF/lib/bcprov-jdk15on-1.53.jar /var/lib/jenkins/plugins/docker-build-step/WEB-INF/lib/bcprov-jdk15on-1.51.jar
            Hide
            bartvw bart van Wissen added a comment -

            I don't have that plugin, but I did a find plugins -name bcprov -print and discovered that there are two other plugins which come with bouncycastle:

            plugins/ec2/WEB-INF/lib/bcprov-jdk15-140.jar
            plugins/ssh-agent/WEB-INF/lib/bcprov-jdk15on-1.47.jar
            plugins/vagrant/WEB-INF/classes/vendor/gems/jruby/1.8/gems/bouncy-castle-java-1.5.0146.1/lib/bcprov-jdk15-146.jar
            

            I cannot disable the ec2 plugin though, because it manages our slaves.

            Show
            bartvw bart van Wissen added a comment - I don't have that plugin, but I did a find plugins -name bcprov -print and discovered that there are two other plugins which come with bouncycastle: plugins/ec2/WEB-INF/lib/bcprov-jdk15-140.jar plugins/ssh-agent/WEB-INF/lib/bcprov-jdk15on-1.47.jar plugins/vagrant/WEB-INF/classes/vendor/gems/jruby/1.8/gems/bouncy-castle-java-1.5.0146.1/lib/bcprov-jdk15-146.jar I cannot disable the ec2 plugin though, because it manages our slaves.
            Hide
            bartvw bart van Wissen added a comment -

            Removing the vagrant subdirectory seems to have done the trick. Thanks.

            Show
            bartvw bart van Wissen added a comment - Removing the vagrant subdirectory seems to have done the trick. Thanks.
            Hide
            matthiasbalke Matthias Balke added a comment -

            I have the same problem using a jenkins pipeline job. I'm using an unmodified JDK 8u121 which gets installed when launching the docker slave the pipeline is running on. That's why I have no option to manipulate paths or variables. Im using plugin version 1.8. But as this issue is not fixed, it seems that upgrading to the latest version won't help.

             

            So what can I do to use the plugin?

            Show
            matthiasbalke Matthias Balke added a comment - I have the same problem using a jenkins pipeline job. I'm using an unmodified JDK 8u121 which gets installed when launching the docker slave the pipeline is running on. That's why I have no option to manipulate paths or variables. Im using plugin version 1.8. But as this issue is not fixed, it seems that upgrading to the latest version won't help.   So what can I do to use the plugin?

              People

              • Assignee:
                Unassigned
                Reporter:
                bartvw bart van Wissen
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: