# Howto: RMI-IIOP interoperability between JOnAS and Weblogic

This guide describes the basic interoperability between JOnAS and Weblogic Server using RMI-IIOP (the examples in this document assume that the Sun rmi/iiop of the JDK is used).

The content of this guide is the following:

1. Accessing an EJB deployed on JOnAS from an EJB deployed on Weblogic server using RMI-IIOP.
2. Accessing an EJB deployed on Weblogic Server from an EJB deployed on JOnAS using RMI-IIOP.

## Accessing an EJB deployed on JOnAS from an EJB deployed on Weblogic server using RMI-IIOP

### JOnAS Configuration

No modification to the EJB code is necessary. However, to deploy it for use with the iiop protocol, add the tag protocols and indicate iiop when creating the build.xml.
For example:

       <jonas destdir="${dist.ejbjars.dir}" classpath="${classpath}" jonasroot="${jonas.root}" protocols="iiop"/>

If GenIC is being used for deployment, the `-protocols` option can be used. Note also that an EJB can be deployed for several protocols. For more details about configuring the communication protocol, refer to the JOnAS Configuration Guide.

For the JOnAS server to use RMI-IIOP, the JOnAS configuration requires modification. The iiop protocol must be selected in the
file carol.properties. Refer also to the JOnAS Configuration Guide for details about configuring the communication protocol.
This modification will allow an EJB to be created using the RMI-IIOP protocol.

### EJB proxy on Weblogic

To call an EJB deployed on JOnAS that is accessible through RMI-IIOP, load the class com.sun.jndi.cosnaming.CNCtxFactory as the initial context factory.
In addition, specify the JNDI url of the server name containing the EJB to call: "iiop://<server>:port."
For example:

        try {
          Properties h = new Properties();
          h.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
          h.put(Context.PROVIDER_URL, "iiop://<server>:<port>");
          ctx=new InitialContext(h);
          }
        catch (Exception e) {
          ...
          }

Then, the JOnAS EJB is accessed in the standard way.

## Access an EJB deployed on Weblogic Server by an EJB deployed on JOnAS using RMI-IIOP

### Weblogic Configuration

No modification to the EJB code is necessary. However, to deploy the EJB for use with the iiop protocol, add the element iiop="true" on the wlappc task when creating the build.xml.
For example:

         wlappc debug="${debug}" source="ejb.jar" iiop="true" classpath="${class.path}"

### EJB proxy on JOnAS

To call an EJB deployed on Weblogic Server that is accessible through RMI-IIOP, specify the JNDI url of the server name containing the EJB to call. This url is of type: "iiop://<server>:port."
For example:

          try {
             Properties h = new Properties();
             h.put(Context.PROVIDER_URL, "iiop://<server>:<port>");
             ctx=new InitialContext(h);
          }
          catch (Exception e) {
              ...
          }

Then, the EJB deployed on Weblogic server is accessed in the standard way.