0

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

3
  • 1
    It seems some jars missing in classpath. Commented Jun 18, 2012 at 14:19
  • I don't think that any jar is missing. if the jar was missing, then exception should be like classnotfoundexception. Commented Jun 18, 2012 at 17:42
  • It is trying reflection, as per java doc it could be due to classdef not found docs.oracle.com/javase/6/docs/api/java/lang/… Commented Jun 18, 2012 at 19:50

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.