aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Accessing EJB on websphere 3.5 from Java Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Accessing EJB on websphere 3.5 from Java Client " Watch "Accessing EJB on websphere 3.5 from Java Client " New topic
Author

Accessing EJB on websphere 3.5 from Java Client

gowrish bhaskar
Greenhorn

Joined: Oct 03, 2001
Posts: 9
hi,
i need to access EJB deployed on WAS 3.5 advanced from a java stand alone client. I have included the following jar files in the clientclasspath..admin.jar,ejs.jar,ns.jar,repository.jar,ujc.jar
and i am using jdk provided with WAS..
When i run my client application it gives the following exception
javax.naming.NamingException: Error during resolve. Root exception is java.lang.NullPointerException
at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNContextImpl.java:744)
at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContextImpl.java:590)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at TestClient.main(TestClient.java:34)
please help me out,
Gowrish

------------------

Regards,<br />Gowrish.B<br />gowrishb@hotmail.com
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
It's hard to tell what's wrong without seeing your code, but here are my thoughts:
- your error message states "Root exception is java.lang.NullPointerException" at "TestClient.main(TestClient.java:34)".
- In TestClient.java, how exactly are you calling InitialContext.lookup()? Are you passing in a null variable?
-miftah
gowrish bhaskar
Greenhorn

Joined: Oct 03, 2001
Posts: 9
hi Miftah Khan,
Thanks for the reply..
so i am now pretty sure that somebody in the world is there to help me out..
The code for look up is :
java.util.Properties hashTable = new java.util.Properties();
hashTable.put(javax.naming.Context.PROVIDER_URL,"iiop://hcl-rti006:900");
hashTable.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
InitialContext ctx = new InitialContext(hashTable);
Object objref = ctx.lookup("LOGIN");
home= (LoginHome) PortableRemoteObject.narrow ((org.omg.CORBA.Object)objref,LoginHome.class);
I get this exception when i try to lookup for jndi name "LOGIN"
The same jndi works fine in a servlet
Thanks in advance
Gowrish
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I'm puzzled.. the only things I can think of is..
Are you doing anything differently between the servlet and the ejb, like having an ejb-ref in web.xml but no corresponding ejb-ref in ejb-jar.xml?
Good luck.

[This message has been edited by Miftah Khan (edited October 04, 2001).]
gowrish bhaskar
Greenhorn

Joined: Oct 03, 2001
Posts: 9
hi,
what i mean to say in my previous posting is
when i try to lookup the ejb from the servlet, it works fine.
but when i try to do the same from a java client it gives the above mentioned exception
gowrish
[This message has been edited by gowrish bhaskar (edited October 05, 2001).]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
OK, this is probably a stupid question (but those questions often end up having interesting ramifications) but are the Java client and the Servlet running on the same machine? If not, can you ping the hostname that you've given in the iiop://hostname:900 line from the machine that you are running the client on?

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Accessing EJB on websphere 3.5 from Java Client