Announcement Announcement Module
Collapse
No announcement yet.
using ldap : exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • using ldap : exception

    good evening ,

    I'm tring to use ldap for authentication but I have this problem always :

    Code:
    [ERROR,ContextLoader] Context initialization failed
    java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:264)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    29 sept. 2010 17:58:25 org.apache.catalina.core.StandardContext listenerStart
    GRAVE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
    java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:264)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    My security context is
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    			 xmlns:beans="http://www.springframework.org/schema/beans"
    			 xmlns:security="http://www.springframework.org/schema/security"
    			 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
    									   http://www.springframework.org/schema/security
    									   http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">
    									   		   						 
    									   
    	<security:http auto-config='true'>
    	    <security:intercept-url pattern="/index.htm*" filters="none"/>
    	    <security:intercept-url pattern="/logo*" filters="none"/>  
    		<security:intercept-url pattern="/vermeg.css" filters="none"/> 
    		<security:intercept-url pattern="/login.jsp*" filters="none"/>
    		<security:intercept-url pattern="/Managing.html" access="ROLE_ADMIN" />
    		<security:intercept-url pattern="/Application.html" access="ROLE_USER" />
    		<security:intercept-url pattern="/**" access="ROLE_USER" />
    		<security:form-login login-page='/login.jsp' authentication-failure-url="/login.jsp?login_error=1" />
    		<security:logout logout-success-url="/index.htm" />	
    	</security:http>	
    	
    	 <!--  Simple namespace-based configuration  --> 
    	 <security:ldap-server ldif="classpath:users.ldif" port="10389" />
    	 
    	 <security:authentication-manager>
      		<security:ldap-authentication-provider group-search-filter="member={0}" group-search-base="ou=groups" user-search-base="ou=people" user-search-filter="uid={0}" /> 
      		<security:authentication-provider ref="secondLdapProvider" /> 
      	 </security:authentication-manager>
         <!--  Traditional Bean version of the same configuration   --> 
         <!--  This bean points at the embedded directory server created by the ldap-server element above  --> 
    	
       	 <beans:bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
           <beans:constructor-arg value="ldap://localhost:10389/dc=springframework,dc=org" /> 
         </beans:bean>
    	 
    	<beans:bean id="secondLdapProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
     	 <beans:constructor-arg>
      		<beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
      			 <beans:constructor-arg ref="contextSource" /> 
      				<beans:property name="userSearch">
      					<beans:bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
      						<beans:constructor-arg index="0" value="ou=users" /> 
      						<beans:constructor-arg index="1" value="(uid={0})" /> 
      						<beans:constructor-arg index="2" ref="contextSource" /> 
      	       			</beans:bean>
      				</beans:property>
      		</beans:bean>
      	 </beans:constructor-arg>
      	 <beans:constructor-arg>
    		 <beans:bean class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
      			<beans:constructor-arg ref="contextSource" /> 
      			<beans:constructor-arg value="ou=groups" /> 
      			<beans:property name="groupSearchFilter" value="(member={0})" /> 
      			<beans:property name="rolePrefix" value="ROLE_" /> 
      			<beans:property name="searchSubtree" value="true" /> 
      			<beans:property name="convertToUpperCase" value="true" /> 
      		 </beans:bean>
      	 </beans:constructor-arg>
        </beans:bean> 										
    	
    </beans:beans>

    any help will be apreciated
    thanks

  • #2
    What version of spring-context do you have? It looks like it is loading the 2.x version of ConfigurableApplicationContext. You should have all the same versions of spring on your classpath (i.e. all 3.x).

    Comment


    • #3
      still don't want to work

      thanks I didn't remark That I put 2 spring context of 2 versions
      but I still have aa problem :

      Code:
      [ERROR,ContextLoader] Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.apacheDirectoryServerContainer': Resolution of declared constructors on bean Class [org.springframework.security.ldap.server.ApacheDSContainer] from ClassLoader [WebappClassLoader
        delegate: false
        repositories:
          /WEB-INF/classes/
      ----------> Parent Classloader:
      org.apache.catalina.loader.StandardClassLoader@19c26f5
      ] failed; nested exception is java.lang.NoClassDefFoundError: org/apache/directory/shared/ldap/exception/LdapNameNotFoundException
      	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:155)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
      	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
      	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
      	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
      	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
      	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
      	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
      	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
      	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
      	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      Caused by: java.lang.NoClassDefFoundError: org/apache/directory/shared/ldap/exception/LdapNameNotFoundException
      	at java.lang.Class.getDeclaredConstructors0(Native Method)
      	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
      	at java.lang.Class.getDeclaredConstructors(Unknown Source)
      	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:152)
      	... 29 more
      Caused by: java.lang.ClassNotFoundException: org.apache.directory.shared.ldap.exception.LdapNameNotFoundException
      	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
      	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
      	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
      	... 33 more
      I attached an image of what I use as libraries.

      Thanks

      Comment


      • #4
        What are you using to manage dependencies (i.e. ivy, maven, gradle, manually, etc)? I would suggest you checkout the Spring Security ldap sample and look at the dependencies listed on it. You can perform this using gradle --dependencies. Alternatively you can Goolge for your error and it will tell you the missing jar.

        Comment


        • #5
          Actually I manage them manually . I tried google but I didn't put the write keys words I think thanks for the help I'm gooing to try this now and I will keep you informed.

          Thanks

          Comment


          • #6
            If you are managing them yourself, you'll need to include almost all the JARs shipped with ApacheDS. As Rob says, it's easiest just to have a tool manage the dependencies for you

            Comment


            • #7
              Thanks,

              I did include them But still have that problem. I want to know what can offert me a manager and if doesn't bother you can you suggest me a tool for managing dependencies but a simple one please(A day or less to understand it and use it).


              Thanks

              Comment


              • #8
                I prefer maven because it is simple and well established. If you use eclipse, I recommend the m2eclipse plugin.

                Comment


                • #9
                  I installed it but I didn't found a simple tutorial to use it.

                  Comment


                  • #10
                    I'm not really sure how we can help you further; we've provided many pointers to ways you can make this work. Maven is well-documented, and there are lots of tutorials and books available to help you learn how to use it.

                    Comment


                    • #11
                      I already pointed you to this thread which has instructions on how to get the example running. I'm afraid I have to agree with Peter; I don't think this is really the place to get help with managing dependencies. I suggest doing a little reading/Googling if you are having problems using Maven.

                      Cheers,

                      Comment


                      • #12
                        I was not demanding help I think this is not the place to demand help on maven
                        I was just informing rob of the advancement because he was kind to me

                        Comment


                        • #13
                          Maybe not a dependency issue

                          Actually I got a similar issue, while using Maven for dependency resolution. After getting through different versions of artifacts, it appears the class "org.apache.directory.shared.ldap.exception.LdapNa meNotFoundException" was removed from library "org.apache.directory.shared:shared-ldap" between versions 0.9.18 and 0.9.19. These dependencies are brought by library "org.apache.directory.server:apacheds-core" respectively in versions 1.5.6 and 1.5.7.

                          Public API policy seems a bit weird to me here :S

                          Comment


                          • #14
                            @Olivier, I don't claim to be an expert on Apache DS; however, my experience when trying to use it with Spring Sec / Spring LDAP in the past was that I had much better luck with Apache DS 1.5.6. I don't remember the problems I had with 1.5.7, but they may have been exactly what you described. Try 1.5.6 and see if you have more success (you may have to force this version in your Maven POM if other POMs are trying to use a more recent one).

                            Comment

                            Working...
                            X