i have deployed the web application sucessfully in j2ee application server.When i run this application i am getting following errors: java.lang.ClassCastException at com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow() on this code Context ic = new InitialContext(); java.lang.Object objref = ic.lookup("java:comp/env/ejb/Category"); catHome = (CategoryHome) PortableRemoteObject.narrow(objref,ejbBeans.CategoryHome.class); I have been stuck to this for last 4 days.I have searched from net but do not get any clue.
Hello Rohit, The reason you are getting the classcast exception is because the jar file is not on the class path of your client application.
When you are deployed the application , by clicking on the "Deploy application" menuitem, did you click on the check box which said "Return Client.jar"? You have to do this, as this jar will contain the stubs which the client needs.After you have done the above and deployed it put the jar file in the same directory where the client file is present.This will help you in running the client successfully
And Ilya the J2ee server is not a bad one.I think everone who is trying to learn EJB should start deploying first on the J2EE server before proceeding to other commericial servers because this server is good in a academic point of you where you get to see what is happenning(The process run's in front of your eyes giving clues on what is happening on the background)unlike a server like Weblogic6.0 where you run commands which will do the job for you but you won't know what exactly happened on the background. Hope this helps, Manjunath P.S Rohit :I think this will also help you in your other question which you had posted regarding the the two ejb's not working concurrently.Put the jar files for both the ejb's in the same directory where your client class file is present. [This message has been edited by Manjunath Subramanian (edited August 18, 2001).] [This message has been edited by Manjunath Subramanian (edited August 18, 2001).]
Joined: Jul 11, 2001
Hi manju, thanks for helping me, i want to know one thing from you about directory structure. when i deploy the application in j2ee, the web part is stored in root directory i.e j2sdkee1.2.1/public_html/applicationName/*.jsp j2sdkee1.2.1/public_html/applicationName/web-inf/classes/*.class here *.class are the javBeans that act as clients to ejbs and ejb jars are stored in j2sdkee1.2.1/repository/machineName/applications/*.jar where jar has sellLoginClient.jar,sellLogin1823703Server.jar andsellLogine6014793825.jar now if i donot check the return client, i think it automaticaaly creats that client.jar into it. I have tried what you have told but of no use, either i am doing it in wrong way. i am getting one client.jar for one application. please tell me in steps what i have to do. i have LoginEJB.class and CategoryEJB.calss plus their homes and Remotes. LoginBean.class and CategoryBean.class javaBeans acts as cleints for their respective EJBbeans. two jsp files Login.jsp and category.jsp. first file of application to be called is category.jsp which checks the sessions for user. please tell me what i have to do from scratch with there directory structure. with thanks, rohit
Try giving the full package name ie as below catHome = (ejbBeans.CategoryHome.class) PortableRemoteObject.narrow(objref,ejbBeans.CategoryHome.class); //Your code is below. catHome = (CategoryHome) PortableRemoteObject.narrow(objref,ejbBeans.CategoryHome.class);