Bharat
Bharat

Reputation: 109

Java LDAP Error while doing the lookup

I am doing a lookup of the Object in the Sun One LDAP and getting the exception given below:

javax.naming.NamingException: problem generating object using object factory [Root
exception is java.lang.IllegalAccessException: Class javax.naming.spi.NamingManager can
not access a member of class com.ldap.java.LDAPFactory with modifiers "public"]; remaining name cn=favorite,dc=xxx,dc=abc,dc=cdf'

The exception is thrown in the code given below where "Read Object back":

        Fruit fruit = new Fruit("orange", "sweet and sour");

        // Perform bind
        ctx.bind("cn=favorite,dc=xxx,dc=abc,dc=cdf", fruit);
        logger.info("Entry bind...Complete");

        // Read object back
        Object f2 = ctx.lookup("cn=favorite,dc=xxx,dc=abc,dc=cdf");
        logger.info("Fruit = " + f2);

        // Read attributes to see encoding
        Attributes attrs = 
                    ctx.getAttributes("cn=favorite,dc=xxx,dc=abc,dc=cdf");
        logger.info("Atrributes = " + attrs);

        // Close the context when we're done
        ctx.close()

Can someone tell me what is wrong in the code?

--

Tks Bharat

Upvotes: 0

Views: 529

Answers (1)

Bharat
Bharat

Reputation: 109

I have resolved the problem by the following piece of code:

Existing Code:

    String classname = Fruit.class.getName();
    StringRefAddr classref = new StringRefAddr("java:".concat(name), fruit + ":" + fruitType);
    String classfactoryname = FruitFactory.class.getName();

    Reference ref = new Reference(classname, classref, classfactoryname, null);

    logger.info("getReference(): END");

    return ref;

New Code:

    String classname = Fruit.class.getName();
    StringRefAddr classref = new StringRefAddr("java:".concat(name), fruit + ":" + fruitType);
    //String classfactoryname = FruitFactory.class.getName();

    Reference ref = new Reference(classname, classref);

    return ref;

--
Tks
Bharat

Upvotes: 1

Related Questions