• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Bear Bibeault
  • paul wheaton
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Mikalai Zaikin
  • Piet Souris
Bartenders:

ClassCast exception working with Remote session bean

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try not using the PortableRemoteObject...
 
kaarthik asokkumar
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ??
 
I don't like that guy. The tiny ad agrees with me.
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic