cancel
Showing results for 
Search instead for 
Did you mean: 

LDAP: Class not found - LdapCtxFactory

matej
Champ in-the-making
Champ in-the-making
Hello,

I have little problem to setup LDAP. Configuration seems to be correct but tomcat starts with this exception:

13:10:02,296  ERROR [web.context.ContextLoader] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationServiceImpl' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\chaining-authentication-context.xml]: Cannot resolve reference to bean 'authenticationServiceImplLDAP' while setting bean property 'authenticationServices' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationServiceImplLDAP' defined in file [C:\Alfrescotomcat\shared\classes\alfresco\extension\chaining-authentication-context.xml]: Cannot resolve reference to bean 'authenticationComponentImplLDAP' while setting bean property authenticationComponent'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationComponentImplLDAP' defined in file [C:\Alfresco\tomcatshared\classes\alfresco\extension\chaining-authentication-context.xml]: Cannot resolve reference to bean 'ldapInitialDirContextFactory' while setting bean property 'LDAPInitialDirContextFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapInitialDirContextFactory' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\ldap-authentication-context.xml]: Invocation of init method failed; nested exception is org.alfresco.repo.security.authentication.AuthenticationException: Unable to connect to LDAP Server; check LDAP configuration 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationServiceImplLDAP' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\chaining-authentication-context.xml]: Cannot resolve reference to bean 'authenticationComponentImplLDAP' while setting bean property 'authenticationComponent'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationComponentImplLDAP' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\chaining-authentication-context.xml]: Cannot resolve reference to bean 'ldapInitialDirContextFactory' while setting bean property 'LDAPInitialDirContextFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapInitialDirContextFactory' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\ldap-authentication
-context.xml]: Invocation of init method failed; nested exception is org.alfresco.repo.security.authentication.AuthenticationException: Unable to connect to LDAP Server; check LDAP configuration

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationComponentImplLDAP' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\chaining-authentication-context.xml]:Cannot resolve reference to bean 'ldapInitialDirContextFactory' while setting bean property 'LDAPInitialDirContextFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapInitialDirContextFactory' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\ldap-authentication-context.xml]: Invocation of init method failed;nested exception is org.alfresco.repo.security.authentication.AuthenticationException: Unable to connect to LDAP Server; check LDAP configuration

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapInitialDirContextFactory' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\ldap-authentication-context.xml]: Invocation of init method failed; nested exception is org.alfresco.repo.security.authentication.AuthenticationException: Unable to connect to LDAP Server; check LDAP configuration

Caused by: org.alfresco.repo.security.authentication.AuthenticationException: Unable to connect to LDAP Server; check LDAP configuration
        at org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl.afterPropertiesSet(LDAPInitialDirContextFactoryImpl.java:239)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:281)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:131)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        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(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.ldap.LdapCtxFactory
                     [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory]
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:197)
        at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:82)
        at org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl.afterPropertiesSet(LDAPInitialDirContextFactoryImpl.java:225)
        … 65 more

Caused by: java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
        … 70 more

08-Apr-2007 13:10:02 org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart
08-Apr-2007 13:10:02 org.apache.catalina.core.StandardContext start SEVERE: Context [/alfresco] startup failed due to previous errors
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
08-Apr-2007 13:10:03 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive share.war
13:10:06,250  INFO  [web.site.FrameworkHelper] Successfully Initialized Web Framework
08-Apr-2007 13:10:06 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive studio.war
13:10:08,343  INFO  [web.scripts.DeclarativeRegistry] Registered 67 Web Scripts(+0 failed), 71 URLs
13:10:08,343  INFO  [web.scripts.AbstractRuntimeContainer] Initialised Presentation Web Script Container (in 307.9425ms)
13:11:09,406  INFO  [web.scripts.DeclarativeRegistry] Registered 101 Web Scripts (+0 failed), 105 URLs
13:11:09,406  INFO  [web.scripts.AbstractRuntimeContainer] Initialised WebFramework Web Script Container (in 61043.84ms)
13:11:09,453  INFO  [web.site.FrameworkHelper] Successfully Initialized Web Framework
08-Apr-2007 13:11:09 org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8080
08-Apr-2007 13:11:09 org.apache.catalina.startup.Catalina start
INFO: Server startup in 91007 ms

Note:
Caused by: java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory

