Monday, November 26, 2012

Grails: How to Solve The LDAP Plugin Error While Trying Startup Your App On Tomcat

There is a bug on the LDAP Plugin 0.8.2 that makes it incompatible with the Tomcat server. If you are getting the follow error when you try startup your WAR file on Tomcat server you can try that soluction!

The Message Error

19/11/2012 10:36:08 
org.apache.catalina.core.StandardContext listenerStartGRAVE: Exception sending 
context initialized event to listener instance of class 
org.codehaus.groovy.grails.web.context.GrailsContextLoaderListenerorg.springframework
.beans.factory.BeanCreationException: Error creating bean with name 
'ldapAuthoritiesPopulator': Cannot resolve reference to bean 'contextSource' while 
setting constructor argument; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with 
name 'contextSource': Instantiation of bean failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Could not instantiate bean 
class [org.springframework.security.ldap.DefaultSpringSecurityContextSource]: 
Constructor threw exception; nested exception is java.lang.NoSuchMethodError: 
org.springframework.security.ldap.DefaultSpringSecurityContextSource.setAuthenticationStrategy(Lorg/springframework/ldap/core/support/DirContextAuthenticationStrategy;)V 
at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) at 
org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630) at 
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148) at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035) at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939) at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at 
org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:126) at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at 
...

The Soluction

Just replace the gldapo-0.8.2.jar and spring-ldap-1.2.1.jar lib files for the gldapo-0.8.5.jar and spring-ldap-1.3.0.jar and rename them as gldapo-0.8.2.jar and spring-ldap-1.2.1.jar on your grails project directory (<your user directory/.grails/<your grails version>/projects/<your project name>/plugins/ldap-0.8.2/lib).

So, you will need the gldapo-0.8.5.jar and spring-ldap-1.3.0.jar files. Unfortunately I don't remember when I've got them, but you can search them on the internet.

4 comments:

  1. it works for me !! thank you :)

    ReplyDelete
    Replies
    1. Thanks for comment, Grissa. I'm happy that it helped you!

      Delete
  2. We have 2015, ldap plugin is great but the problem still exists.
    Please find programmatic solution to that problem:
    http://stackoverflow.com/a/28874887/1345116

    ReplyDelete
  3. Today, computer has changed the whole scene of entire world. Many tasks of done manually previously after spending extended hours, is now able to be accomplished within a few momemts... Health

    ReplyDelete