Anyway I got the error,
nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy142 implementing javax.naming.directory.DirContext,javax.naming.ldap.LdapContext,javax.naming.Context] to required type [org.springframework.ldap.core.support.BaseLdapPathContextSource]: no matching editors or conversion strategy found
Think that I should use some Spring ldap classes to create the jndi or have to write the classes, but I can't find any document talking about that.
Please anyone can help me out? Thank you very much.
If you are just trying to externalize URL and password to JNDI you could go the JMX route but if you are using spring 3.1 JNDI Property source is automatically registered for you so you could just store the URL and password in there and access it through SPEL in your context file.
Joined: Jun 20, 2007
Thank you Bill Gorder.
You gave me the alternative ideas.
Actually the way I did for the jndi is correct, it returns the javax.naming.directory.DirContext.
However the spring security <ldap-server> expects the org.springframework.ldap.core.support.BaseLdapPathContextSource (interface of DefaultSpringSecurityContextSource).
That's why the erorr msg complains type is not matched.
So I want to ask further question in another way.
Is there any way to convert javax.naming.directory.DirContext instance to org.springframework.ldap.core.support.BaseLdapPathContextSource instance?
It looks I need the connections between jdk ldap implementation with spring ldap implementation.
That will solve my problem as well.
I am think maybe I can write a new class which implements from BaseLdapPathContextSource to make it work.
Joined: Jun 20, 2007
I have tried this way to write a new class which implements BaseLdapPathContextSource.
Find the interfaces in BaseLdapPathContextSource is nothing but just return the Context.
Since I already have the instance of javax.naming.directory.DirContext from jndi, so implment these getContext methods to return that.
Did a few testings, it works without issue.
Just not sure whether it's a proper approach.
If think about the database datasource, the jndi should return the ContextSource instead of Context. This way could be better.
I find one discusstion about this jndi. That's what I want to know as well.