PDA

View Full Version : BeanCreationException



tylerperkins
Dec 19th, 2006, 10:35 AM
I am following the reference guide by Arthursson and Sandberg that comes with Spring-Ldap 1.1.2, but have had no luck getting it to work. I think I might be missing some knowledge that is assumed by the document. Here is my app. context.


<!-- LDAP Settings-->
<bean id="contextSource"
class="org.springframework.ldap.support.LdapContextSource">
<property name="url" value="ldap://persona.tu.ir:389"/>
<property name="base" value="dc=tu,dc=ir"/>
<property name="userName" value="cn=something"/>
<property name="password" value="secret"/>
<property name="dirObjectFactory" value="org.springframework.ldap.support.DefaultDirObjectF actory" />
</bean>
<bean id="ldapOperations" class="org.springframework.ldap.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
<bean id="LdapUserDao" class="taxonomy.dao.spring.SpringLdapUserDao">
<property name="ldapOperations" ref="ldapOperations"/>
</bean>


I think I may be having a library issue, but not sure, these are the libraries that I am using right now for spring.

spring.jar (v2.0)
spring-ldap-1.1.2.jar
commons-collections.jar
commons-lang.jar
commons-logging.jar
ldapbp.jar
spring-orm.jar


Finally this is the error that I am getting.


2006-12-19 09:02:55 StandardContext[/taxonomy]Loading Spring root WebApplicationContext
2006-12-19 09:02:56 StandardContext[/taxonomy]Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'contextSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.lang.ArrayUtils.isEmpty([Ljava/lang/Object;)Z
Caused by: java.lang.NoSuchMethodError: org.apache.commons.lang.ArrayUtils.isEmpty([Ljava/lang/Object;)Z
at org.springframework.ldap.support.AbstractContextSo urce.afterPropertiesSet(AbstractContextSource.java :240)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1057)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1024)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:421)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:140)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:273)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:346)
at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:156)
at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4343)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
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:324)
at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:425)

Do I need to have a class to initialize the contextSource (like a LdapServerManager) or is that something that spring takes care of? In the sample program that comes with spring-ldap they have something like this:


<bean name="ldapServerManager" class="org.springframework.ldap.LdapServerManager">
<property name="contextSource" ref="contextSource" />
<property name="ldifFile" value="setup_data.ldif" />
</bean>
which I assume is what I'm missing.

any help would be appreciated.

Thanks,

Tyler Perkins

ulsa
Dec 19th, 2006, 12:17 PM
I would say you have the wrong version of commons-lang. Make sure you use commons-lang 2.1.

With regards to the usage of LdapServerManager, that's just an internal helper class that we used to simplify the bootstrapping of an in-memory ApacheDS LDAP-server for our integration tests and our sample application.

Chris Lee
Dec 19th, 2006, 12:17 PM
It is likely that a newer version of commons-lang is required; your present version doesn't appear to have a required method.

tylerperkins
Dec 19th, 2006, 12:24 PM
Hey thanks guys, that did the job. Ive been updating libraries and have found that it is not a very fun job. I've successfully upgraded from struts 1.1 to struts 2.0 and spring 1.1 to spring 2.0. Now I will attempt to update Hibernate.

Thanks again,
Tyler Perkins

piloud
Mar 13th, 2008, 05:17 PM
Hello, there,

I got the same error, I upgraded the commons-lang to commons-lang-2.3jar and still got the same error. Do I have to upgrade anything else to get it work? How do you find out the spring version?

Thanks!

ulsa
Mar 14th, 2008, 02:01 AM
You will find the version of all Spring jars in the META-INF/MANIFEST.MF file.

ulsa
Mar 16th, 2008, 05:12 AM
I just verified that the integration tests and the person sample works fine with commons-lang 2.3.