Failed to initialize interceptor chain,Spring-LDAP送给我的第一个异常

Failed to initialize interceptor chain,Spring-LDAP送给我的第一个异常

这几天在研究Spring-LDAP,准备应用在项目中。试着调试官网上的一个例子:spring-ldap-person,结果总是在启动服务器时报错。

PS:官方的例子我是通过Subversion得到了,地址是https://svn.sourceforge.net/svnroot/springframework/spring-ldap/trunk/spring-ldap-person/

开发环境:Window XP + eclipse3.2 + tomcat 5.0.30 + ApacheDS 1.0.0
系统架构:Spring + Spring Webflow + Spring-LDAP
错误跟踪:
2007-06-21 10:10:47,218 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'serverContext' defined in ServletContext resource [/WEB-INF/apacheDsContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [javax.naming.InitialContext]: Constructor threw exception; nested exception is org.apache.directory.server.core.interceptor.Inter ceptorException: Failed to initialize interceptor chain. [Root exception is java.lang.NullPointerException]
Caused by:
org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [javax.naming.InitialContext]: Constructor threw exception; nested exception is org.apache.directory.server.core.interceptor.Inter ceptorException: Failed to initialize interceptor chain. [Root exception is java.lang.NullPointerException]
Caused by:
org.apache.directory.server.core.interceptor.Inter ceptorException: Failed to initialize interceptor chain. [Root exception is java.lang.NullPointerException]
at org.apache.directory.server.core.interceptor.Inter ceptorChain.init(InterceptorChain.java:274)
at org.apache.directory.server.core.DefaultDirectoryS ervice.initialize(DefaultDirectoryService.java:822 )
at org.apache.directory.server.core.DefaultDirectoryS ervice.startup(DefaultDirectoryService.java:229)
at org.apache.directory.server.core.jndi.AbstractCont extFactory.getInitialContext(AbstractContextFactor y.java:117)
at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:247)
at javax.naming.InitialContext.init(InitialContext.ja va:223)
at javax.naming.InitialContext.<init>(InitialContext. java:197)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:494)
at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:85)
at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:87)
at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:186)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireConstructor(Abs tractAutowireCapableBeanFactory.java:799)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:717)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:384)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:156)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:287)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:352)
at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:244)
at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:187)
at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3831)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4323)
at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.inst all(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(Stan dardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.java:701)
at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:432)
at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:983)
at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:789)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:478)
at org.apache.catalina.core.StandardService.start(Sta ndardService.java:480)
at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalin a.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:425)
Caused by: java.lang.NullPointerException
at org.apache.directory.server.core.ServerUtils.getAt tribute(ServerUtils.java:54)
at org.apache.directory.server.core.partition.impl.bt ree.LeafEvaluator.evalEquality(LeafEvaluator.java: 301)
at org.apache.directory.server.core.partition.impl.bt ree.LeafEvaluator.evaluate(LeafEvaluator.java:121)
at org.apache.directory.server.core.partition.impl.bt ree.ExpressionEvaluator.evaluate(ExpressionEvaluat or.java:103)
at org.apache.directory.server.core.partition.impl.bt ree.ExpressionEnumerator$2.assertCandidate(Express ionEnumerator.java:257)
at org.apache.directory.server.core.partition.impl.bt ree.IndexAssertionEnumeration.prefetch(IndexAssert ionEnumeration.java:161)
at org.apache.directory.server.core.partition.impl.bt ree.IndexAssertionEnumeration.<init>(IndexAssertio nEnumeration.java:66)
at org.apache.directory.server.core.partition.impl.bt ree.ExpressionEnumerator.enumConj(ExpressionEnumer ator.java:270)
at org.apache.directory.server.core.partition.impl.bt ree.ExpressionEnumerator.enumerate(ExpressionEnume rator.java:134)
at org.apache.directory.server.core.partition.impl.bt ree.DefaultSearchEngine.search(DefaultSearchEngine .java:136)
at org.apache.directory.server.core.partition.impl.bt ree.BTreePartition.search(BTreePartition.java:404)
at org.apache.directory.server.core.partition.Default PartitionNexus.search(DefaultPartitionNexus.java:8 63)
at org.apache.directory.server.core.referral.Referral Service.init(ReferralService.java:175)
at org.apache.directory.server.core.interceptor.Inter ceptorChain.register0(InterceptorChain.java:436)
at org.apache.directory.server.core.interceptor.Inter ceptorChain.register(InterceptorChain.java:395)
at org.apache.directory.server.core.interceptor.Inter ceptorChain.init(InterceptorChain.java:260)
... 51 more

解决方法:
        我求助于Spring官网的论坛,得到了解决的方法。

This is probably caused by the temporary apacheDS data file being corrupt. Try removing the directory Documents and settings\[user]\Local Settings\Temp\ldaptemplate_apacheds

You could also try deleting the ldaptemplate_apacheds directory in Tomcat's temp dir, as well as the ldap-person in Tomcat's work/Catalina/localhost directory.


这个错误很可能是由于ApacheDS的临时数据文件遭到了破坏造成的,试着删除Documents and settings\[user]\Local Settings\Temp\下的ldaptemplate_apacheds文件夹,还有Tomcat的Temp文件夹下的ldaptemplate_apacheds文件和Tomcat的work/Catalina/localhost下的应用文件夹。这样再启动tomcat后,ldaptemplate_apacheds文件就会重新生成,问题就解决了。


下面贴出了原稿:http://forum.springframework.org/showthread.php?p=127663&posted=1#post127663

Yesterday, 10:57 AM
allen-zhe
Junior Member
 
