| Author |
accessing EJB from java client Error!
|
Gul Khan
Ranch Hand
Joined: Sep 03, 2003
Posts: 173
|
|
Hi I am new to EJB and am trying to access a session bean from a java client. i m using websphere studio. here is the code for client, Plz help me solve this problem ------------------------------------------ public class ClientTest extends Object { public ClientTest() { } public static void main(String[] args) throws Exception{ Properties h = new Properties(); h.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory"); h.put(Context.PROVIDER_URL,"iiop://127.0.0.1:2809"); // InitialContext ctx = new InitialContext(h); InitialContext ctx = new InitialContext(); Object obj=ctx.lookup("test"); // this is line 30 from error try { TestHome home=(TestHome)PortableRemoteObject.narrow(obj,TestHome.class); Test test=home.create(); System.out.println("Create successfully"); String st=test.getMsg(); test.remove(); } catch(Exception e) { e.printStackTrace(); } } } ------------------------------------------------ and the error i m getting is as follows ---------ERROR ----------- javax.naming.ConfigurationException: Malformed provider URL: corbaloc:iiop:localhost at com.ibm.ws.naming.util.WsnInitCtxFactory.parseBootstrapURL(WsnInitCtxFactory.java:1422) at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:368) at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:102) at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:408) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:131) at javax.naming.InitialContext.lookup(InitialContext.java:359) at ClientTest.main(ClientTest.java:30) Thanks and Regards Gul
|
 |
Gul Khan
Ranch Hand
Joined: Sep 03, 2003
Posts: 173
|
|
|
The same code works when put in a servlet.
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Why have you commented InitialContext ctx = new InitialContext(h); Remove InitialContext ctx = new InitialContext();
|
Groovy
|
 |
Gul Khan
Ranch Hand
Joined: Sep 03, 2003
Posts: 173
|
|
I was testing the client on the same jvm so was trying both way. by passing the properties it gives a context factory error so for compilation sake i was trying without it. but i dont know y it gives malformed url when the same thing is working in the servlet. Thanks for replying
|
 |
Gul Khan
Ranch Hand
Joined: Sep 03, 2003
Posts: 173
|
|
here is the error that i get if i pass the properties to the context ---------- java.lang.IncompatibleClassChangeError: com.ibm.CORBA.iiop.ORB method createObjectURL(Ljava/lang/String Lcom/ibm/CORBA/iiop/ObjectURL; at com.ibm.ws.naming.util.WsnInitCtxFactory.parseIiopUrl(WsnInitCtxFactory.java:1668) at com.ibm.ws.naming.util.WsnInitCtxFactory.parseBootstrapURL(WsnInitCtxFactory.java:1427) at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:368) at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:102) at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:408) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:131) at javax.naming.InitialContext.lookup(InitialContext.java:359) at ClientTest.main(ClientTest.java:30) -----------------------
|
 |
Gul Khan
Ranch Hand
Joined: Sep 03, 2003
Posts: 173
|
|
someone plz help Thanks in advance Gul
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
|
Are you sure that you are using the right jar file at the client side.
|
 |
Gul Khan
Ranch Hand
Joined: Sep 03, 2003
Posts: 173
|
|
|
yes u m using the same jar files. do i need to package the stub files of the ejb or something?
|
 |
 |
|
|
subject: accessing EJB from java client Error!
|
|
|