7 Replies Latest reply on Sep 27, 2012 2:22 AM by Augus T

    How can I redirect HTTP to HTTPS in JBoss 5.0.1?

    Frank McAleer Newbie

      I am new to the JBoss community and would appreciate anyone's help who has been able to set up a redirect from HTTP to HTTPS in JBoss 5.0.1.

      =================================================================
      I have a customer using Jboss 5.0.1 GA and trying to redirect HTTP to HTTPS on port 443.


      I have been able to do this in JBoss 4.0.5 by:

       

      1) Uncommenting the commented out HTTP section of the JBoss_Home\server\my_domain\deploy\jbossweb-tomcat55.sar\server.xml, after setting the HTTPS port for 443, and

       

      2)Updating the ..\deploy\jbossweb-tomcat55.sar\conf\web.xml file with the following addition:


      <security-constraint>
      <web-resource-collection>
      <web-resource-name>Protected Context</web-resource-name>
      <url-pattern>/*</url-pattern>
      </web-resource-collection>
      <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee>
      </user-data-constraint>
      </security-constraint>

       

      ----------------------------------

       

      This doesn't seem to work for me in JBoss 5.0.1, in that it appears that I am trying to redirect to the default port of 8443, not the 443 entered into the server.xml referenced above.


      If anyone has done this or has an idea of where I am going wrong, I would appreciate your help.

       

      Thanks,
      Frank M.

        • 1. Re: How can I redirect HTTP to HTTPS in JBoss 5.0.1?
          Vinod Pandey Newbie

          Hi all,

           

          I have same requirements for JBoss 5.1.0. As explained point 2 by Frank.....  ..\deploy\jbossweb-tomcat55.sar\conf\web.xml does not exists for JBoss 5.1.0 hence I can not update file. So how should I redirect the http to https?

           

          Thanks in advance

          Vinod Pandey

          NHST, India

          • 2. Re: How can I redirect HTTP to HTTPS in JBoss 5.0.1?
            Peter Johnson Master

            Did you do a search for the global web.xml in the JBoss AS directories? If so, you would have found it at server/xxx/deployers/jbossweb.deployer/web.xml.

            • 3. Re: How can I redirect HTTP to HTTPS in JBoss 5.0.1?
              Vinod Pandey Newbie

              Yeah Peter is right. I found the file.....But now after updating this file I got following exception

               

              ERROR [CommonClient] Exception caught while (preparing for) performing the invocation:
              java.io.IOException: Could not transmit message
                      at org.jboss.ws.core.client.HTTPRemotingConnection.invoke(HTTPRemotingConnection.java:265)
                      at org.jboss.ws.core.client.SOAPProtocolConnectionHTTP.invoke(SOAPProtocolConnectionHTTP.java:71)
                      at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:340)
                      at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:290)
                      at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:170)
                      at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:150)
                      at $Proxy298.add(Unknown Source)
                      at demo.DemoServlet.add(DemoServlet.java:88)
                      at demo.DemoServlet.processRequest(DemoServlet.java:42)
                      at demo.DemoServlet.doGet(DemoServlet.java:61)
                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
                      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                      at java.lang.Thread.run(Thread.java:619)
              Caused by: org.jboss.remoting.CannotConnectException: Can not connect http client invoker after 1 attempt(s)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.makeInvocation(HTTPClientInvoker.java:249)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:161)
                      at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:165)
                      at org.jboss.remoting.Client.invoke(Client.java:1724)
                      at org.jboss.remoting.Client.invoke(Client.java:629)
                      at org.jboss.ws.core.client.HTTPRemotingConnection.invoke(HTTPRemotingConnection.java:243)
                      ... 32 more
              Caused by: org.jboss.ws.WSException: Invalid HTTP server response [302] - Moved Temporarily
                      at org.jboss.ws.core.soap.SOAPMessageUnMarshallerHTTP.read(SOAPMessageUnMarshallerHTTP.java:75)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:570)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:369)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.makeInvocation(HTTPClientInvoker.java:231)
                      ... 37 more
              16:56:31,902 ERROR [[DemoServlet]] Servlet.service() for servlet DemoServlet threw exception
              javax.xml.ws.WebServiceException: java.io.IOException: Could not transmit message
                      at org.jboss.ws.core.jaxws.client.ClientImpl.handleRemoteException(ClientImpl.java:396)
                      at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:302)
                      at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:170)
                      at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:150)
                      at $Proxy298.add(Unknown Source)
                      at demo.DemoServlet.add(DemoServlet.java:88)
                      at demo.DemoServlet.processRequest(DemoServlet.java:42)
                      at demo.DemoServlet.doGet(DemoServlet.java:61)
                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
                      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                      at java.lang.Thread.run(Thread.java:619)
              Caused by: java.io.IOException: Could not transmit message
                      at org.jboss.ws.core.client.HTTPRemotingConnection.invoke(HTTPRemotingConnection.java:265)
                      at org.jboss.ws.core.client.SOAPProtocolConnectionHTTP.invoke(SOAPProtocolConnectionHTTP.java:71)
                      at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:340)
                      at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:290)
                      ... 29 more
              Caused by: org.jboss.remoting.CannotConnectException: Can not connect http client invoker after 1 attempt(s)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.makeInvocation(HTTPClientInvoker.java:249)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:161)
                      at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:165)
                      at org.jboss.remoting.Client.invoke(Client.java:1724)
                      at org.jboss.remoting.Client.invoke(Client.java:629)
                      at org.jboss.ws.core.client.HTTPRemotingConnection.invoke(HTTPRemotingConnection.java:243)
                      ... 32 more
              Caused by: org.jboss.ws.WSException: Invalid HTTP server response [302] - Moved Temporarily
                      at org.jboss.ws.core.soap.SOAPMessageUnMarshallerHTTP.read(SOAPMessageUnMarshallerHTTP.java:75)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:570)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:369)
                      at org.jboss.remoting.transport.http.HTTPClientInvoker.makeInvocation(HTTPClientInvoker.java:231)
                      ... 37 more

               

              Peter can you help me to get out of this?

              Thanks in advance

               

              Vinod Pandey

              NHST India

              • 4. Re: How can I redirect HTTP to HTTPS in JBoss 5.0.1?
                Peter Johnson Master

                I have never seen this error. Maybe someone else who has can help.

                 

                I found this discussion, but there was no conclusion: http://community.jboss.org/message/558482

                • 5. Re: How can I redirect HTTP to HTTPS in JBoss 5.0.1?
                  Vinod Pandey Newbie

                  oh.......But can you suggest me a step by step way to redirect from http to https?

                   

                  Thanks

                  Vinod Pandey

                  • 6. Re: How can I redirect HTTP to HTTPS in JBoss 5.0.1?
                    Vinod Pandey Newbie

                    Hi Peter....

                     

                    I found a link https://jira.jboss.org/browse/JBWS-2216 that may described my problem. But as a newbie I am not able to understand wheater is it right or not.I just tried to download jbossws-native-3.0.3, but I did not find this version. Could you please tell what to do now. I am really grateful for your quick response.

                     

                    Thanks

                    Vinod Pandey

                    NHST, India

                    • 7. Re: How can I redirect HTTP to HTTPS in JBoss 5.0.1?
                      Augus T Newbie

                      Hi Frank,

                       

                      I also stumbled on this problem. Thanks for the hint for JBoss 4, i managed to solve this.

                      In JBoss 5.1.0, the web.xml location is located at deployers\jbossweb.deployer\web.xml.

                       

                      My next problem is the redirection will always go to port 8443, although i already configured in deploy\jbossweb.sar\server.xml, i'm using 443.

                       

                      Edit:

                      I found how to do it (not elegantly, but works):

                      1. edit conf\bindingservice.beans\META-INF\bindings-jboss-beans.xml

                      2. Find <xsl:variable name="portHttps" select="$port + 363"/>

                      3. Edit "$port + 363" to "443"

                       

                      The reason is because the live URL used was 8080, if it's 80, there will be no need to edit this file.