Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-6633

Unable to bind servlet to specific HttpConnectors

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.2.8
    • Fix Version/s: None
    • Component/s: karaf

      Description

      On a fresh Karaf run:

      feature:install war

      Logout, then configure a Jetty connector jettyConn1 in etc/jetty.xml:
       
      <Call name="addConnector">
      <Arg>
      <New class="org.eclipse.jetty.server.ServerConnector">
      <Arg name="server">
      <Ref refid="Server" />
      </Arg>
      <Arg name="factories">
      <Array type="org.eclipse.jetty.server.ConnectionFactory">
      <Item>
      <New class="org.eclipse.jetty.server.HttpConnectionFactory">
      <Arg name="config">
      <Ref refid="httpConfig" />
      </Arg>
      </New>
      </Item>
      </Array>
      </Arg>
      <Set name="host">
      <Property name="jetty.host" default="localhost" />
      </Set>
      <Set name="port">
      <Property name="jetty.port" default="8282" />
      </Set>
      <Set name="idleTimeout">
      <Property name="http.timeout" default="30000" />
      </Set>
      <Set name="name">jettyConn1</Set>
      </New>
      </Arg>
      </Call>
      Now run Karaf again and run the command:

      bundle:install --start mvn:org.ops4j.pax.web.samples/whiteboard-extended/7.2.14

      This will install sample bundle from Pax-Web project:

      https://github.com/ops4j/org.ops4j.pax.web/tree/web-7.2.14/samples/whiteboard-extended 
       
      Which registers a servlet to bind to the jettyConn1 configured in jetty.xml.
      I can verify the servlets are deployed: 
      karaf@root()> http:list         
      ID  │ Servlet                   │ Servlet-Name                 │ State       │ Alias                     │ Url───┼──────────────────────┼──────────────────────────────┼─────────────┼───────────────────────────┼─309 │ WhiteboardServlet         │ ServletModel-26              │ Deployed    │ /whiteboard               │ [/whiteboard/*]309 │ WhiteboardServlet         │ ServletModel-28              │ Deployed    │ /whiteboard2              │ [/whiteboard2/*]309 │ WhiteboardServlet         │ ServletModel-30              │ Deployed    │ /whiteboard3              │ [/whiteboard3/*]309 │ WhiteboardServlet         │ ServletModel-32              │ Deployed    │ /whiteboard4              │ [/whiteboard4/*]
       
      But Jetty is responding 404 to a GET request on  http://localhost:8282/whiteboard, same for all other ports.
       
      I see this warning in the log file:
       
      2020-03-10T10:12:07,497 | WARN  | features-3-thread-1 | ContextHandler                   | 245 - org.eclipse.jetty.util - 9.4.22.v20191022 | ContextHandler [+localhost+, @jettyConn1] has a connector only entry e.g. "@connector" and one or more host only entries. 
      The host entries will be ignored to match legacy behavior.  To clear this warning remove the host entries or update to use at least one host@connector syntax entry that will match a host for an specific connector
       
      The expected result is that a GET request to  http://localhost:8282/whiteboard  responds 200, and 404 to http://localhost:8181/whiteboard because the servlet is registered to bind to the jettyConn1:
       

      contextMappingParams.put(ExtenderConstants.PROPERTY_HTTP_CONNECTORS,
      "jettyConn1");

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                alex.soto Alex Soto
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: