1 Reply Latest reply on Jan 21, 2015 6:54 AM by valsaraj viswanathan

    IllegalArgumentException while setting LdapContext

    valsaraj viswanathan Master

      java.lang.IllegalArgumentException: Can not set javax.naming.ldap.LdapContext field org.app.security.bean.SecurityBean.ctx to javax.naming.directory.InitialDirContext$$$$Proxy1

        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) [rt.jar:1.7.0_07]

        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) [rt.jar:1.7.0_07]

        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [rt.jar:1.7.0_07]

        at java.lang.reflect.Field.set(Field.java:680) [rt.jar:1.7.0_07]

        at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:108)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56) [wildfly-weld-8.2.0.Final.jar:8.2.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.weld.ejb.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:94) [wildfly-weld-8.2.0.Final.jar:8.2.0.Final]

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]

        ... 90 more

       

      I have injected resource in SecurityBean like this:

      @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>