cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

...

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

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:

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

Hope that helps!

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Shin,

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

Regards,

Bhavik

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi shin,

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

Let me know the status.

Regards,

Bhavik

Former Member
0 Kudos

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.