1 Reply Latest reply on Oct 20, 2004 10:29 AM by Matthias Lakämper

    UserTransaction and HttpNamingContextFactory

    Matthias Lakämper Newbie

      Hi,

      i have a servlet on Server 'A' which communicates with Session-Beans on Server 'B'.
      The Servlet starts a Transaction and the Seesion-Bean makes the Database-Actions.
      JBoss-Version: jboss-3.0.4_tomcat-4.1.12.


      ;----------- Servlet-Snipping ---------------------------------------------------
      myTrans = (UserTransaction)ctx.lookup( "UserTransaction" );
      myTrans.begin();


      String updateStmt = "update ..."
      try {
      mySessBean.doUpdStrbDatabase(updateStmt);
      }
      lTransaction.commit();

      } catch (Exception le) {
      lTransaction.rollback();
      le.printStackTrace();
      }

      ;----------- Servlet-Snipping ---------------------------------------------------

      with standard-Connection the System works fine.

      Now i changed the jndi.properties to use HttpNamingContextFactory
      because i want to communicate with the JBoss-Server through
      a Firewall.

      ;------jndi.properties----------------------------------------------------
      ; Standardconnection
      ;--java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      ;--java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      ;--java.naming.provider.url=jnp://localhost:11099

      java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=http://localhost:8080/invoker/JNDIFactory
      ;------jndi.properties----------------------------------------------------

      the web.xml in http-invoker.sar was customized to solve the external url.

      ;------- server .../default/deploy/http-invoker.sar/invoker.war/WEB-INF/web.xml


      <servlet-name>JNDIFactory</servlet-name>
      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.

      <servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
      <init-param>
      <param-name>invokerName</param-name>
      <param-value>jboss:service=Naming</param-value>
      </init-param>
      <init-param>
      <param-name>externalURL</param-name>
      <param-value>http://pcit1052:8080/invoker/JMXInvokerServlet</param-value>
      ...

      </init-param>
      <load-on-startup>2</load-on-startup>

      ;------- server .../default/deploy/http-invoker.sar/invoker.war/WEB-INF/web.xml


      The Beans work fine. But when i try to work with a UserTransaction
      the System runs into an Exception.


      javax.naming.CommunicationException: Failed to connect to server http:1099
      [Root exception is javax.naming.ServiceUnavailableException:
      Failed to connect to server http:1099
      [Root exception is java.net.UnknownHostException: http: http]]


      Is there an additional setup necessary ?

      I would be glad to get help.

      Regards Matthias Lakämper

        • 1. Re: UserTransaction and HttpNamingContextFactory
          Matthias Lakämper Newbie

          Hi,

          i tried another approach.

          The jndi.properties are in Standard-Settings

          ;------jndi.properties----------------------------------------------------
          java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory
          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
          java.naming.provider.url=http://localhost:8080/invoker/JNDIFactory
          ;------jndi.properties----------------------------------------------------

          In jboss-service.xml i added an attribute for RmiPort

          ;----------- excerpt from jboss-service.xml-------------------------------
          < mbean code="org.jboss.naming.NamingService"
          name="jboss:service=Naming">
          < attribute name="Port">11099
          < attribute name="RmiPort">34158
          < /mbean>
          ;----------- excerpt from jboss-service.xml-------------------------------


          In this case also the bean-Functions work fine until i try to start a
          UserTransaction. Here the System tries to communicate on an arbitrary port,
          e.g. 3967.

          Is there a way to define a fix port for Transactions ?

          Regards Matthias Lakämper