on 02-12-2009 6:33 AM
Hi friends,
I am trying to invoke an eij object without adding the ejb archive file to the project lib folder..
how can i do this ...
here am using ejb reflection concept (this works fine in other web servers like weblogic)
here my code is ..
try{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL,"sapsrv02:p4_50204");
InitialContext context = new InitialContext(props);
Object obj = context.lookup("PayCheckBeanJNDI");//HWBean //JNDI
EJBHome home = (EJBHome)PortableRemoteObject.narrow(obj,EJBHome.class);
}catch(NamingException e) {
msgMNG.reportException("NamingException : "+e.getMessage(),false);
} catch (javax.ejb.EJBException e) {
msgMNG.reportException("javax.ejb.EJBException : "+e.getMessage(),false);
}catch(Exception e){
msgMNG.reportException("Exception : "+e.getMessage(),false);
}
I am facing an exception while running this code ...
classcastExceptio : javax. ejb.EJBHome
I have ,add the ejb20.jar, sapj2eeclinet.jar in classpath still am facing the same problem..
Can anyone help me..
Thanks & Regards
Krish
Hi,
Following is the code to access an EJB from Java using CE, may be of use for you
Properties props =new Properties();
props.put (Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL,"localhost:50004");
InitialContext context = new InitialContext(props);
Object obj = context.lookup("com.sap/CalculatorServiceEAR/REMOTE/CalculatorBean/com.bcone.test.CalculatorRemote");
System.out.println(obj.getClass());
CalculatorRemote helloRef = (CalculatorRemote)
PortableRemoteObject.narrow(obj, CalculatorRemote.class);
System.out.println(helloRef.add(10, 20));
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Object obj = context.lookup("com.sap/CalculatorServiceEAR/REMOTE/CalculatorBean/com.bcone.test.CalculatorRemote");
System.out.println(obj.getClass());
CalculatorRemote helloRef = (CalculatorRemote)
PortableRemoteObject.narrow(obj, CalculatorRemote.class);
System.out.println(helloRef.add(10, 20));
The above works fine when i add the CalculatorEJB.jar to my project classpath..
But my recuirment is ..
-> do not add the CalculatorEJB.jar to my project classpath..
-> Should invoke the ejb object by using jndi name alone
Wanna to load the CalculatorRemote class in
EJBHome home = (EJBHome)PortableRemoteObject.narrow(obj, javax.ejb.EJBHome.class);
This is possible in weblogic server by using reflection technology... Whether this can be done using sap server ...
If it is possible means, how can be done?
Thanks
Krish
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
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.