Class Cast Exception in Portable Remote Object

Reply

Join Date: Jul 2008
Posts: 1
Reputation: vishal2901 is an unknown quantity at this point 
Solved Threads: 0
vishal2901 vishal2901 is offline Offline
Newbie Poster

Class Cast Exception in Portable Remote Object

 
0
  #1
Jul 14th, 2008
Hai guys,

I am new at jsp.I have made a simple j2ee application in which i am getting class cast exception in PortableRemoteObject.narrow function.

The exception is:
  1. org.apache.jasper.JasperException
  2. org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
  3. org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
  4. org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
  5. javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
  6. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  7. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  8. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  9. java.lang.reflect.Method.invoke(Method.java:585)
  10. org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
  11. java.security.AccessController.doPrivileged(Native Method)
  12. javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
  13. org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
  14. org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)

The root cause is :
  1. java.lang.ClassCastException
  2. com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
  3. javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
  4. org.apache.jsp.registration_jsp._jspService(registration_jsp.java:59)
  5. org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
  6. javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
  7. org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
  8. org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
  9. org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
  10. javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
  11. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  12. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  13. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  14. java.lang.reflect.Method.invoke(Method.java:585)
  15. org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
  16. java.security.AccessController.doPrivileged(Native Method)
  17. javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
  18. org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
  19. org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)


The code of the file is :
  1. <%@ page language="java" import="java.sql.,pkg.,javax.ejb.,javax.naming.,javax.rmi.PortableRemoteObject,java.rmi.RemoteException" %>
  2. <html>
  3. <head>
  4. <title></title>
  5. </head>
  6. <body bgcolor="CCCCFF">
  7. <h1><center>Welcome to MyBank</center></h1>
  8. <%
  9. InitialContext initial = new InitialContext();
  10. Object objref = initial.lookup("bankDSN");
  11. pkg.mybankHome vi = (pkg.mybankHome)PortableRemoteObject.narrow(objref,pkg.mybankHome.class);
  12. %>
  13. </body>
  14. </html>

I have read many threads but i was not able to solve this problem.
It has been 2 to 3 weeks that i am struck in this error.
Plz help me with this.

Thanks in advance.
Last edited by peter_budo; Jul 14th, 2008 at 8:41 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 114
Reputation: ejosiah is an unknown quantity at this point 
Solved Threads: 12
ejosiah's Avatar
ejosiah ejosiah is offline Offline
Junior Poster

Re: Class Cast Exception in Portable Remote Object

 
0
  #2
Jul 14th, 2008
The simple anwser to this is that pkg.mybankHome and PortableRemoteObject.narrow are not of the same type or do not belong to the same class hierarchy. In simple terms u cant do this

Cat cat = (cat)new Dog();

or can you?

Think about this for a sec.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC