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

Hudson fails when restarted with Active Directory enabled.

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Platform: All, OS: All

      Hudson = 1.262
      Access Control = Active Directory
      Authorization = Matrix based Security

      I restart Hudson by doing the following:
      net stop "Apache Tomcat"
      net start "Apache Tomcat"

      After a restart, any attempt to access Hudson produces the following error:

      org.springframework.beans.factory.BeanCreationException: Error creating bean
      with name 'activeDirectory': Instantiation of bean failed; nested exception is
      org.springframework.beans.BeanInstantiationException: Could not instantiate bean
      class [hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider]:
      Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError:
      Native Library D:\HudsonData\plugins\active-directory\WEB-INF\lib\com4j.dll
      already loaded in another classloader
      at
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:917)
      at
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:873)
      at
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:514)
      at
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
      at java.security.AccessController.doPrivileged(Native Method)
      at
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
      at
      org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
      at
      org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
      at
      org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
      at
      org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
      at
      org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:413)
      at
      org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
      at
      org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
      at
      hudson.util.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:94)
      at hudson.util.spring.BeanBuilder.createApplicationContext(BeanBuilder.java:387)
      at
      hudson.plugins.active_directory.ActiveDirectorySecurityRealm.createSecurityComponents(ActiveDirectorySecurityRealm.java:57)
      at hudson.model.Hudson.setSecurityRealm(Hudson.java:1135)
      at hudson.model.Hudson.load(Hudson.java:1483)
      at hudson.model.Hudson.(Hudson.java:378)
      at hudson.WebAppMain$2.run(WebAppMain.java:156)
      Caused by: org.springframework.beans.BeanInstantiationException: Could not
      instantiate bean class
      [hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider]:
      Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError:
      Native Library D:\HudsonData\plugins\active-directory\WEB-INF\lib\com4j.dll
      already loaded in another classloader
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:98)
      at
      org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
      at
      org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:911)
      ... 19 more
      Caused by: java.lang.UnsatisfiedLinkError: Native Library
      D:\HudsonData\plugins\active-directory\WEB-INF\lib\com4j.dll already loaded in
      another classloader
      at java.lang.ClassLoader.loadLibrary0(Unknown Source)
      at java.lang.ClassLoader.loadLibrary(Unknown Source)
      at java.lang.Runtime.load0(Unknown Source)
      at java.lang.System.load(Unknown Source)
      at com4j.COM4J.loadNativeLibrary(COM4J.java:430)
      at com4j.COM4J.(COM4J.java:386)
      at
      hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider.(ActiveDirectoryAuthenticationProvider.java:45)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:83)
      ... 21 more

      The only workaround I've found is to:

      1. edit config.xml and either set "<useSecurity>false</useSecurity>" or remove
      the following element:

      <securityRealm
      class="hudson.plugins.active_directory.ActiveDirectorySecurityRealm">
      <domain></domain>
      </securityRealm>

      2. Restart Hudson again. It works now, but naturally the security system is
      missing.

      3. Restore the original config.xml.

      4. Restart Hudson a second time. Hudson now works correctly, until the next
      restart.

          [JENKINS-2708] Hudson fails when restarted with Active Directory enabled.

          djcarr added a comment -

          wrong subcategory

          djcarr added a comment - wrong subcategory

          djcarr added a comment -

          wrong owner

          djcarr added a comment - wrong owner

          This doesn't make sense. When you stop Tomcat, its JVM exits. So there's nothing
          that "remembers" what the previous execution about.

          Whereas you report that the behavior differs with the same config.xml, depending
          on what its previous execution was like.

          Do you have other plugins installed? Perhaps there's some interference along
          that line?

          Kohsuke Kawaguchi added a comment - This doesn't make sense. When you stop Tomcat, its JVM exits. So there's nothing that "remembers" what the previous execution about. Whereas you report that the behavior differs with the same config.xml, depending on what its previous execution was like. Do you have other plugins installed? Perhaps there's some interference along that line?

          Marked as closed because there's no further input from the reporter.

          If someone else sees a similar problem, please feel free to reopen.

          Kohsuke Kawaguchi added a comment - Marked as closed because there's no further input from the reporter. If someone else sees a similar problem, please feel free to reopen.

          didi316 added a comment -

          This exception happens for me too now.
          I am running hudson on a tomcat 6 server and I restarted Hudson and the
          exception occurred. I furhter tried to restart tomcat but that didn't change
          anything too.

          A thing that I did (tried to remove the changes again but the exception still
          occurs) is that I changed the server.xml from tomcat by adding UTF8 stuff:

          from:
          <Connector port="8080" protocol="HTTP/1.1"
          connectionTimeout="20000"
          redirectPort="8443"/>
          to
          <Connector port="8080" protocol="HTTP/1.1"
          connectionTimeout="20000"
          redirectPort="8443"
          URIEncoding="UTF-8" />

          but I don't think that this had any influence...

          I have several other Plugins installed on my system (Perforce, Nant, MSBuild,
          Nunit, Disk Space, Additional Sidebar, Active Directory,...)

          didi316 added a comment - This exception happens for me too now. I am running hudson on a tomcat 6 server and I restarted Hudson and the exception occurred. I furhter tried to restart tomcat but that didn't change anything too. A thing that I did (tried to remove the changes again but the exception still occurs) is that I changed the server.xml from tomcat by adding UTF8 stuff: from: <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/> to <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> but I don't think that this had any influence... I have several other Plugins installed on my system (Perforce, Nant, MSBuild, Nunit, Disk Space, Additional Sidebar, Active Directory,...)

          didi316 added a comment -

          I commented the following info in the config.xml and hudson starts up correctly
          again:
          <authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
          <securityRealm
          class="hudson.plugins.active_directory.ActiveDirectorySecurityRealm"/>

          but when trying to enable active directory again I get a 500 error in the UI

          javax.servlet.ServletException:
          org.springframework.beans.factory.BeanCreationException: Error creating bean
          with name 'activeDirectory': Instantiation of bean failed; nested exception is
          org.springframework.beans.BeanInstantiationException: Could not instantiate bean
          class [hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider]:
          Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError:
          Native Library C:\Dokumente und Einstellungen\Default
          User\.hudson\plugins\active-directory\WEB-INF\lib\com4j.dll already loaded in
          another classloader

          and further on - as it is already posted in this defect

          I'm using 1.309

          didi316 added a comment - I commented the following info in the config.xml and hudson starts up correctly again: <authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/> <securityRealm class="hudson.plugins.active_directory.ActiveDirectorySecurityRealm"/> but when trying to enable active directory again I get a 500 error in the UI javax.servlet.ServletException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activeDirectory': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider] : Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError: Native Library C:\Dokumente und Einstellungen\Default User\.hudson\plugins\active-directory\WEB-INF\lib\com4j.dll already loaded in another classloader and further on - as it is already posted in this defect I'm using 1.309

          didi316 added a comment -

          I enabled the UTF8 thing for tomcat and as expected it didn't have any negative
          influence - so, currently I'm running hudson without Active Directory and it
          works fine.

          List of installed Plugins:

          didi316 added a comment - I enabled the UTF8 thing for tomcat and as expected it didn't have any negative influence - so, currently I'm running hudson without Active Directory and it works fine. List of installed Plugins: Hudson Active Directory plugin http://wiki.jenkins-ci.org/display/JENKINS/Active+Directory+Plugin Audit Trail http://hudson.gotdns.com/wiki/display/JENKINS/Audit+Trail+Plugin Hudson Backup plugin http://wiki.jenkins-ci.org/display/JENKINS/Backup+Plugin Hudson disk-usage plugin http://wiki.jenkins-ci.org/display/JENKINS/Disk+Usage+Plugin Hudson Mantis plugin http://wiki.jenkins-ci.org/display/JENKINS/Mantis+Plugin Hudson MSBuild Plugin http://hudson.gotdns.com/wiki/display/JENKINS/MSBuild+Plugin Hudson NAnt Plugin http://wiki.jenkins-ci.org//display/JENKINS/NAnt+Plugin Hudson NUnit plugin http://hudson.gotdns.com/wiki/display/JENKINS/NUnit+Plugin Hudson Perforce Plugin http://hudson.gotdns.com/wiki/display/JENKINS/Perforce+Plugin Sidebar Link http://wiki.jenkins-ci.org/display/JENKINS/Sidebar-Link+Plugin Hudson Edgewall Trac plugin http://hudson.gotdns.com/wiki/display/JENKINS/Trac+Plugin

          heavydawson added a comment -

          Also seeing this for a while while evaluating Hudson. It appeared today after I
          upgraded from 1.326 to 1.328:
          =========================================================================
          org.springframework.beans.factory.BeanCreationException: Error creating bean
          with name 'activeDirectory': Instantiation of bean failed; nested exception is
          org.springframework.beans.BeanInstantiationException: Could not instantiate bean
          class [hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider]:
          Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError:
          Native Library C:\Documents and Settings\Default User\.hudson\plugins\active-
          directory\WEB-INF\lib\com4j.dll already loaded in another classloader
          at
          org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.ins
          tantiateBean(AbstractAutowireCapableBeanFactory.java:917)
          at
          org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre
          ateBeanInstance(AbstractAutowireCapableBeanFactory.java:873)
          at
          org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC
          reateBean(AbstractAutowireCapableBeanFactory.java:514)
          at
          org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.r
          un(AbstractAutowireCapableBeanFactory.java:485)
          at java.security.AccessController.doPrivileged(Native Method)
          at
          org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre
          ateBean(AbstractAutowireCapableBeanFactory.java:455)
          at
          org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Abstra
          ctBeanFactory.java:251)
          at
          org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingle
          ton(DefaultSingletonBeanRegistry.java:169)
          at
          org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
          anFactory.java:248)
          at
          org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
          anFactory.java:170)
          at
          org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstanti
          ateSingletons(DefaultListableBeanFactory.java:413)
          at
          org.springframework.context.support.AbstractApplicationContext.finishBeanFactory
          Initialization(AbstractApplicationContext.java:735)
          at
          org.springframework.context.support.AbstractApplicationContext.refresh(AbstractA
          pplicationContext.java:369)
          at
          hudson.util.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(Defau
          ltRuntimeSpringConfiguration.java:94)
          at
          hudson.util.spring.BeanBuilder.createApplicationContext(BeanBuilder.java:388)
          at
          hudson.plugins.active_directory.ActiveDirectorySecurityRealm.createSecurityCompo
          nents(ActiveDirectorySecurityRealm.java:61)
          at
          hudson.security.SecurityRealm.getSecurityComponents(SecurityRealm.java:340)
          at hudson.security.HudsonFilter.reset(HudsonFilter.java:134)
          at hudson.model.Hudson.setSecurityRealm(Hudson.java:1692)
          at hudson.model.Hudson.load(Hudson.java:2079)
          at hudson.model.Hudson.(Hudson.java:560)
          at hudson.WebAppMain$2.run(WebAppMain.java:191)
          Caused by: org.springframework.beans.BeanInstantiationException: Could not
          instantiate bean class
          [hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider]:
          Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError:
          Native Library C:\Documents and Settings\Default User\.hudson\plugins\active-
          directory\WEB-INF\lib\com4j.dll already loaded in another classloader
          at
          org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:98)
          at
          org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiat
          e(SimpleInstantiationStrategy.java:61)
          at
          org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.ins
          tantiateBean(AbstractAutowireCapableBeanFactory.java:911)
          ... 21 more
          Caused by: java.lang.UnsatisfiedLinkError: Native Library C:\Documents and
          Settings\Default User\.hudson\plugins\active-directory\WEB-INF\lib\com4j.dll
          already loaded in another classloader
          at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1743)
          at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1674)
          at java.lang.Runtime.load0(Runtime.java:770)
          at java.lang.System.load(System.java:1003)
          at com4j.COM4J.loadNativeLibrary(COM4J.java:430)
          at com4j.COM4J.(COM4J.java:386)
          at
          hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider.(ActiveDir
          ectoryAuthenticationProvider.java:48)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at
          sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI
          mpl.java:39)
          at
          sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA
          ccessorImpl.java:27)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
          at
          org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:83)
          ... 23 more
          ==============================================

          heavydawson added a comment - Also seeing this for a while while evaluating Hudson. It appeared today after I upgraded from 1.326 to 1.328: ========================================================================= org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activeDirectory': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider] : Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError: Native Library C:\Documents and Settings\Default User\.hudson\plugins\active- directory\WEB-INF\lib\com4j.dll already loaded in another classloader at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.ins tantiateBean(AbstractAutowireCapableBeanFactory.java:917) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre ateBeanInstance(AbstractAutowireCapableBeanFactory.java:873) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC reateBean(AbstractAutowireCapableBeanFactory.java:514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.r un(AbstractAutowireCapableBeanFactory.java:485) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre ateBean(AbstractAutowireCapableBeanFactory.java:455) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Abstra ctBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingle ton(DefaultSingletonBeanRegistry.java:169) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe anFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe anFactory.java:170) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstanti ateSingletons(DefaultListableBeanFactory.java:413) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactory Initialization(AbstractApplicationContext.java:735) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractA pplicationContext.java:369) at hudson.util.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(Defau ltRuntimeSpringConfiguration.java:94) at hudson.util.spring.BeanBuilder.createApplicationContext(BeanBuilder.java:388) at hudson.plugins.active_directory.ActiveDirectorySecurityRealm.createSecurityCompo nents(ActiveDirectorySecurityRealm.java:61) at hudson.security.SecurityRealm.getSecurityComponents(SecurityRealm.java:340) at hudson.security.HudsonFilter.reset(HudsonFilter.java:134) at hudson.model.Hudson.setSecurityRealm(Hudson.java:1692) at hudson.model.Hudson.load(Hudson.java:2079) at hudson.model.Hudson.(Hudson.java:560) at hudson.WebAppMain$2.run(WebAppMain.java:191) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider] : Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError: Native Library C:\Documents and Settings\Default User\.hudson\plugins\active- directory\WEB-INF\lib\com4j.dll already loaded in another classloader at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:98) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiat e(SimpleInstantiationStrategy.java:61) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.ins tantiateBean(AbstractAutowireCapableBeanFactory.java:911) ... 21 more Caused by: java.lang.UnsatisfiedLinkError: Native Library C:\Documents and Settings\Default User\.hudson\plugins\active-directory\WEB-INF\lib\com4j.dll already loaded in another classloader at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1743) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1674) at java.lang.Runtime.load0(Runtime.java:770) at java.lang.System.load(System.java:1003) at com4j.COM4J.loadNativeLibrary(COM4J.java:430) at com4j.COM4J.(COM4J.java:386) at hudson.plugins.active_directory.ActiveDirectoryAuthenticationProvider.(ActiveDir ectoryAuthenticationProvider.java:48) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI mpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA ccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:83) ... 23 more ==============================================

          The LinkageError happens when you redeploy Hudson on a running JVM. The act of doing so creates a new classloader, and they'll try to load the same native library, which fails because it's already loaded in another classloader, as the error message says.

          This is a restriction in JNI, and I think the only thing we can do is to probably report this error a bit more gracefully.

          To resolve the problem, restart the entire JVM, which is what Hudson does when you tell him to restart on its own.

          Kohsuke Kawaguchi added a comment - The LinkageError happens when you redeploy Hudson on a running JVM. The act of doing so creates a new classloader, and they'll try to load the same native library, which fails because it's already loaded in another classloader, as the error message says. This is a restriction in JNI, and I think the only thing we can do is to probably report this error a bit more gracefully. To resolve the problem, restart the entire JVM, which is what Hudson does when you tell him to restart on its own.

          Sorin Sbarnea added a comment -

          I think I had the same issue, after installing Active Directory plugin, hudson does not restart anymore. It is stuck at starting phase.

          Sorin Sbarnea added a comment - I think I had the same issue, after installing Active Directory plugin, hudson does not restart anymore. It is stuck at starting phase.

            Unassigned Unassigned
            djcarr djcarr
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: