-
2. Re: WildFly External Context - LDAP
valsaraj007 Jan 9, 2015 4:52 AM (in response to emmartins)Thanks Eduardo.
I have used
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<external-context name="java:global/ldap" module="org.jboss.as.naming" class="javax.naming.ldap.InitialLdapContext" cache="true">
<environment>
<property name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/>
<property name="java.naming.provider.url" value="ldaps://localhost:636"/>
<property name="java.naming.security.authentication" value="simple"/>
<
property
name
=
"java.naming.security.principal"
value
=
"uid=admin,ou=system"
/>
<
property
name
=
"java.naming.security.credentials"
value
=
"secret"
/>
</environment>
</external-context>
</bindings>
<remote-naming/>
</subsystem>
and got the following error:
ERROR [org.jboss.as.naming] (XNIO-1 task-1) JBAS011812: Failed to obtain jndi view value for entry ldap.: java.lang.RuntimeException: java.lang.NoSuchMethodException: javax.naming.ldap.InitialLdapContext.<init>(java.util.Hashtable)
What may be the problem?
-
3. Re: WildFly External Context - LDAP
emmartins Jan 9, 2015 5:26 AM (in response to valsaraj007)1 of 1 people found this helpfulTry class attribute with value javax.naming.directory.InitialDirContext, the value you used is a class that does not have the constructor with the standard environment map argument, which we internally use to build the initial context. I will update the docs to mention that requirement.
-
4. Re: WildFly External Context - LDAP
valsaraj007 Jan 9, 2015 6:12 AM (in response to emmartins)I am injecting resource like this:
@Resource(lookup = "java:global/ldap")
private LdapContext ctx;
Will that work in the same way if I used class attribute with value javax.naming.directory.InitialDirContext?
-
5. Re: WildFly External Context - LDAP
valsaraj007 Jan 14, 2015 7:22 AM (in response to valsaraj007)Hi Eduardo,
I am getting this error when I access the EJB, java.lang.IllegalArgumentException: Can not set javax.naming.ldap.LdapContext field org.app.security.bean.SecurityBean.ctx to javax.naming.directory.InitialDirContext$$$$Proxy1.
Here is my code and configuration:
@Resource(lookup = "java:global/ldap")
private LdapContext ctx;
<external-context name="java:global/ldap" module="org.jboss.as.naming" class="javax.naming.ldap.InitialLdapContext" cache="true">
<environment>
<property name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/>
<property name="java.naming.provider.url" value="ldaps://localhost:636"/>
<property name="java.naming.security.authentication" value="simple"/>
<
property
name
=
"java.naming.security.principal"
value
=
"uid=admin,ou=system"
/>
<
property
name
=
"java.naming.security.credentials"
value
=
"secret"
/>
</environment>
</external-context>
-
6. Re: WildFly External Context - LDAP
emmartins Jan 14, 2015 10:47 AM (in response to valsaraj007)Use javax.naming.directory.InitialDirContext as class attribute value, as I said before you can't use javax.naming.ldap.InitialLdapContext due to not having the required constructor.
Wrt resource injection, when using javax.naming.directory.InitialDirContext you can inject the external context to that class or any interfaces it implements, which do not include LdapContext...
-
7. Re: WildFly External Context - LDAP
valsaraj007 Jan 15, 2015 12:14 AM (in response to emmartins)Is it possible to inject to javax.naming.directory.InitialDirContext and then cast to javax.naming.ldap.InitialLdapContext to perform operations with LDAPv3-style controls and perform LDAPv3-style extended operations?