Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring LDAP使用LdapContextSource为com.sun.jndi.LDAP.ctl.ResponseControlFactory提供NoClassDefFoundError_Java_Spring_Spring Mvc_Ldap_Spring Ldap - Fatal编程技术网

Java Spring LDAP使用LdapContextSource为com.sun.jndi.LDAP.ctl.ResponseControlFactory提供NoClassDefFoundError

Java Spring LDAP使用LdapContextSource为com.sun.jndi.LDAP.ctl.ResponseControlFactory提供NoClassDefFoundError,java,spring,spring-mvc,ldap,spring-ldap,Java,Spring,Spring Mvc,Ldap,Spring Ldap,我正在尝试使用SpringLDAP org.springframework.LDAP.support.LdapContextSource类访问LDAP 下面是我的代码 配置文件 <bean id="contextSource" class="org.springframework.ldap.support.LdapContextSource"> <property name="url" value=&q

我正在尝试使用SpringLDAP org.springframework.LDAP.support.LdapContextSource类访问LDAP

下面是我的代码

配置文件

<bean id="contextSource"
    class="org.springframework.ldap.support.LdapContextSource">
    <property name="url" value="ldap://url:11539" />
    <property name="base" value="o=ctc" />
    <property name="userName" value="cn=admin,ou=Users,ou=CFG,o=ctc" />
    <property name="password" value="password" />
</bean>


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

<bean id="mail_AdapterImpl"
    class="com.MAIL_AdapterImpl">
    <property name="ldapTemplate" ref="ldapTemplate" />
    <property name="mailAccount" ref="LdapDTO" />
</bean>
pom文件

我在pom文件中添加了以下依赖项

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-ldap</artifactId>
    <version>1.1.2</version>
</dependency>

org.springframework
SpringLDAP
1.1.2
但我有以下例外

Error Logs:
12:42:23,053 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-4) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contextSource' defined in ServletContext resource [/WEB-INF/app-beans.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com.sun.jndi.ldap.ctl.ResponseControlFactory from [Module "deployment.MAPP.war:main" from Service Module Loader]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.10.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_31]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_31]
Caused by: java.lang.NoClassDefFoundError: com.sun.jndi.ldap.ctl.ResponseControlFactory from [Module "deployment.ASSPP.war:main" from Service Module Loader]
    at org.springframework.ldap.support.LdapContextSource.class$(LdapContextSource.java:42) [spring-ldap-1.1.2.jar:1.1.2]
    at org.springframework.ldap.support.LdapContextSource.<clinit>(LdapContextSource.java:42) [spring-ldap-1.1.2.jar:1.1.2]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_31]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.6.0_31]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.6.0_31]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) [rt.jar:1.6.0_31]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    ... 21 more
错误日志:
12:42:23053错误[org.springframework.web.context.ContextLoader](MSC服务线程1-4)上下文初始化失败:org.springframework.beans.factory.BeanCreationException:创建名为“contextSource”的bean时出错,该bean在ServletContext资源[/web-INF/app beans.xml]中定义:实例化失败;嵌套异常是服务模块加载器中的[Module“deployment.MAPP.war:main]中的java.lang.NoClassDefFoundError:com.sun.jndi.ldap.ctl.ResponseControlFactory
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.InstanceBean(AbstractAutowireCapableBeanFactory.java:965)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.DefaultListableBeanFactory.PreInstanceSingleton(DefaultListableBeanFactory.java:585)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)[spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)[spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
在org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392)[jbossweb-7.0.10.Final.jar:]
在org.apache.catalina.core.StandardContext.start(StandardContext.java:3850)[jbossweb-7.0.10.Final.jar:]
在org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)[jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
位于org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
位于org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
位于java.util.concurrent.ThreadPoolExecutor$Worker.runTask(未知源)[rt.jar:1.6.031]
位于java.util.concurrent.ThreadPoolExecutor$Worker.run(未知源)[rt.jar:1.6.031]
运行(未知源)[rt.jar:1.6.0_31]
原因:java.lang.NoClassDefFoundError:com.sun.jndi.ldap.ctl.ResponseControlFactory来自服务模块加载器的[Module”deployment.ASSPP.war:main]
位于org.springframework.ldap.support.LdapContextSource.class$(LdapContextSource.java:42)[spring-ldap-1.1.2.jar:1.1.2]
位于org.springframework.ldap.support.LdapContextSource.(LdapContextSource.java:42)[spring-ldap-1.1.2.jar:1.1.2]
在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)[rt.jar:1.6.0\u 31]
在sun.reflect.NativeConstructorAccessorImpl.newInstance(未知源)[rt.jar:1.6.0\u 31]
在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知源)[rt.jar:1.6.031]
位于java.lang.reflect.Constructor.newInstance(未知源)[rt.jar:1.6.031]
在org.springframework.beans.BeanUtils.instanceClass(BeanUtils.java:126)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.simpleinstationstrategy.instantiate(simpleinstationstrategy.java:74)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.InstanceBean(AbstractAutowireCapableBeanFactory.java:958)[spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
... 还有21个

我尝试添加sun-jndi-ldapbp.jar,但没有任何帮助。我也可以在我的类路径中看到SpringLDAP 1.1.2JAR。不知道这是为什么导致这个问题。
Error Logs:
12:42:23,053 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-4) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contextSource' defined in ServletContext resource [/WEB-INF/app-beans.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com.sun.jndi.ldap.ctl.ResponseControlFactory from [Module "deployment.MAPP.war:main" from Service Module Loader]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) [spring-context-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.10.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_31]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_31]
Caused by: java.lang.NoClassDefFoundError: com.sun.jndi.ldap.ctl.ResponseControlFactory from [Module "deployment.ASSPP.war:main" from Service Module Loader]
    at org.springframework.ldap.support.LdapContextSource.class$(LdapContextSource.java:42) [spring-ldap-1.1.2.jar:1.1.2]
    at org.springframework.ldap.support.LdapContextSource.<clinit>(LdapContextSource.java:42) [spring-ldap-1.1.2.jar:1.1.2]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_31]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.6.0_31]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.6.0_31]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) [rt.jar:1.6.0_31]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) [spring-beans-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    ... 21 more