Version 2

    Setup

     

    Step 1. Grab a copy of JBoss AS 4.2.x+ or JBoss EAP 4.2.x/4.3.x+ and create a new server configuration (based on /default).

     

    Step 2. Go to deploy/http-invoker.sar/invoker.war/WEB-INF/classes/ and ZIP up the classes into a JAR called jboss-http-naming.jar. Put this jar in the server's lib directory so that both the legacy and unified http invoker share these classes.

     

    Server Side

     

    Step 3. Within the deploy/ directory of the newly created configuration, create the following folder hierarchy:

     

    deploy/
      unified-http-invoker.sar/
        unified-invoker.war/
          WEB-INF/
        META-INF/

     

    Step 4. Within WEB-INF, create a file called web.xml that will contain the JNDI factory servlet definition. Note how underneath the JNDI factory there's a NamingFactoryServlet that will return a JNDI proxy that will be defined in the next step:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC
       "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd">
    
    <web-app>
        <servlet>
            <servlet-name>JNDIFactory</servlet-name>
            <description>A servlet that exposes the JBoss JNDI Naming service stub
            through http. The return content is a serialized
            MarshalledValue containg the org.jnp.interfaces.Naming stub. This
            configuration handles requests for the standard JNDI naming service.
            </description>
            <servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
            <init-param>
                <param-name>namingProxyMBean</param-name>
                <param-value>jboss:service=proxyfactory,type=unified,transport=servlet,target=naming</param-value>
            </init-param>
          <init-param>
             <param-name>proxyAttribute</param-name>
             <param-value>Proxy</param-value>
          </init-param>
          <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>JNDIFactory</servlet-name>
            <url-pattern>/JNDIFactory/*</url-pattern>
        </servlet-mapping>
    </web-app>

     

    Step 5. Within META-INF, create a file called jboss-service.xml that will contain:

    1. JBoss Remoting MBean with Servlet as defined transport.

    2. Unified Invoker MBean that will delegate to JBoss Remoting MBean.

    3. Proxy to the JNDI Naming Service that uses the Unified Invoker underneath.

     

    <?xml version="1.0" encoding="UTF-8"?>
    <server>
       <!-- Expose the Naming service interface via the UnifiedInvoker -->
       <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
          name="jboss:service=proxyfactory,type=unified,transport=servlet,target=naming">
          <attribute name="InvokerName">jboss:service=invoker,type=unified,transport=servlet</attribute>
          <attribute name="TargetName">jboss:service=Naming</attribute>
          <attribute name="JndiName"></attribute>
          <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
          <attribute name="ClientInterceptors">
              <interceptors>
                 <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
                 <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
                 <interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor>
                 <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
              </interceptors>
          </attribute>
          <depends>jboss:service=invoker,type=unified,transport=servlet</depends>
       </mbean>
    
       <!-- Unified invoker (based on remoting) -->
       <mbean code="org.jboss.invocation.unified.server.UnifiedInvoker"
          name="jboss:service=invoker,type=unified,transport=servlet">
          <depends>jboss:service=TransactionManager</depends>
          <depends>jboss.remoting:service=connector,transport=servlet</depends>
       </mbean>
    
       <mbean code="org.jboss.remoting.transport.Connector"
          name="jboss.remoting:service=connector,transport=servlet"
          display-name="Servlet transport Connector">
          <attribute name="Configuration">
             <config>
                <invoker transport="servlet">
                   <attribute name="dataType" isParam="true">invocation</attribute>
                   <attribute name="marshaller" isParam="true">org.jboss.invocation.unified.marshall.InvocationMarshaller</attribute>
                   <attribute name="unmarshaller" isParam="true">org.jboss.invocation.unified.marshall.InvocationUnMarshaller</attribute>
                   <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
                   <attribute name="serverBindPort">8080</attribute>
                   <attribute name="path">unified-invoker/ServerInvokerServlet</attribute>
                </invoker>
                <handlers>
                   <handler subsystem="invoker">jboss:service=invoker,type=unified,transport=servlet</handler>
                </handlers>
             </config>
          </attribute>      
       </mbean>
    </server>

     

    Deployment Archive

     

    No changes required here.

     

    Client Side

     

    Step 6. Retrieve the JNDI proxy via the HTTP, do the lookup and call your EJB.

     

    Properties p = new Properties();
    p.put("java.naming.factory.initial", "org.jboss.naming.HttpNamingContextFactory");
    p.put("java.naming.provider.url", "http://localhost:8080/unified-invoker/JNDIFactory");
    p.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");      
    ctx = new InitialContext(p);
    
    TimeTellerHome home = (TimeTellerHome)ctx.lookup("ejb/MyEjb");
    TimeTeller teller = home.create();
    System.out.println(teller.whatsTheTime());

     

    Referenced by: