This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassCast exception working with Remote session bean

 
kaarthik asokkumar
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Harry
Ranch Hand
Posts: 10085
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try not using the PortableRemoteObject...
 
kaarthik asokkumar
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ??
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic