Skip to Content
avatar image
Former Member

Hi, I wanna get PMF using JNDI lookup. How can I do?

I have coded client program.

This program is very simple client java program.

...

public static void main(String args[]) {

...

Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY,

"com.sap.engine.services.jndi.InitialContextFactoryImpl");

props.put(Context.PROVIDER_URL,"HOME01:50004");

props.put(Context.SECURITY_PRINCIPAL, "Administrator");

props.put(Context.SECURITY_CREDENTIALS, "erperp");

try {

Context ctx = new InitialContext( props );

pmf = (PersistenceManagerFactory)

ctx.lookup("sap.com/com.sap.jdo/jdo/DefaultPMF");

} catch(NamingException ne) {

System.out.println( ne.toString() );

}

...

}

The props properties is correct.

The ctx.lookup statement is not run correctly.

How can I write this string?

Visual Admin path..

- Deploy Service

- connector

- sap.com/com.sap.jdo

jdo/defaultPMF - connector

...

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Feb 23, 2005 at 06:53 AM

    Hi shin,

    Replace your Look up string with "jdo/defaultPMF".

    Let me know the status.

    Regards,

    Bhavik

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I already tried it. Thie string "jdo/defualtPMF" is not run correctly too.

      ¤Ð¤Ð

      The JNDI lookup naming rule is very hard to set to me....

      Thanks Bhavik.

      If I solve the program, i will let you know how can I make it.

  • avatar image
    Former Member
    Feb 23, 2005 at 07:44 AM

    Hi Shin,

    Can you give me what exception or error you get when deploy this application?

    Regards,

    Bhavik

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Return Error is below.

      com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at jdo, the whole lookup name is jdo/defaultPMF.

      As you knew, This application is a simple J2SE app.

      Thank you for your interest

  • avatar image
    Former Member
    Feb 23, 2005 at 08:19 AM

    Hi Shin,

    Use given below JNDI name. Now i am sure it will work.

    "mcf/jdo/defaultPMF"

    If it works fine then let me know, and reward this and close the thread.

    Regards,

    Bhavik

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Above all. Thank for your kindness.

      This sting "mcf/jdo/defaultPMF" is run correctly..

      But, one problem occurs.

      java.lang.ClassCastException at com.mentor.education.java.businesslogic.Main.main(Main.java:54)

      pmf = (PersistenceManagerFactory) ctx.lookup("mcf/jdo/defaultPMF");

      pmf is a javax.jdo.PersistenceManagerFactory reference variable.

      humm.. I wanna get a PersistenceManagerFactory via JNDI.

      Could you let me know what means "mcf"?

      You care me as if you are my parents. Thanks.

      Message was edited by: JUNHA SHIN

  • avatar image
    Former Member
    Feb 23, 2005 at 09:24 AM

    Hi Shin,

    Check whether the type of the object of pmf is correct or not. Check whether are you typecasting in proper class or not.

    And don't forget to reward points. 😉

    Regards,

    Bhavik

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 23, 2005 at 09:37 AM

    Hi,

    actually, the "mcf/jdo/defaultPMF" (as Bhavik suggested)is not the right string to use in the lookup (although it works)! This lookup returns a MCFWrapper object which cannot be cast to PersistenceManagerFactory (MCFWrapper object is used internally by the application server.)

    The correct lookup string to use will be "deployedAdapters/jdo/defaultPMF/shareable/jdo/defaultPMF", which returns a reference object that can be cast to the PersistenceManagerFactory.

    However, I'd like to make a note here. Using JDO PMF from a remote java client directly is not a good approach, as you will miss features (such as security, pooling, etc.) offered on the server-side. Therefore, the recommended way is to use it from a J2EE compoment (servlet, EJB). For more info, see documentation:

    JDO" target="_blank">http://help.sap.com/saphelp_nw04/helpdata/en/05/7037b0b8b04c27a55c44c8b8ba5743/frameset.htm">JDO Programming Models.

    Hope that helps!

    Add comment
    10|10000 characters needed characters exceeded