How to call a non JBoss Application server (WebLogic) via IIOP using CNCtxFactory from JBoss EAP 5.0.1?

Solution Verified - Updated -

Issue

  • Cannot retrieve appropriate EJBHome for EJB deployed on WebLogic server.
  • Context.INITIAL_CONTEXT_FACTORY=com.sun.jndi.cosnaming.CNCtxFactory
  • Context.PROVIDER_URL=iiop://WEBLOGIC_HOST:7001
  • All other InitialContext properties unmodified
  • Here is how we access the EJB

        Context context = new.InitialContext(environment)
        Object beanref = context.lookup(com.jboss.examples.ejb.Hello);
        Object beantmp=PortableObjectRemote.narrow(beanref, com.jboss.examples.ejb.HelloHome.class)
        my-bean-nameHome beanHome = (HelloHome)beantmp;
        my-bean-name NewBean = beanHome.create();
    
  • The EJB is deployed on WebLogic using:

       <weblogic-enterprise-bean>
           <ejb-name>HelloBean</ejb-name> 
          <stateless-session-descriptor>
          <pool>
            <initial-beans-in-free-pool>5</initial-beans-in-free-pool> 
           </pool>
         <stateless-clustering>
             <stateless-bean-is-clusterable>true</stateless-bean-is-clusterable> 
         </stateless-clustering>
       </stateless-session-descriptor>
        <enable-call-by-reference>true</enable-call-by-reference> 
       <jndi-name>Hello/jndi-name> 
       </weblogic-enterprise-bean>
       <weblogic-compatibility>
         <entity-always-uses-transaction>true</entity-always-uses-transaction> 
       </weblogic-compatibility>
    
  • The IIOP stubs are compiled for the EJB on WebLogic using:

       <target name="appc">
           <java classname="weblogic.appc" fork="yes" failonerror="yes"
                 classpathref="compile.path">
                 <arg value="-iiop" />
                 <arg value="-basicClientJar" />
                 <arg value="${dest.dir}/${ant.project.name}.jar" />
            </java>
       </target>
    
  • We receive a non-null response with an embedded IOR from our "lookup" call and an object of type my-bean-nameHome_stub after our "narrow" call.

  • There is a ClassCastException during the "create" method as follows:

    java.lang.ClassCastException: org.jacorb.orb.Reference cannot be cast to com.abc.my-bean-name 
          at com.com.abc.my-bean-nameHome_Stub.create(Unknown Source)
    

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 5.0.1
  • Sun Java Development Kit (JDK)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content