1 Reply Latest reply: May 25, 2012 7:31 AM by Wolf-Dieter Fink RSS

accessing EJB deployed on JBoss5.1 at a remote server using AS7 client

Uday Shankar Newbie


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();


          Object home_obj = c.lookup(lookupJndi);


          DBAccessorHome home = (DBAccessorHome) PortableRemoteObject.narrow(home_obj, DBAccessorHome.class);

          DBAccessor dba_bean = home.create();


        } catch (Exception e) {







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


    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.

  • 1. Re: accessing EJB deployed on JBoss5.1 at a remote server using AS7 client
    Wolf-Dieter Fink Master

    Thats very dubious for me.


    The subject look like you try to access an EJB deployed in a JBoss5.1 from an AS7 server (sounds like inside EJB).

    Your code is a main method, which is a standalone application.


    So if you have a standalone application you should use the standard procedure to access EJBs in a JBoss 5.1 (your example is a mix of AS5 and AS7 client).

    The client libraries of AS5 and AS7 are different and you can not access in that way.