jenkinsci / jenkinsci/active-directory-plugin
[JENKINS-2708] Hudson fails when restarted with Active Directory enabled.
- Dominant language
- Java
- Stars
- 53
- Forks
- 115
- PR merge metrics
- No merged PRs in 30d
Description
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 "false" or remove
the following element:
class="hudson.plugins.active_directory.ActiveDirectorySecurityRealm">
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.
---
Originally reported by djcarr, imported from: Hudson fails when restarted with Active Directory enabled.
Raw content of original issue
Hudson = 1.262
Access Control = Active Directory
Authorization = Matrix based SecurityI 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 moreThe 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.
- environment:
Platform: All, OS: All
Contributor guide
Research direction
Start at ActiveDirectoryAuthenticationProvider.java:45 and ActiveDirectorySecurityRealm.java:57, then trace the Hudson.load restart path shown in the stack trace. Reproduce the restart with Active Directory enabled and verify that Hudson starts successfully without the com4j.dll UnsatisfiedLinkError while security remains enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100