LDAP を使用する Spring アプリケーションを作成しています。これが私のBeanファイルです。
<?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>
これが私のBean作成コードです:
ApplicationContext fac = new ClassPathXmlApplicationContext(
"a/b/c/ldap.xml");
HelloLdap hello = (HelloLdap) fac.getBean("helloLdap");
これが私のエラーメッセージです:
スレッド「メイン」での例外 org.springframework.beans.factory.BeanCreationException: クラスパス リソース [xxxxxxxxxxxx] で定義された名前 'contextSource' を持つ Bean の作成中にエラーが発生しました: プロパティ値の設定中にエラーが発生しました。ネストされた例外は org.springframework.beans.PropertyBatchUpdateException; です。ネストされた PropertyAccessExceptions (1) は次のとおりです。 PropertyAccessException 1: org.springframework.beans.MethodInvocationException: プロパティ 'base' が例外をスローしました。ネストされた例外は java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils です
だからそれは言う(最も重要なこと):
"Property 'base' threw exception"
これは、認証に StartTLS が必要なためではないかと考えています。私のbeansファイルのどこにもStartTLS認証を示していないので、おそらくそれがエラーの原因です。それでも、 Bean の作成時ではなく、Bean の作成後に認証が行われることを期待しています。
それが原因(StartTLS認証)かどうかは誰にもわかりませんか? そうでない場合、XMLで何が間違っているのか考えていますか?