wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes P.R.O. narrow throws ClassCastException (RI/AS8) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "P.R.O. narrow throws ClassCastException (RI/AS8)" Watch "P.R.O. narrow throws ClassCastException (RI/AS8)" New topic
Author

P.R.O. narrow throws ClassCastException (RI/AS8)

Toby Eggitt
Ranch Hand

Joined: Dec 08, 2004
Posts: 41
I'm trying to work the example in HeadFirst Java, the advisor one... I'm using the Referece Implementation. I compile, package, and deploy happily enough (after a couple of hours searching these archives to discover the need for "Context.INITIAL_CONTEXT_FACTORY" and stuff), but when I try to run the client, I get a class cast exception. This exception is being created by the narrow method itself. I separated out the narrow from the Java-level cast so I could distinguish. The error looks like this:

looking for a Advisor
got something back, it's a com.sun.corba.se.internal.iiop.CDRInputStream_1_0$1:IOR:000000000000002a524d493a6865616466697273742e416476696365486f6d653a30303030303030303030303030303030000000000000010000000000000188000102000000000c3139322e3136382e322e33000e74000000000056afabcb00000000260000003f00000009533141532d4f5242000000000000000200000008526f6f74504f41000000001237323235353736343933383432343332300000000000000d0100b43c4221000000000001ff0a0000000000070000000100000020000000000001000100000002050100010001002000010109000000010001 01000000002600000002000200000000000300000016000000000000000c3139322e3136382e322e33000eec00000000000300000016000000000000000c3139322e3136382e322e33000f5000000000001f0000000400000003000000200000000400000001000000210000007c000000000000000100000000000000240000001e0000006600000000000000010000000c3139322e3136382e322e33000eec004000000000000000080606678102010101000000170401000806066781020101010000000764656661756c74000400000000000000000000010000000806066781020101010000000f
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at AdviceClient.go(AdviceClient.java:26)
at AdviceClient.main(AdviceClient.java:10)

The stuff about "Looking for an Advisor" and "got something back, it's a blah blah" are debug messages I added so I could see confidently what the lookup was looking for, and what was returned. I just do a S.o.p on the returned object from the lookup.

As you see, the narrow then explodes, apparently claiming that what the lookup returned can't be turned into an AdviceHome.

Any suggestions? I have undeployed and redeployed till I'm blue in the face, and I'm currently reinstalling the RI from scrach in case there was anything stupid left behind (I tried to use JBoss earlier, but that was awful! [or maybe I just don't understand it])

Thanks for any help you can offer,
Toby
Conor Williams
Greenhorn

Joined: Oct 31, 2012
Posts: 4
probably a bit late but,
run it like this: (pointing to the jar created by RI)
C:\ejb\headfirst>c:\j2sdk1.4.2_15\bin\java -classpath adviceappClient.jar;%CLASS
PATH% AdviceClient

happy Christmas!
 
jQuery in Action, 2nd edition
 
subject: P.R.O. narrow throws ClassCastException (RI/AS8)
 
Similar Threads
HeadFirst EJB question. java.rmi.RemoteException: CORBA BAD_OPERATION
HF - What goes where question
P.R.O.narrow throwing ClassCastException?
Too many exceptions for first EJB Client App
P.R.O.narrow throws ClassCastException