Configuration:
C:\Alfresco\tomcat\shared\classes\alfresco\extension\chaining-authentication-context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
   
    <!– Chaining –>
    <bean id="authenticationServiceImpl" class="org.alfresco.repo.security.authentication.ChainingAuthenticationServiceImpl">
        <property name="authenticationServices">
            <list>
                <ref bean="authenticationServiceImplLDAP"/>
            </list>
        </property>
        <property name="mutableAuthenticationService">
            <ref bean="authenticationServiceImplAlfresco"/>
        </property>
    </bean>
   
    <!– Alfresco Auth –>
    <bean id="authenticationServiceImplAlfresco" class="org.alfresco.repo.security.authentication.AuthenticationServiceImpl">
        <property name="authenticationDao">
            <ref bean="authenticationDaoAlfresco"/>
        </property>
        <property name="ticketComponent">
            <ref bean="ticketComponent"/>
        </property>
        <property name="authenticationComponent">
            <ref bean="authenticationComponentImplAlfresco"/>
        </property>
    </bean>
   
    <bean id="authenticationDaoAlfresco" class="org.alfresco.repo.security.authentication.RepositoryAuthenticationDao">
        <property name="nodeService">
            <ref bean="nodeService"/>
        </property>
        <property name="dictionaryService">
            <ref bean="dictionaryService"/>
        </property>
        <property name="namespaceService">
            <ref bean="namespaceService"/>
        </property>
        <property name="searchService">
            <ref bean="searchService"/>
        </property>
        <property name="userNamesAreCaseSensitive">
            <value>
                ${user.name.caseSensitive}
            </value>
        </property>
        <property name="passwordEncoder">
            <ref bean="passwordEncoder"/>
        </property>
    </bean>
   
    <bean id="authenticationComponentImplAlfresco" class="org.alfresco.repo.security.authentication.AuthenticationComponentImpl">
        <property name="authenticationDao">
            <ref bean="authenticationDaoAlfresco"/>
        </property>
        <property name="authenticationManager">
            <ref bean="authenticationManager"/>
        </property>
        <property name="allowGuestLogin">
            <value>
                true
            </value>
        </property>
    </bean>
   
    <!– LDAP Auth –>
    <bean id="authenticationServiceImplLDAP" class="org.alfresco.repo.security.authentication.AuthenticationServiceImpl">
        <property name="authenticationDao">
            <ref bean="authenticationDaoLDAP"/>
        </property>
        <property name="ticketComponent">
            <ref bean="ticketComponent"/>
        </property>
        <property name="authenticationComponent">
            <ref bean="authenticationComponentImplLDAP"/>
        </property>
    </bean>
   
    <bean id="authenticationComponentImplLDAP" class="org.alfresco.repo.security.authentication.ldap.LDAPAuthenticationComponentImpl">
        <property name="LDAPInitialDirContextFactory">
            <ref bean="ldapInitialDirContextFactory"/>
        </property>
        <property name="userNameFormat">
            <value>
                uid=%s,ou=People,o=company.com
            </value>
        </property>
    </bean>
   
    <bean id="authenticationDaoLDAP" class="org.alfresco.repo.security.authentication.ntlm.NullMutableAuthenticationDao"/>
   
</beans>

C:\Alfresco\tomcat\shared\classes\alfresco\extension\ldap-authentication-context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   
    <bean id="ldapInitialDirContextFactory" class="org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl">
        <property name="initialDirContextEnvironment">
            <map>
                <!– The LDAP provider –>
                <entry key="java.naming.factory.initial">
                    <value>
                        com.sun.jndi.ldap.LdapCtxFactory
                    </value>
                </entry>
               
                <!– The url to the LDAP server –>
                <entry key="java.naming.provider.url">
                    <value>
                        ldap://ldap.dom:389
                    </value>
                </entry>
               
                <!– The authentication mechanism to use      –>
                <!– Some sasl authentication mechanisms may require a realm to be set –>
                <!–                java.naming.security.sasl.realm –>
                <!– The available options will depend on your LDAP provider –>
                <entry key="java.naming.security.authentication">
                    <value>
                        simple
                    </value>
                </entry>
               
                <!– The id of a user who can read group and user information –>
                <!– This does not go through the pattern substitution defined above and is used "as is" –>
                <entry key="java.naming.security.principal">
                    <value>
                        cn=Admin,o=company.com
                    </value>
                </entry>
               
                <!– The password for the user defined above –>
                <entry key="java.naming.security.credentials">
                    <value>
                        password
                    </value>
                </entry>
            </map>
        </property>
    </bean>
   
