This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ClassCastException ;  javax.rmi. Portable Remote Object. narrow(Unknown Source) 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 » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ClassCastException ;  javax.rmi. Portable Remote Object. narrow(Unknown Source)" Watch "ClassCastException ;  javax.rmi. Portable Remote Object. narrow(Unknown Source)" New topic
Author

ClassCastException ; javax.rmi. Portable Remote Object. narrow(Unknown Source)

Shivakanth Thyagarajan
Ranch Hand

Joined: Mar 28, 2005
Posts: 41
Dear Ranchers,
I am trying to run AdviceClient and i am getting the below exception.

java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at AdviceClient.go(AdviceClient.java:24)
at AdviceClient.main(AdviceClient.java:11)

I have done all possible things. I have j2ee.jar in the classpath and the client jar also in the classpath. I tried to find it in the google but with little vain. I am using j2ee 1.4 server and Operating system is Windows XP.

Please help me out. I have lost my patience.

Thanks
Shivakanth.T
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

Hi Shivakanth
Make sure that the class type which you pass as an argument to the narrow method is of the same type as the home interface and that the cast is being made to that same home type. Also, make sure that the
home is not local.

Regards,
Mars.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
Shivakanth Thyagarajan
Ranch Hand

Joined: Mar 28, 2005
Posts: 41
I could solve this we need to add one more jar file in the CLASSPATH and it works.

<install-dir>\lib\appserv-rt.jar

Hope this would be helpful for someone in future.

Thanks
Shivakanth.T
Conor Williams
Greenhorn

Joined: Oct 31, 2012
Posts: 4
probably a bit late but,
i got it by running 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!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ClassCastException ; javax.rmi. Portable Remote Object. narrow(Unknown Source)
 
Similar Threads
AdviceClient
Head First EJB - Problem Running Client of 1st example of EJB.
Head First EJB - JNDI Error
HF EJB. AdviceBean example. BAD_OPERATION exception
Not able to run the AdviceClient program mentioned in Chapter 1 of Head First EJB