Uploaded image for project: 'ServiceMix'
  1. ServiceMix
  2. SM-1756

add CXFManagedServlet to apache-servicemix-web to enable servicemix-cxf-bc endpoint deploy into servlet container without starting jetty

    Details

      Description

      we need add CXFManagedServlet in the web.xml to replace the http transport with cxf servlet transport.

      1. apache-servicemix-web.zip
        25 kB
        Mario Matias Urbieta
      2. apache-servicemix-web-patch.tgz
        10 kB
        Mario Matias Urbieta
      3. SM-1756.patch
        1 kB
        Benoît Clouet

        Activity

        Hide
        ffang Freeman Fang added a comment -
        Show
        ffang Freeman Fang added a comment - commit fix http://svn.apache.org/viewvc?rev=731906&view=rev for 3.2 branch
        Hide
        ffang Freeman Fang added a comment -
        Show
        ffang Freeman Fang added a comment - commit fix http://svn.apache.org/viewvc?rev=732203&view=rev for servicemix-cxf-bc component project http://svn.apache.org/viewvc?rev=732204&view=rev for trunk
        Hide
        benoit.clouet Benoît Clouet added a comment -

        The problem comes from that after an install of the cxf bc component and
        SA, then on restart of the tomcat, the context listener(which load servicemix
        container and then start the intalled cxf bc and sa) always run before the
        CXFServlet(which replace the servlet transport), so that the cxf bc has no
        chance to use the bus with replaced servlet transport.

        Show
        benoit.clouet Benoît Clouet added a comment - The problem comes from that after an install of the cxf bc component and SA, then on restart of the tomcat, the context listener(which load servicemix container and then start the intalled cxf bc and sa) always run before the CXFServlet(which replace the servlet transport), so that the cxf bc has no chance to use the bus with replaced servlet transport.
        Hide
        benoit.clouet Benoît Clouet added a comment - - edited

        the trick is to get the context loaded after the CXFManagedServlet. So use the alternative to the ContextLoaderListener ie. the ContextLoaderServlet.

        This involves a slight modification of the web.xml. You have to comment out
        :
        <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        and to replace this by the servlet context loader equivalent :
        <servlet>
        <servlet-name>context</servlet-name>

        <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
        <load-on-startup>3</load-on-startup>
        </servlet>

        This patch should be applied to the apache-servicemix-web instead of the servicemix-web-console because of the overlay mechanism which overwrites the web.xml from the servicemix-web-console by the one from apache-servicemix-web.

        Show
        benoit.clouet Benoît Clouet added a comment - - edited the trick is to get the context loaded after the CXFManagedServlet. So use the alternative to the ContextLoaderListener ie. the ContextLoaderServlet. This involves a slight modification of the web.xml. You have to comment out : <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> and to replace this by the servlet context loader equivalent : <servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>3</load-on-startup> </servlet> This patch should be applied to the apache-servicemix-web instead of the servicemix-web-console because of the overlay mechanism which overwrites the web.xml from the servicemix-web-console by the one from apache-servicemix-web.
        Hide
        ffang Freeman Fang added a comment -

        Hi Benoît,

        I played with your testcase appended with the mailling list, it's ok for me after restarting tomcat, I can see the wsdl from http://localhost:8080/apache-servicemix-web-3.3.1/services/testCxf?wsdl.
        You need ensure your SA status is start from the web console.
        What the exact problem you saw?
        I also go through your patch and google a bit, seems use ContextLoaderServlet instead of ContextLoaderListener is not a good idea, as ContextLoaderServlet is deprecated and can't work with modern servlet container (servlet api 2.4), the ContextLoaderListener is recommand to use
        Freeman

        Show
        ffang Freeman Fang added a comment - Hi Benoît, I played with your testcase appended with the mailling list, it's ok for me after restarting tomcat, I can see the wsdl from http://localhost:8080/apache-servicemix-web-3.3.1/services/testCxf?wsdl . You need ensure your SA status is start from the web console. What the exact problem you saw? I also go through your patch and google a bit, seems use ContextLoaderServlet instead of ContextLoaderListener is not a good idea, as ContextLoaderServlet is deprecated and can't work with modern servlet container (servlet api 2.4), the ContextLoaderListener is recommand to use Freeman
        Hide
        ffang Freeman Fang added a comment -

        Hi Benoît,

        I'm going to close this issue since I play with your testcase and it work for me.
        Feel free to reopen if you find anything more.
        Thanks

        Freeman

        Show
        ffang Freeman Fang added a comment - Hi Benoît, I'm going to close this issue since I play with your testcase and it work for me. Feel free to reopen if you find anything more. Thanks Freeman
        Hide
        matiasurbieta Mario Matias Urbieta added a comment -

        Hi, Jetty is started when service units are packaged as cxf-bc SU but lightweight one. When it is declared as a lightweight component, it works as expected using the registered CXFManagedServlet instead of starting Jetty.
        I have attached the apache-servicemix-web (distribution) project with three tests that describe usage scenarios:
        1) lightweight cxf consumer endpoint that works ok (PASSES)
        2) a cxf consumer endpoint packaged as a SU (wsdl first derived example[1]) that do not work as expected starting a jetty server. (FAILS)
        3) variation of configuration where a spring ServletContextLoader is used instead of the listener version. The bug is still present. (FAILS)

        I think, the cxf-bc component should follow managed approach used in the http component.
        NOTES

        • The environment corresponds to SMX 3.3.1 and 2010.01 components
        • [1] wsdl first example was modified adding the locationURI parameter to the cxf consumer endpoint.
        Show
        matiasurbieta Mario Matias Urbieta added a comment - Hi, Jetty is started when service units are packaged as cxf-bc SU but lightweight one. When it is declared as a lightweight component, it works as expected using the registered CXFManagedServlet instead of starting Jetty. I have attached the apache-servicemix-web (distribution) project with three tests that describe usage scenarios: 1) lightweight cxf consumer endpoint that works ok (PASSES) 2) a cxf consumer endpoint packaged as a SU (wsdl first derived example [1] ) that do not work as expected starting a jetty server. (FAILS) 3) variation of configuration where a spring ServletContextLoader is used instead of the listener version. The bug is still present. (FAILS) I think, the cxf-bc component should follow managed approach used in the http component. NOTES The environment corresponds to SMX 3.3.1 and 2010.01 components [1] wsdl first example was modified adding the locationURI parameter to the cxf consumer endpoint.
        Hide
        matiasurbieta Mario Matias Urbieta added a comment -

        Hi folks, i was working on this issue and i finally localized the problem. CXFManagedServlet wasn't working in the right way when application server (in my case a Jboss) had a non-empty context and a non-empty servet mapping.
        I have attached a new version of the CXFServlet called ServicemixCXFManagedServlet that solves the issue ; in the file apache-servicemix-web-patch. This new version requires an initial parameter that specifies the context name and the servlet name present in any service request. For instance, the parameter value could be "servicemix-web/services" where servicemix-web is the web app's name and services is the servlet mapping. I couldnt find the way for detecting this information automatically.

        • The environment corresponds to SMX 3.3.1 and 2009.01 components (CHANGED from previous comment)
        • [1] wsdl first example was modified adding the locationURI parameter to the cxf consumer endpoint.

        Regards

        Show
        matiasurbieta Mario Matias Urbieta added a comment - Hi folks, i was working on this issue and i finally localized the problem. CXFManagedServlet wasn't working in the right way when application server (in my case a Jboss) had a non-empty context and a non-empty servet mapping. I have attached a new version of the CXFServlet called ServicemixCXFManagedServlet that solves the issue ; in the file apache-servicemix-web-patch. This new version requires an initial parameter that specifies the context name and the servlet name present in any service request. For instance, the parameter value could be "servicemix-web/services" where servicemix-web is the web app's name and services is the servlet mapping. I couldnt find the way for detecting this information automatically. The environment corresponds to SMX 3.3.1 and 2009.01 components (CHANGED from previous comment) [1] wsdl first example was modified adding the locationURI parameter to the cxf consumer endpoint. Regards
        Hide
        ffang Freeman Fang added a comment -

        Hi,

        Thanks so much.

        I'll take a look at this patch when I'm back from my holiday.

        Freeman

        Show
        ffang Freeman Fang added a comment - Hi, Thanks so much. I'll take a look at this patch when I'm back from my holiday. Freeman
        Hide
        ffang Freeman Fang added a comment -

        I believe the fix for SM-2115[1] and SMXCOMP-897[2] also fix this issue
        [1]https://issues.apache.org/jira/browse/SM-2115
        [2]https://issues.apache.org/jira/browse/SMXCOMP-897

        Freeman

        Show
        ffang Freeman Fang added a comment - I believe the fix for SM-2115 [1] and SMXCOMP-897 [2] also fix this issue [1] https://issues.apache.org/jira/browse/SM-2115 [2] https://issues.apache.org/jira/browse/SMXCOMP-897 Freeman

          People

          • Assignee:
            ffang Freeman Fang
            Reporter:
            ffang Freeman Fang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development