Join Date: Jun 2007
Location: Beijing, China
Posts: 3
Failed to initialize interceptor chain
i got this trouble when i run the spring-ldap-person sample.
mine env is window+tomcat.
here is the stack:

2007-06-21 10:10:47,218 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'serverContext' defined in ServletContext resource [/WEB-INF/apacheDsContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [javax.naming.InitialContext]: Constructor threw exception; nested exception is org.apache.directory.server.core.interceptor.Inter ceptorException: Failed to initialize interceptor chain. [Root exception is java.lang.NullPointerException]
Caused by:
org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [javax.naming.InitialContext]: Constructor threw exception; nested exception is org.apache.directory.server.core.interceptor.Inter ceptorException: Failed to initialize interceptor chain. [Root exception is java.lang.NullPointerException]
Caused by:
org.apache.directory.server.core.interceptor.Inter ceptorException: Failed to initialize interceptor chain. [Root exception is java.lang.NullPointerException]
at org.apache.directory.server.core.interceptor.Inter ceptorChain.init(InterceptorChain.java:274)
at org.apache.directory.server.core.DefaultDirectoryS ervice.initialize(DefaultDirectoryService.java:822 )
at org.apache.directory.server.core.DefaultDirectoryS ervice.startup(DefaultDirectoryService.java:229)
at org.apache.directory.server.core.jndi.AbstractCont extFactory.getInitialContext(AbstractContextFactor y.java:117)
at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:247)
at javax.naming.InitialContext.init(InitialContext.ja va:223)
at javax.naming.InitialContext.<init>(InitialContext. java:197)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:494)
at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:85)
at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:87)
at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:186)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireConstructor(Abs tractAutowireCapableBeanFactory.java:799)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:717)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:384)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:156)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:287)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:352)
at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:244)
at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:187)
at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3831)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4323)
at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.inst all(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(Stan dardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.java:701)
at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:432)
at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:983)
at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:789)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:478)
at org.apache.catalina.core.StandardService.start(Sta ndardService.java:480)
at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalin a.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:425)
Caused by: java.lang.NullPointerException
at org.apache.directory.server.core.ServerUtils.getAt tribute(ServerUtils.java:54)
at org.apache.directory.server.core.partition.impl.bt ree.LeafEvaluator.evalEquality(LeafEvaluator.java: 301)
at org.apache.directory.server.core.partition.impl.bt ree.LeafEvaluator.evaluate(LeafEvaluator.java:121)
at org.apache.directory.server.core.partition.impl.bt ree.ExpressionEvaluator.evaluate(ExpressionEvaluat or.java:103)
at org.apache.directory.server.core.partition.impl.bt ree.ExpressionEnumerator$2.assertCandidate(Express ionEnumerator.java:257)
at org.apache.directory.server.core.partition.impl.bt ree.IndexAssertionEnumeration.prefetch(IndexAssert ionEnumeration.java:161)
at org.apache.directory.server.core.partition.impl.bt ree.IndexAssertionEnumeration.<init>(IndexAssertio nEnumeration.java:66)
at org.apache.directory.server.core.partition.impl.bt ree.ExpressionEnumerator.enumConj(ExpressionEnumer ator.java:270)
at org.apache.directory.server.core.partition.impl.bt ree.ExpressionEnumerator.enumerate(ExpressionEnume rator.java:134)
at org.apache.directory.server.core.partition.impl.bt ree.DefaultSearchEngine.search(DefaultSearchEngine .java:136)
at org.apache.directory.server.core.partition.impl.bt ree.BTreePartition.search(BTreePartition.java:404)
at org.apache.directory.server.core.partition.Default PartitionNexus.search(DefaultPartitionNexus.java:8 63)
at org.apache.directory.server.core.referral.Referral Service.init(ReferralService.java:175)
at org.apache.directory.server.core.interceptor.Inter ceptorChain.register0(InterceptorChain.java:436)
at org.apache.directory.server.core.interceptor.Inter ceptorChain.register(InterceptorChain.java:395)
at org.apache.directory.server.core.interceptor.Inter ceptorChain.init(InterceptorChain.java:260)
... 51 more

i need some help! thanks in adv.


  # 2    
Yesterday, 04:25 PM
rasky
Senior Member
 
Join Date: Mar 2005
Location: Landskrona, Sweden
Posts: 200
This is probably caused by the temporary apacheDS data file being corrupt. Try removing the directory Documents and settings\[user]\Local Settings\Temp\ldaptemplate_apacheds
__________________
Mattias Arthursson
Jayway AB ( www.jayway.se)
Spring-LDAP project member

  # 3    
Yesterday, 05:49 PM
allen-zhe
Junior Member
 
Join Date: Jun 2007
Location: Beijing, China
Posts: 3
thanks for ur advice, Mr. Arthursson. i tryed ur method, but it didn't work!
i cleaned my temp files, and restored my ApahceDS, still got this error!
got any other advice, Mr. Arthursson?

by the way, mine ApacheDS's version is 1.0.0.

ulsa
Senior Member
 
Join Date: Jul 2005
Location: Helsingborg, Sweden
Posts: 102
You could also try deleting the ldaptemplate_apacheds directory in Tomcat's temp dir, as well as the ldap-person in Tomcat's work/Catalina/localhost directory.
__________________
Ulrik Sandberg
Jayway AB ( www.jayway.se)
Spring-LDAP project member

Today, 09:37 AM
allen-zhe
Junior Member
 
Join Date: Jun 2007
Location: Beijing, China
Posts: 3
thanks a lot, ulsa! it works now!

你可能感兴趣的:(Failed to initialize interceptor chain,Spring-LDAP送给我的第一个异常)