1 2 3 Previous Next 32 Replies Latest reply on Aug 23, 2011 3:34 AM by llwang0455

    Problem attaching CXF interceptors to the Bus via configuration

    niyyel

      Dear all,

       

      I'm trying to develop an interceptor that works at bus level. So, all endpoints will be able to use such interceptor without adding any configuration to them.

       

      I'm developing a bundle that I later add to the FUSE /deploy folder. The configuration I use is:

       

       

       

       

      And my InterceptorCXF class is:

       

      public class InterceptorCXF extends AbstractSoapInterceptor {

       

          public InterceptorCXF() {

              super(Phase.READ);

              System.out.println("enters");

          }

          public void handleMessage(SoapMessage message) throws Fault {

               System.out.println("works");

       

      }

       

      So, the bundle is started properly in my console, and I am able to see the message "enters" in the console.

       

      In order to test that I'm able to intercept messages, I deploy the cxf-wsdl-first-osgi-package example of FUSE. But I'm not able to catch the message in any way. Why not? I should see on the screen the message "works" to verity that I intercepted the message. However I tried eveyrthing and I can not.

       

      Please could you help me?

        • 1. Re: Problem attaching CXF interceptors to the Bus via configuration
          ffang

          Hi,

           

          You need configure a cxf bus for servicemix-cxf-bc component level, so that all endpoints with servicemix-cxf-bc can use this bus, your current way can't do it.

           

          You should

          1. add a org.apache.servicemix.components.cxfbc.cfg in $FUSE_ESB/etc folder,

          add an entry

          busCfg="the relative path for the cxf bus configure file in your bundle"

           

          2. make your bundle containing the cxf bus configure file and interceptor class as a fragment bundle and attach it to servicemix-cxf-bc bundle, so that the bus configure file is available for the servicemix-cxf-bc bundle.

           

          Freeman

          • 2. Re: Problem attaching CXF interceptors to the Bus via configuration
            niyyel

            Thank you very much for your help Freeman,

             

            I noticed that in my servicemix log file I have this WARN message. Is it related with what you have suggested me?

             

            I'm sorry to say that I'm not very experienced on FUSE. Could you maybe provide me some links of how to proceed about the instructions you gave me before?

             

            Many thanks

            Jordi

            • 3. Re: Problem attaching CXF interceptors to the Bus via configuration
              ffang

              Hi,

               

              I guess what confused you in my previous suggestion is the fragment bundle part, right?

               

              If so, fragment  bundle is a general OSGi concept but not FUSE ESB specific, you can google to get more details about how fragment bundle works.

               

              About the WARN message, could you tell me how you encounter it?

              Generally this is caused by your bundle missing Import-Package META-INF.cxf, you can add it into your pom.xml maven-bundle-plugin configuration to see if it helps.

               

              Freeman

              • 4. Re: Problem attaching CXF interceptors to the Bus via configuration
                niyyel

                Hi Freeman,

                 

                Thanks one more time. However , I still feel a bit lost in this huge world

                 

                I'll try to explain myself better and how I have proceed step by step.

                 

                First, with Eclipse IDE I create a new Maven Project using spring-osig-bundle archetype.

                Using this template, I create my interceptros class (InterceptorCXF.java).

                After that, I configure the <cxf:bus> in the bundle-context.xml.

                 

                Then, I do mvn install to generate my .jar file. I copy this .jar in my FUSE deploy folder and then I start servicemix. The bundle starts properly.

                 

                After that, I thought that a good way to test whether the interceptor works or not is deploying also some of the examples available in FUSE. However, here is the problem , i cannot intercept anything.

                 

                About your suggestions. I am not sure how I can set up my Eclipse environment to work as you suggested. Also , I do not have any filed named  cxf.xml.

                 

                Which kind of format should have the file org.apache.servicemix.components.cxfbc.cfg ?

                 

                I know..many questions...

                 

                I attach you my project, probably will help to understand what I am saying.

                 

                Jordi

                thanks again,

                • 5. Re: Problem attaching CXF interceptors to the Bus via configuration
                  ffang

                  Hi,

                   

                  Your interceptor doesn't work is that from your bundle it just create a single cxf bus which is not picked up by servicemix-cxf-bc component, so that it can't be aware of any cxfbc endpoint consequently.

                   

                  What I suggest you is that you should configure a component level bus which could be shared by all cxfbc endpoints.

                   

                  The org.apache.servicemix.components.cxfbc.cfg is just a text file under $FUSE_ESB/etc folder, you need add this file yourself and specify the busCfg entry there. And such cfg file leverage OSGi configureAdmin service to pick up properties during runtime.

                   

                  About the cxf.xml file, it exist in cxf bundle under META-INF/cxf and could be used from your customer bundle, so your customer bundle should import package META-INF.cxf to ensure cxf.xml is available for your bundle.

                   

                  In your Eclipse generated project, there's a pom.xml which use maven-bundle-plugin, you can configure that plugin to add any package import you want.

                   

                   

                  Freeman

                  • 6. Re: Problem attaching CXF interceptors to the Bus via configuration
                    niyyel

                    Hi Freeman,

                     

                    I think I have succesfully added META-INF/cxf to my customer bundle ( at least I do not have any more the previous error message in fuse log file). I have added some  in my bundle-context.xml.

                     

                    But still i do not intercept messages. Then I guess is because my bundle is a "regular" bundle, and not a fragment bundle. How I can attach a fragment bundle if the bundle is in FUSE and i'm working in a eclipse environment?

                     

                    Could you please give me more details about how configuring a component level bus which could be shared by all cxfbc endpoints ?

                     

                    many thanks for your help

                    • 7. Re: Problem attaching CXF interceptors to the Bus via configuration
                      niyyel

                      Hi again,

                       

                      I added to my pom this:

                      <Fragment-Host>org.apache.servicemix.servicemix-cxf-bc</Fragment-Host>

                       

                      Is this the way to indicate that is a fragment bundle depending of org.apache.servicemix.servicemix-cxf-bc bundle?

                       

                      Here the problema I have now is that the bundle appears as "installed" but cannot be started.

                       

                      cheers,

                      jordi

                      • 8. Re: Problem attaching CXF interceptors to the Bus via configuration
                        ffang

                        Hi,

                         

                        You should use Bundle-SymbolicName of servicemix-cxf-bc bundle for Fragment-Host, which should be

                        "servicemix-cxf-bc"

                        After you doing it, you need refresh servicemix-cxf-bc bundle to  pick up your fragment bundle.

                         

                        The correct status for your fragment bundle should be "Resolved", if you saw it not "Resolved", there must be some exception in data/log/servicemix.log which can indicate you what's wrong there.

                         

                        Just an example how host/fragment bundle looks like if you use "osgi:list" to list bundle status.

                         

                        For Host, it like

                        activemq-core (5.4.2.fuse-01-00)

                                                               Fragments: 53

                        which indicate it has the fragment bundle with bundle id 53

                        For fragment, it like

                        activemq-blueprint (5.4.2.fuse-01-00)

                                                               Hosts: 43

                        which means it's a fragment bundle (notice the status is "Resolved" but not the normal "Active"), the hosts is with bunle id 43.

                         

                         

                        Freeman

                        • 9. Re: Problem attaching CXF interceptors to the Bus via configuration
                          niyyel

                          Hi Freeman,

                           

                          I'm using FUSE ESB v4.2 instead of FUSE ESB v4.3

                          Does this make any difference for what we are talking about?

                          • 10. Re: Problem attaching CXF interceptors to the Bus via configuration
                            ffang

                            Hi,

                             

                            You should use FUSE 4.3, so that the busCfg you specified in org.apache.servicemix.components.cxfbc.cfg could be picked up.

                            SMXCOMP-802[1] tracked this issue.

                             

                            https://issues.apache.org/jira/browse/SMXCOMP-802

                             

                            Freeman

                            • 11. Re: Problem attaching CXF interceptors to the Bus via configuration
                              niyyel

                              Hi Freeman ,

                               

                              I feel I am progressing, and that is precisely for your valuable help!! Thank you so much.

                               

                              Indeed, you were right, I have moved to FUSE ESB v4.3 and now it seems I have "attached" my bundle successfully.

                               

                              Apache ServiceMix :: Components :: CXF Binding Component (2010.02.0.fuse-00-00)

                                                                     Fragments: 171

                               

                              [] GLOS CXF interceptor (0.0.1.SNAPSHOT)

                                                                     Hosts: 132

                               

                              However, I am not sure that I specify busCfg org.apache.servicemix.components.cxfbc.cfg  properly ( I have attached my file) .

                               

                              If this file is correct, I'm wondering that could be just that the way I'm trying to test is wrong. What I use is the "cxf-wsdl-first-osgi-package" example in FUSE.

                               

                              What I do is to install that example and later with the web-client click "send" ( file:///C:/apache-servicemix-4.2.0-fuse-02-00/examples/cxf-wsdl-first-osgi-package/client.html). I reveice a proper STATUS 200 OK but any trace capture in my interceptor.

                               

                              Once again, many thanks

                              jordi

                              • 12. Re: Problem attaching CXF interceptors to the Bus via configuration
                                ffang

                                Hi,

                                 

                                This

                                busCfg= "C:\Users\Jordi\Documents\EclipseWorkspace\glosCXFinterceptor\src\main\resources\META-INF\spring\bundle-context.xml"

                                 

                                isn't correct, it should be the relative path in your bundle

                                try with

                                busCfg="META-INF\spring\bundle-context.xml"

                                 

                                With your original busCfg configuration, I think you should see some exception in data/log/servicemix.log to complain can't load file.

                                 

                                Freeman

                                • 13. Re: Problem attaching CXF interceptors to the Bus via configuration
                                  niyyel

                                  Hi Freeman,

                                   

                                  I tried with busCfg="META-INF\spring\bundle-context.xml".

                                  Unfortunately, I cannot see any error trace or exception. I attach you me log file

                                  • 14. Re: Problem attaching CXF interceptors to the Bus via configuration
                                    niyyel

                                    Hi Freeman,

                                     

                                    I have been reading the log file and I have found this entry.

                                     

                                    10:09:35,831 | INFO  | ExtenderThread-2 | XmlBeanDefinitionReader          | tory.xml.XmlBeanDefinitionReader  315 | 60 - org.springframework.beans - 3.0.3.RELEASE | Loading XML bean definitions from URL bundle://171.0:0/META-INF/spring/bundle-context-osgi.xml

                                     

                                     

                                    10:09:36,046 | INFO  | ExtenderThread-2 | XmlBeanDefinitionReader          | tory.xml.XmlBeanDefinitionReader  315 | 60 - org.springframework.beans - 3.0.3.RELEASE | Loading XML bean definitions from URL  bundle://171.0:0/META-INF/spring/bundle-context.xml

                                     

                                    I guess it means that the busCfg is loaded properly right?

                                     

                                    No idea why still doesn't work...

                                     

                                    Attached also the log file if you need to check something

                                     

                                    all the best,

                                     

                                    Edited by: niyyel on Feb 25, 2011 9:26 AM

                                     

                                    Edited by: niyyel on Feb 25, 2011 9:28 AM

                                    1 2 3 Previous Next