</beans>

JVM:
Iam running alfresco on JDK 1.6.0_13 (and tried also update 6, 7 also JDK 1.5.0_18 and JRE versions as well but no result)
Missing class is present in rt.jar which was present in all tested java versions.

Alfresco version:
Alfresco-Labs-3Stable-Full-Setup.exe

Has anyone clue where could be the problem?

Regards
Matej
1 REPLY 1

cbarbosa
Champ in-the-making
Champ in-the-making
Hi Matej,

Have you figure out which was the problem??

I also have problems using ldap authentication after update my svn source and would like to know if someone else had troubles and the solution for it.

ldap-authentication.properties


# This properties file brings together the common options for LDAP #authentication rather than editing the bean definitions
#
# How to map the user id entered by the user to taht passed through to LDAP
# - simple
#    - this must be a DN and would be something like
#      CN=%s,DC=company,DC=com
# - digest
#    - usually pass through what is entered
#      %s
#ldap.authentication.userNameFormat=%s
ldap.authentication.userNameFormat=uid=%s,ou=People,dc=EALS,dc=salleURL,dc=edu

# The LDAP context factory to use
ldap.authentication.java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory

# The URL to connect to the LDAP server
ldap.authentication.java.naming.provider.url=ldap://ldap.salle.url.edu:389

# The authentication mechanism to use
‑­
ldap.authentication.java.naming.security.authentication=simple

# The default principal to use (only used for LDAP sync)
#ldap.authentication.java.naming.security.principal=reader
ldap.authentication.java.naming.security.principal=uid=*******,ou=Directory Administrators,o=salleURL.edu

# The password for the default principal (only used for LDAP sync)
ldap.authentication.java.naming.security.credentials=*********

# Escape commas entered by the user at bind time
# Useful when using simple authentication and the CN is part of the DN and contains commas
ldap.authentication.escapeCommasInBind=false

# Escape commas entered by the user when setting the authenticated user
# Useful when using simple authentication and the CN is part of the DN and contains commas, and the escaped \, is  pulled in as part of an LDAP sync
# If this option is set to true it will break the default home folder provider as space names can not contain \
ldap.authentication.escapeCommasInUid=false



ldap-authentication-context.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
    <bean name="authenticationDaoLDAP" class="org.alfresco.repo.security.authentication.DefaultMutableAuthenticationDao" >
    <property name="allowDeleteUser">
        <value>true</value>
    </property>
</bean>

<bean id="authenticationComponentLDAP" class="org.alfresco.repo.security.authentication.ldap.LDAPAuthenticationComponentImpl">
    <property name="LDAPInitialDirContextFactory">
       <ref bean="ldapInitialDirContextFactory"/>
    </property>
    <property name="userNameFormat">
       <value>${ldap.authentication.userNameFormat}</value>
    </property>
   <property name="nodeService">
      <ref bean="nodeService" />
   </property>
   <property name="personService">
      <ref bean="personService" />
   </property>
   <property name="transactionService">
      <ref bean="transactionService" />
   </property>
</bean>

<bean id="ldapInitialDirContextFactory" class="org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl">
        <property name="initialDirContextEnvironment">
            <map>
                <!– The LDAP provider –>
                <entry key="java.naming.factory.initial">
                    <value>${ldap.authentication.java.naming.factory.initial}</value>
                </entry>

                <!– The url to the LDAP server –>
                <!– Note you can use space separated urls - they will be tried in turn until one works –>
                <!– This could be used to authenticate against one or more ldap servers (you will not know which one ….) –>
                <entry key="java.naming.provider.url">
                    <value>${ldap.authentication.java.naming.provider.url}</value>
                </entry>

                <!– The authentication mechanism to use      –>
                <!– Some sasl authentication mechanisms may require a realm to be set –>
                <!–                java.naming.security.sasl.realm –>
                <!– The available options will depend on your LDAP provider –>
                <entry key="java.naming.security.authentication">
                    <value>${ldap.authentication.java.naming.security.authentication}</value>
                </entry>

                <!– The id of a user who can read group and user information –>
                <!– This does not go through the pattern substitution defined above and is used "as is" –>
                <entry key="java.naming.security.principal">
                    <value>${ldap.authentication.java.naming.security.principal}</value>
                </entry>
            </map>
        </property>
    </bean>
</beans>







Regards.


Caio Barbosa