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

NullPointerException with jgit on Git Plugin 2.0 beta

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • 64 bit Debian Linux "testing" running Jenkins 1.509.2 in winstone container running on Oracle JDK 7

      Steps I used to see the issue:

      • installed Git Client plugin 1.1.1 and restarted Jenkins
      • downloaded and installed Git Plugin 2.0 beta and restarted Jenkins
      • executed several successful builds without changing configurations
      • confirmed those builds were correctly responding to build hooks
      • use configuration page to delete git as executable, add jgit
      • submitted another change to git repository, watched hooks activate

      No build from Jenkins, and a null pointer exception is in the log file.

      SEVERE: Failed to record SCM polling for hudson.model.FreeStyleProject@21d1ff77[p4-port-linux-Merge]
      java.lang.NullPointerException
      at org.jenkinsci.plugins.gitclient.trilead.TrileadSessionFactory.getSession(TrileadSessionFactory.java:34)
      at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
      at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
      at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
      at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
      at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
      at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1105)
      at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
      at org.jenkinsci.plugins.gitclient.JGitAPIImpl.fetch(JGitAPIImpl.java:299)
      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 hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:275)
      at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:256)
      at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:215)
      at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      at hudson.remoting.Request$2.run(Request.java:326)
      at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:724)

          [JENKINS-18957] NullPointerException with jgit on Git Plugin 2.0 beta

          Nikolas Falco added a comment -

          mee too with:

          • jenkins 1.526
          • Jenkins GIT client plugin 1.1.2
          • Jenkins GIT plugin 1.4.0

          the only solution is revert to 1.0.7

          Nikolas Falco added a comment - mee too with: jenkins 1.526 Jenkins GIT client plugin 1.1.2 Jenkins GIT plugin 1.4.0 the only solution is revert to 1.0.7

          Mark Waite added a comment - - edited

          I can't duplicate the problem with Jenkins 1.526, git client plugin 1.1.2, and git plugin 1.4.0. Can you provide more details (like a stack trace)?

          I did the following steps as part of my attempt to duplicate the problem:

          • install Jenkins 1.509.2
          • update to git client plugin 1.1.2 and git plugin 1.4.0
          • define a new job "job1" using the git plugin with an ssh URL
          • build "job1"
          • upgrade to Jenkins 1.526
          • define a new job "job2" using the git plugin with an ssh URL
          • build "job2"
          • build "job1" again

          Can you compare my steps with your steps and see if there are any obvious ways we differ?

          I was definitely not setting any command line arguments or environment variables to force the use of JGit from within the git 1.4.0 plugin, since my experience with JGit in the 1.4.0 plugin confirmed that it was not ready for production use.

          Mark Waite added a comment - - edited I can't duplicate the problem with Jenkins 1.526, git client plugin 1.1.2, and git plugin 1.4.0. Can you provide more details (like a stack trace)? I did the following steps as part of my attempt to duplicate the problem: install Jenkins 1.509.2 update to git client plugin 1.1.2 and git plugin 1.4.0 define a new job "job1" using the git plugin with an ssh URL build "job1" upgrade to Jenkins 1.526 define a new job "job2" using the git plugin with an ssh URL build "job2" build "job1" again Can you compare my steps with your steps and see if there are any obvious ways we differ? I was definitely not setting any command line arguments or environment variables to force the use of JGit from within the git 1.4.0 plugin, since my experience with JGit in the 1.4.0 plugin confirmed that it was not ready for production use.

          Nikolas Falco added a comment -

          No problem with a newer installation.

          I can not use plugin > 1.0.7 in production environment. I have also uninstall and reinstall plugin but nothing. Every old/new job has same problem on build (and polling):
          Building on master in workspace /home/builder/.jenkins/jobs/job1/workspace
          Checkout:workspace / /home/builder/.jenkins/jobs/job1/workspace - hudson.remoting.LocalChannel@57a3c2bf
          Using strategy: Default
          Cloning the remote Git repository
          [WARNING] JGit doesn't support reference repository. This flag is ignored.
          FATAL: null
          java.lang.NullPointerException
          at org.jenkinsci.plugins.gitclient.trilead.TrileadSessionFactory.getSession(TrileadSessionFactory.java:31)
          at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
          at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
          at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
          at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
          at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
          at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1105)
          at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
          at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178)
          at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)
          at org.jenkinsci.plugins.gitclient.JGitAPIImpl$3.execute(JGitAPIImpl.java:643)
          at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.clone(AbstractGitAPIImpl.java:57)
          at org.jenkinsci.plugins.gitclient.JGitAPIImpl.clone(JGitAPIImpl.java:98)
          at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1006)
          at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942)
          at hudson.FilePath.act(FilePath.java:906)
          at hudson.FilePath.act(FilePath.java:879)
          at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942)
          at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1108)
          at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:117)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1406)
          at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
          at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
          at hudson.model.Run.execute(Run.java:1597)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:247)

          Nikolas Falco added a comment - No problem with a newer installation. I can not use plugin > 1.0.7 in production environment. I have also uninstall and reinstall plugin but nothing. Every old/new job has same problem on build (and polling): Building on master in workspace /home/builder/.jenkins/jobs/job1/workspace Checkout:workspace / /home/builder/.jenkins/jobs/job1/workspace - hudson.remoting.LocalChannel@57a3c2bf Using strategy: Default Cloning the remote Git repository [WARNING] JGit doesn't support reference repository. This flag is ignored. FATAL: null java.lang.NullPointerException at org.jenkinsci.plugins.gitclient.trilead.TrileadSessionFactory.getSession(TrileadSessionFactory.java:31) at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121) at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248) at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147) at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1105) at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128) at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178) at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125) at org.jenkinsci.plugins.gitclient.JGitAPIImpl$3.execute(JGitAPIImpl.java:643) at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.clone(AbstractGitAPIImpl.java:57) at org.jenkinsci.plugins.gitclient.JGitAPIImpl.clone(JGitAPIImpl.java:98) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1006) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942) at hudson.FilePath.act(FilePath.java:906) at hudson.FilePath.act(FilePath.java:879) at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1108) at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:117) at hudson.model.AbstractProject.checkout(AbstractProject.java:1406) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581) at hudson.model.Run.execute(Run.java:1597) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:247)

          Nikolas Falco added a comment -

          The previous installation was under windows 7.
          To debug the problem I do another new installation under Ubuntu 12.10 linux develop machine and I have got the problem.

          Debugging in the working case the to org.eclipse.jgit.api.FetchCommand do the normal work, in the second case (not working) a call to org.jenkinsci.plugins.gitclient.trilead.TrileadSessionFactory.getSession was done where the credentialprovider passed from FetchCommand in the firm is null.

          Nikolas Falco added a comment - The previous installation was under windows 7. To debug the problem I do another new installation under Ubuntu 12.10 linux develop machine and I have got the problem. Debugging in the working case the to org.eclipse.jgit.api.FetchCommand do the normal work, in the second case (not working) a call to org.jenkinsci.plugins.gitclient.trilead.TrileadSessionFactory.getSession was done where the credentialprovider passed from FetchCommand in the firm is null.

          Mark Waite added a comment -

          The default for git plugin 1.4.0 and git client 1.1.2 is to use the git command line implementation rather than using the jgit implementation (at least as far as I understand it). However, your stack trace shows jgit is being used rather than the git command line implementation. Your stack trace also shows the multiSCM plugin in the stack trace, while the original stack trace does not show that.

          You might try disabling or removing the MultiSCM plugin to see if that fixes the issue.

          You might also check that there are no settings in your Jenkins startup file which cause it to switch from using the default git command line implementation.

          Mark Waite added a comment - The default for git plugin 1.4.0 and git client 1.1.2 is to use the git command line implementation rather than using the jgit implementation (at least as far as I understand it). However, your stack trace shows jgit is being used rather than the git command line implementation. Your stack trace also shows the multiSCM plugin in the stack trace, while the original stack trace does not show that. You might try disabling or removing the MultiSCM plugin to see if that fixes the issue. You might also check that there are no settings in your Jenkins startup file which cause it to switch from using the default git command line implementation.

          Nikolas Falco added a comment -

          I had already try without multiSCM, it's not the problem.
          I have no settings (JVM -Dorg.jenkinsci.plugins.gitclient.Git.useJGit) on the startup file.

          Removing "JGit" installation from "Manage Jenkins">"Configure System">Git, now works.

          Nikolas Falco added a comment - I had already try without multiSCM, it's not the problem. I have no settings (JVM -Dorg.jenkinsci.plugins.gitclient.Git.useJGit) on the startup file. Removing "JGit" installation from "Manage Jenkins" >"Configure System" >Git, now works.

          Mark Waite added a comment -

          Thanks very much for the clarification. That made it so that I was able to duplicate the problem. If the git client 1.4.0 plugin has "JGit" added as an available git implementation (through "Manage Jenkins" and "Configure System"), and if a job is configured to use JGit instead of Git as its implementation, and if the job uses an ssh protocol Git URL, then I see the same stack trace you're describing.

          I think the problem you've discovered is independent of the Git plugin 2.0 beta that was described in this bug report, since the computer where I duplicated your stack trace has never installed the Git plugin 2.0 beta.

          Could you submit a separate bug report on the problem so that others won't have the confusion of thinking this Git plugin 1.4.0 problem is related to Git plugin 2.0 beta?

          Mark Waite added a comment - Thanks very much for the clarification. That made it so that I was able to duplicate the problem. If the git client 1.4.0 plugin has "JGit" added as an available git implementation (through "Manage Jenkins" and "Configure System"), and if a job is configured to use JGit instead of Git as its implementation, and if the job uses an ssh protocol Git URL, then I see the same stack trace you're describing. I think the problem you've discovered is independent of the Git plugin 2.0 beta that was described in this bug report, since the computer where I duplicated your stack trace has never installed the Git plugin 2.0 beta. Could you submit a separate bug report on the problem so that others won't have the confusion of thinking this Git plugin 1.4.0 problem is related to Git plugin 2.0 beta?

          ssh in git-client plugin is only supported when a credentialsProvide is set, and this option is only available in git plugin 2.0 as an extended option.
          Anyway, git-client plugin should avoid failing with a NPE

          Nicolas De Loof added a comment - ssh in git-client plugin is only supported when a credentialsProvide is set, and this option is only available in git plugin 2.0 as an extended option. Anyway, git-client plugin should avoid failing with a NPE

          Jesse Glick added a comment -

          I have not managed to reproduce this exception using the Git plugin as of the refactoring branch (Jenkins 1.480, Git Client 1.2.0). I just get

          Fetching changes from the remote Git repository
          FATAL: Cannot open session, connection is not authenticated.
          java.lang.IllegalStateException: Cannot open session, connection is not authenticated.
          	at com.trilead.ssh2.Connection.openSession(Connection.java:1102)
          	at org.jenkinsci.plugins.gitclient.trilead.TrileadSession.exec(TrileadSession.java:24)
          	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
          	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
          	at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
          	at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
          	at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1105)
          	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
          	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.fetch(JGitAPIImpl.java:323)
          	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:590)
          	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:815)
          	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:840)
          

          which is not the prettiest error but the cause is clear enough. Anyway it seems ndeloof already fixed this exception in the Git Client plugin in 006a0235fc6615ae0273b39e52b6dfdeb5025fd1 in 1.2.0; and sconnolly rewrote the code in question, also in 1.2.0. So I think this issue is obsolete.

          Jesse Glick added a comment - I have not managed to reproduce this exception using the Git plugin as of the refactoring branch (Jenkins 1.480, Git Client 1.2.0). I just get Fetching changes from the remote Git repository FATAL: Cannot open session, connection is not authenticated. java.lang.IllegalStateException: Cannot open session, connection is not authenticated. at com.trilead.ssh2.Connection.openSession(Connection.java:1102) at org.jenkinsci.plugins.gitclient.trilead.TrileadSession.exec(TrileadSession.java:24) at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248) at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147) at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1105) at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128) at org.jenkinsci.plugins.gitclient.JGitAPIImpl.fetch(JGitAPIImpl.java:323) at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:590) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:815) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:840) which is not the prettiest error but the cause is clear enough. Anyway it seems ndeloof already fixed this exception in the Git Client plugin in 006a0235fc6615ae0273b39e52b6dfdeb5025fd1 in 1.2.0; and sconnolly rewrote the code in question, also in 1.2.0. So I think this issue is obsolete.

          Mark Waite added a comment -

          Agreed that the issue is obsolete due to changes in earlier versions of git client plugin

          Mark Waite added a comment - Agreed that the issue is obsolete due to changes in earlier versions of git client plugin

            ndeloof Nicolas De Loof
            markewaite Mark Waite
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: