[jboss-user] [EJB 3.0] - ClassCastException on Stateless Remote Bean

holmes.j do-not-reply at jboss.com
Wed Sep 20 16:39:03 EDT 2006

Just started with the new EJB 3 stuff, so I'm guessing I've done something wrong.  I just can't see what it is.

I'm getting ClassCastExceptions when trying to get the a Remote Session Bean in a JNDI lookup.  It's failing on the cast to the GeoFeatureManager.  

		try {
  | 			String geoFeatureManagerName = "motionbased/GeoFeatureManagerBean/remote";
  | 			InitialContext ctx = new InitialContext();
  | 			Object object = ctx.lookup(geoFeatureManagerName);
  | 			GeoFeatureManager geoFeatureManager = (GeoFeatureManagerBean) object;
  | 			this.geoFeature = geoFeatureManager.findGeoFeature(getGeoFeaturePk());
  | 		} catch (NamingException e1) {
  | 			e1.printStackTrace();
  | 			throw new SQLException(e1.getMessage());
  | 		}

The Remote Interface 

  | @Remote
  | public interface GeoFeatureManager extends Serializable {
  | ...
  | }

The Implementation of it ...

@Stateless(name = "GeoFeatureManagerBean")
  | @Remote( { GeoFeatureManager.class })
  | @RemoteBinding(jndiBinding = "motionbased/GeoFeatureManagerBean/remote")
  | public class GeoFeatureManagerBean implements GeoFeatureManager {
  | 	private static final long serialVersionUID = 6211376611083502502L;

I read this http://wiki.jboss.org/wiki/Wiki.jsp?page=CommonHurdlesAndDifficultiesYouMayEncounterDuringEJB3Development that says to make sure you don't have the class in more than one jar.  I've checked, and it only appears in one of my jars.

When I step through the code, it returns a $Proxy, which contains h, a StatelessRemoteProxy.  Within the proxy it sees the appropriate jar.  And in the EJBMetaData, it has the appropriate interface, GeoFeatureManager.

So, I don't really see what I'm doing wrong.  Hopefully somebody else can point out my mistake.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973079#3973079

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973079

More information about the jboss-user mailing list