5 Replies Latest reply on Oct 5, 2009 5:05 PM by Bob Damato

    More ServiceBindingSet questions

    Bob Damato Newbie

      I've got a jboss server that's running behind an apache web server, so I have the HTTP and HTTPS connectors disabled in jbossweb.sar/server.xml. Only AJP is running:

      <Connector protocol="AJP/1.3" port="8709" address="${jboss.bind.address}"
       redirectPort="8443" />
      


      I'm using the port offset feature in bindingservice.beans/META-INF/bindings-jboss-beans.xml to handle the ports. Everything is working properly, except that when I hit a secured web page, jboss is redirecting me to port 9143 instead of 8443 (port offset is 700). This is my config:

       <!-- The CouponEngineBindings bindings are obtained by taking the base bindings and adding 700 to each port value -->
       <bean name="CouponEngineBindings" class="org.jboss.services.binding.impl.ServiceBindingSet">
       <constructor>
       <!-- The name of the set -->
       <parameter>CouponEngineBindings</parameter>
       <!-- Default host name -->
       <parameter>${jboss.bind.address}</parameter>
       <!-- The port offset -->
       <parameter>700</parameter>
       <!-- Set of bindings that are specific to this ServiceBindingSet -->
       <parameter>
       <set elementClass="org.jboss.services.binding.ServiceBindingMetadata">
       <bean class="org.jboss.services.binding.ServiceBindingMetadata">
       <property name="serviceName">jboss:service=Naming</property>
       <property name="bindingName">Port</property>
       <property name="port">8299</property>
       <property name="description">The listening socket for the Naming service</property>
       <property name="fixedPort">true</property>
       </bean>
       <bean class="org.jboss.services.binding.ServiceBindingMetadata">
       <property name="serviceName">jboss.web:service=WebServer</property>
       <property name="bindingName">HttpsConnector</property>
       <property name="port">8443</property>
       <property name="description">JBoss Web HTTPS connector socket</property>
       <property name="fixedPort">true</property>
       </bean>
       </set>
       </parameter>
       </constructor>
       </bean>
      


      Any ideas on how I make tomcat redirect HTTPS requests to the correct port?

        • 1. Re: More ServiceBindingSet questions
          Bob Damato Newbie

          Anyone have any ideas on this one?

          • 2. Re: More ServiceBindingSet questions
            jaikiran pai Master

            Can you please post the console logs? Especially the lines which show the ports being used:

            13:09:54,208 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8080
            13:09:54,208 INFO [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-0.0.0.0-8009
            


            • 3. Re: More ServiceBindingSet questions
              Bob Damato Newbie

               

              2009-10-05 07:44:37,270 WARN [org.jboss.annotation.factory.AnnotationCreator] No ClassLoader provided, using TCCL: org.jboss.managed.api.annotation.ManagementComponent
              2009-10-05 07:44:37,886 WARN [org.jboss.annotation.factory.AnnotationCreator] No ClassLoader provided, using TCCL: org.jboss.managed.api.annotation.ManagementComponent
              2009-10-05 07:44:42,829 INFO [org.apache.catalina.core.AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/local/lib
              2009-10-05 07:44:43,210 INFO [org.apache.coyote.ajp.AjpProtocol] Initializing Coyote AJP/1.3 on ajp-0.0.0.0-8709
              2009-10-05 07:44:43,334 INFO [org.apache.catalina.core.StandardService] Starting service jboss.web
              2009-10-05 07:44:43,347 INFO [org.apache.catalina.core.StandardEngine] Starting Servlet Engine: JBoss Web/2.1.3.GA
              2009-10-05 07:44:43,693 INFO [org.apache.catalina.startup.Catalina] Server startup in 481 ms
              2009-10-05 07:44:43,812 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/jbossws
              ....
              
              2009-10-05 07:46:02,831 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/vpservice
              2009-10-05 07:46:03,853 INFO [org.apache.coyote.ajp.AjpProtocol] Starting Coyote AJP/1.3 on ajp-0.0.0.0-8709
              2009-10-05 07:46:04,034 INFO [org.jboss.bootstrap.microcontainer.ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 5m:1s:569ms
              


              • 4. Re: More ServiceBindingSet questions
                jaikiran pai Master

                Looking at the bindings-jboss-beans.xml, the "redirectPort" of the connector is calculated from the XSLT transform configuration:

                <bean class="org.jboss.services.binding.ServiceBindingMetadata">
                 <property name="serviceName">jboss.web:service=WebServer</property>
                 <property name="port">8080</property>
                 <property name="description">JBoss Web HTTP connector socket; also drives the values for the HTTPS and AJP sockets</property>
                
                 <!--
                 Inject a XSLT transform configuration (see below) that describes
                 how to transform server.xml
                 If the binding value request doesn't require an XSL Transform, this config
                 will be ignored.
                 -->
                 <property name="serviceBindingValueSourceConfig"><inject bean="JBossWebConnectorXSLTConfig"/></property>
                 </bean>
                
                ...
                
                <!-- XSL Transform to apply to server.xml -->
                 <bean name="JBossWebConnectorXSLTConfig"
                 class="org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig">
                
                 <constructor>
                 <parameter><![CDATA[
                 <xsl:stylesheet
                 xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
                
                 <xsl:output method="xml" />
                 <xsl:param name="port"/>
                
                 <xsl:variable name="portAJP" select="$port - 71"/>
                 <xsl:variable name="portHttps" select="$port + 363"/>
                
                 <xsl:template match="/">
                 <xsl:apply-templates/>
                 </xsl:template>
                
                 <xsl:template match = "Connector">
                 <Connector>
                 <xsl:for-each select="@*">
                 <xsl:choose>
                 <xsl:when test="(name() = 'port' and . = '8080')">
                 <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
                 </xsl:when>
                 <xsl:when test="(name() = 'port' and . = '8009')">
                 <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
                 </xsl:when>
                 <xsl:when test="(name() = 'redirectPort')">
                 <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
                 </xsl:when>
                ...
                


                As can be seen, the "redirectPort" is set to $portHttps, which itself is calculated as $port + 363. The $port is your HTTP port which in your case, because of the offset 700, is 8780. So redirectPort = 8780 + 363 = 9143 and that's what you are seeing.

                You mentioned that you have disabled HTTP connector:

                so I have the HTTP and HTTPS connectors disabled in jbossweb.sar/server.xml


                So to get around this issue, try setting a fixed port 8080 in the bindings-jboss-beans.xml for the HTTP port, so that the redirectPort gets calculated as 8080 + 363 = 8443. Here's an example (haven't checked for syntax or other semantics):

                <!-- The CouponEngineBindings bindings are obtained by taking the base bindings and adding 700 to eac
                h port value -->
                 <bean name="CouponEngineBindings" class="org.jboss.services.binding.impl.ServiceBindingSet">
                 <constructor>
                 <!-- The name of the set -->
                 <parameter>CouponEngineBindings</parameter>
                 <!-- Default host name -->
                 <parameter>${jboss.bind.address}</parameter>
                 <!-- The port offset -->
                 <parameter>700</parameter>
                 <!-- Set of bindings that are specific to this ServiceBindingSet -->
                 <parameter>
                 <set elementClass="org.jboss.services.binding.ServiceBindingMetadata">
                 <bean class="org.jboss.services.binding.ServiceBindingMetadata">
                 <property name="serviceName">jboss:service=Naming</property>
                 <property name="bindingName">Port</property>
                 <property name="port">8299</property>
                 <property name="description">The listening socket for the Naming service</property>
                 <property name="fixedPort">true</property>
                 </bean>
                 <bean class="org.jboss.services.binding.ServiceBindingMetadata">
                 <property name="serviceName">jboss.web:service=WebServer</property>
                 <property name="bindingName">HttpsConnector</property>
                 <property name="port">8443</property>
                 <property name="description">JBoss Web HTTPS connector socket</property>
                 <property name="fixedPort">true</property>
                 </bean>
                 <!-- Fixed HTTP port -->
                 <bean class="org.jboss.services.binding.ServiceBindingMetadata">
                 <property name="serviceName">jboss.web:service=WebServer</property>
                 <property name="port">8080</property>
                 <property name="description">JBoss Web HTTP connector socket; also drives the values for the HTTPS and AJP sockets</property>
                 <property name="fixedPort">true</property>
                 </bean>
                 </set>
                 </parameter>
                 </constructor>
                 </bean>
                
                
                
                
                


                • 5. Re: More ServiceBindingSet questions
                  Bob Damato Newbie

                  That did it, thanks jaikiran!