Home > Archive > Java Beans > February 2006 > Narrow returns null
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Narrow returns null
|
|
| Christian Naeger 2006-02-10, 7:57 am |
| Hi all,
I desperately need your help.
I have written a simple Statless Session Bean and successfully deployed
it to Sun App Server 8.2. Moreover, I have written a small Java
application (a standalone application, with the jar from a min
get-client-stubs on the classpath) that looks up the Session Bean. The
look up is successful and I get an object of the correct type. The
narrowing does not throw an exception but unfortunately it does return
a null pointer. Please, have a look at the client code and the output
below.
I have tried everything I can think of and I believe I have done
everything correctly. Yet, it just doesn't work. Could anyone please
give a hint what I am probably doing wrong (the API does not mention
narrow returning null and google didn't bring up a solution either)?
Any help is greatly appreciated.
Greetings, Chris
Client-Code:
=========
Hashtable props = new Hashtable();
props.put("java.naming.factory.initial",
"com.sun.jndi.cosnaming.CNCtxFactory");
props.put("java.naming.provider.url", "iiop://localhost:3700");
Context ic = new InitialContext(props);
Object o = ic.lookup("ejb/BankMgr");
if (o == null)
System.out.println("Null Pointer");
else
System.out.println("No Null Pointer");
System.out.println(o.getClass().getName());
System.out.println(o.toString());
System.out.println(BankMgrHome.class);
o = PortableRemoteObject.narrow(o, BankMgrHome.class);
if (o == null)
System.out.println("Null Pointer");
else
System.out.println("No Null Pointer");
Output:
=======
No Null Pointer
com.sun.corba.se.impl.corba.CORBAObjectImpl
IOR:000000000000002f524d493a6e696e762e65
6e7469746965732e42616e6b4d6772486f6d653a
3030303030303030303030303030303000000000
00010000000000000178000102000000000a3132
372e302e302e31000e7400000056afabcb000000
00260000003f00000009533141532d4f52420000
000000000002000
00008526f6f74504f41000000001237343637393
631373538323037313830380000000000000d010
950b76df1000000000001ff14000000000007000
0000100000020000000000001000100000002050
1000100010020000101090000000100010100000
0002600000002000200000000000300000014000
000000000000a31
32372e302e302e31000eec000000030000001400
0000000000000a3132372e302e302e31000f5000
00001f0000000400000003000000200000000400
0000010000002100000078000000000000000100
000000000000240000001c000000660000000000
0000010000000a3132372e302e302e31000eec00
400000000000080
6066781020101010000001704010008060667810
20101010000000764656661756c7400040000000
0000000000000010000000806066781020101010
000000f
interface ninv.entities.BankMgrHome
Null Pointer
| |
| Jeffrey Spoon 2006-02-11, 6:58 pm |
| In message <1139571182.914864.130020@g14g2000cwa.googlegroups.com>,
Christian Naeger <naeger@gmx.de> writes
>
>
>Any help is greatly appreciated.
>Greetings, Chris
>
>Client-Code:
>=========
>
> Hashtable props = new Hashtable();
> props.put("java.naming.factory.initial",
> "com.sun.jndi.cosnaming.CNCtxFactory");
> props.put("java.naming.provider.url", "iiop://localhost:3700");
> Context ic = new InitialContext(props);
> Object o = ic.lookup("ejb/BankMgr");
> if (o == null)
> System.out.println("Null Pointer");
> else
> System.out.println("No Null Pointer");
> System.out.println(o.getClass().getName());
> System.out.println(o.toString());
> System.out.println(BankMgrHome.class);
> o = PortableRemoteObject.narrow(o, BankMgrHome.class);
> if (o == null)
> System.out.println("Null Pointer");
> else
> System.out.println("No Null Pointer");
>
>
>
This is going to be no help whatsoever, but why do you use == to test
the equality of Object o? If you use if(o.equals(null)) you'll get a
null pointer exception.
--
Jeffrey Spoon
|
|
|
|
|