문제

I am writing a Spring application that uses LDAP. Here is my beans file.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

   <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
      <property name="url" value="xxxxx:xxx" />
      <property name="base" value="ou=xxxxx,dc=xxxxxxx,dc=xxxxxx" />
      <property name="userDn" value="uid=xxxxxxx" />
      <property name="password" value="xxxxxxxx" />
   </bean>

   <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
      <constructor-arg ref="contextSource" />
   </bean>

   <bean id="helloLdap" class="a.b.c.HelloLdap">
      <property name="ldapTemplate" ref="ldapTemplate" />
   </bean>

</beans>

Here is my beans creation code:

ApplicationContext fac = new ClassPathXmlApplicationContext(
                "a/b/c/ldap.xml");
HelloLdap hello = (HelloLdap) fac.getBean("helloLdap");

Here is my error message:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contextSource' defined in class path resource [xxxxxxxxxxxx]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'base' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils

So it says (most importantly)

"Property 'base' threw exception". 

I am wondering whether this is because the authentication requires StartTLS. I don't indicate StartTLS authentication anywhere in my beans file, so perhaps that is causing the error. Still, I would expect the authentication to happen after the beans are created, not during their creation.

Does anyone know if that is the cause (StartTLS authenticaton)? If not, any idea of what I am doing wrong in my XML?

Thanks, ktm

도움이 되었습니까?

해결책

The answer is in the error message:

java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils

Something in the application requires Apache Commons Lang. Download that, add it to your classpath.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top