File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes ClassCast exception working with Remote session bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ClassCast exception working with Remote session bean" Watch "ClassCast exception working with Remote session bean" New topic
Author

ClassCast exception working with Remote session bean

kaarthik asokkumar
Greenhorn

Joined: Jan 21, 2005
Posts: 29
hi
I am working with EJB3 in jboss container using a eclipse id. I created a test session bean(stateless) and created a remote interface. I have my ejb in a separate ear and i am trying to access the ejb through from UserInterface ear (differrent ear but they share the same jvm). I get a class cast exception

Object ob = context.lookup("pfmbusinessenterprise/CalculatorBean/remote");
CalculatorRemote calc = (CalculatorRemote) PortableRemoteObject.narrow(ob, CalculatorRemote.class);

I explicitly created CalculatorRemote interface in the UserInterface ear.

I dont get this error when i explicitly add the ejb application as a dependency. I dont want to do this as i wanted to have the 2 ears separate.

JNDI look up is fine but its the casting that is causing a problem. I dont know what i am missing..

java.lang.ClassCastException
18:33:18,996 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
18:33:18,996 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
18:33:18,996 ERROR [STDERR] at business.test.clienttest.test(clienttest.java:13)


@ Stateless
public class CalculatorBean implements CalculatorRemote {

public String test (){
return "You are ok";
}
}

import javax.ejb.Remote;

@Remote
public interface CalculatorRemote {
public String test ();
}

Any help would be great.


SCJP 1.4, SCWCD 1.4,SCBCD 1.3.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Try not using the PortableRemoteObject...


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
kaarthik asokkumar
Greenhorn

Joined: Jan 21, 2005
Posts: 29
i think i know what the issue is. I need to generate my stubs. Can any one please share some experience on generating the stubs using eclipse and jboss ??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ClassCast exception working with Remote session bean
 
Similar Threads
Could not access Local Session Bean using JNDI lookup
Problem in running ejb sample program
jndi settings for statefull session bean
Simple & Basic EJB application -- Help is needed
Problem in JNDI look up in ejb 3.0