Hi,
I am trying to access an EJB deployed on a remote server (AIX machine) from a Java client which has a main method.
the code I am using is below:
public static void main(String[] args) {
Properties p = new Properties();
p.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");//AS7
p.put(Context.PROVIDER_URL, "jnp://d05leapp02:1299");//server running on 8280, and host is d05leapp02
try {
//bean name is dgin.ol.cs.bo.sb.dbaccess.DBAccessorBean_jndi
Context c = new InitialContext(p);
//ear_name=MTApp.ear; jar_name=dbaccess.jar; Bean_name=DBAccessorBean
String lookupJndi = "ejb:MTApp/dbaccess//DBAccessorBean!" + DBAccessor.class.getName();
System.out.println(lookupJndi);
Object home_obj = c.lookup(lookupJndi);
DBAccessorHome home = (DBAccessorHome) PortableRemoteObject.narrow(home_obj, DBAccessorHome.class);
DBAccessor dba_bean = home.create();
} catch (Exception e) {
e.printStackTrace();
}
}
when executing this code I get ClassCastException, as below:
May 25, 2012 2:59:28 PM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 1.0.2.Final
java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at EJBClientTest.main(EJBClientTest.java:29)
Caused by: java.lang.ClassCastException: $Proxy0 cannot be cast to org.omg.CORBA.Object
... 3 more
Note: I have the jboss-client-7.1.0.Final.jar in the class path
any help is appriciated. thanks in advance.