on 02-23-2005 6:05 AM
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
...
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Hi Shin,
Can you give me what exception or error you get when deploy this application?
Regards,
Bhavik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi shin,
Replace your Look up string with "jdo/defaultPMF".
Let me know the status.
Regards,
Bhavik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.