10 Replies Latest reply on Sep 15, 2011 1:18 AM by Jochen Lauer

    CXF - REST - JSON Question

    Jochen Lauer Apprentice

      Hello together,

       

      I have some problems regarding the combination CXF - REST - JSON.

       

      My camel route works fine returning xml but when I try to return json format I run into problems.

       

      I installed the feature camel-jackson and camel-xmpp (don't know if it is really required)

      and changed my service implementation to

       

      @GET
      @Path("/match/{id}/")
      @Produces({"application/json", "text/xml"})
      public Match getMatch(@PathParam("id") String id) {
                return null;
           }
      

       

      and my camel route looks like

       

      
      <from uri="cxfrs://bean://rsServer"/>
              <choice>
                  <when>
                      <simple>${in.header.CamelHttpMethod} == 'GET'</simple>
                      <to uri="sql:SELECT * FROM matches p where p.matchID =#?dataSourceRef=dataSource"></to>
                      <bean ref="GetMatchBean"></bean>
                      <marshal ref="jsonProvider"></marshal>
                  </when>
      
      .....
      ....
      <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider"></bean>
      
      

       

      My client call

       

      WebClient wclient = WebClient.create("http://localhost:9000/route/matchservice/match/123","someuser","somepassword",null);
      wclient.type("text/xml").accept("application/json");
      Response r = wclient.get();
      System.out.println("Response from GET " + r.getStatus());
      

       

       

       

      This fails with a "java.net.ConnectException: Connection refused: connect".

       

      The same code without the json stuff using application/xml works fine

        • 1. Re: CXF - REST - JSON Question
          Freeman(Yue) Fang Master

          Hi,

           

          First you need check if you really expose RESTful service at http://localhost:9000/route/matchservice/match/123,

          The exception

          "java.net.ConnectException: Connection refused: connect".

          generally means there's no service at url you try to connect.

           

          Freeman

          • 2. Re: CXF - REST - JSON Question
            Jochen Lauer Apprentice

            Ok, my osgi bundle has really not been started (after redeployment). The osgi:start does not bring it up and running only a redeployment got it in the status "Failed" with a

            java.lang.ClassNotFoundException: org.codehaus.jettison.mapped.TypeConverter not found by org.apache.cxf.bundle

             

            I thought jettison is included the camel-jackson component ? Which bundle do I have to deploy/install to avoid the ClassNotFound Exception ?

             

            Regards

            labo

            • 3. Re: CXF - REST - JSON Question
              Freeman(Yue) Fang Master

              Hi,

               

              Package org.codehaus.jettison.mapped is from bundle mvn:org.codehaus.jettison/jettison/1.2

               

              this bundle is from cxf feature so it should be installed by default when you start FUSE ESB.

               

              I think you just need add Import-Package org.codehaus.jettison.mapped for your customer bundle.

              Freeman

              • 4. Re: CXF - REST - JSON Question
                Jochen Lauer Apprentice

                I already mapped org.codehaus.jettison.mapped it in the import section of my bundle.

                I am using apache-servicemix-4.4.0-fuse-00-43, the jettison-1.2.jar file is incuded

                \system\org\codehaus\jettison\jettison\1.2

                but the errror still occurs....

                 

                Regards

                labo

                • 5. Re: CXF - REST - JSON Question
                  Freeman(Yue) Fang Master

                  Hi,

                   

                  Could you post result of

                  osgi:list -t 0

                  and

                  osgi:headers your_customer_bundle_id?

                   

                  Also, does your machine has internet connection?

                   

                  Freeman

                  • 6. Re: CXF - REST - JSON Question
                    Jochen Lauer Apprentice

                    It seems that the cxf bundle is not able to find the jettison jar.

                    java.lang.ClassNotFoundException: org.codehaus.jettison.mapped.TypeConverter not found by org.apache.cxf.bundle

                     

                    osgi:list -t 0

                    osgi:list -t 0
                    START LEVEL 100 , List Threshold: 0
                       ID   State         Blueprint      Spring    Level  Name
                    [   0] [Active     ] [            ] [       ] [    0] System Bundle (3.0.9.fuse-00-43)
                    [   1] [Active     ] [            ] [       ] [    5] OPS4J Pax Url - wrap: (1.2.6)
                    [   2] [Active     ] [            ] [       ] [    5] OPS4J Pax Url - mvn: (1.2.6)
                    [   3] [Active     ] [            ] [       ] [    8] OPS4J Pax Logging - Service (1.6.2)
                    [   4] [Active     ] [            ] [       ] [    8] OPS4J Pax Logging - API (1.6.2)
                    [   5] [Active     ] [            ] [       ] [   10] Apache Felix Configuration Admin Service (1.2.8.fuse-00-43)
                    [   6] [Active     ] [            ] [       ] [   10] Apache Felix Bundle Repository (1.6.4)
                    [   7] [Active     ] [            ] [       ] [   11] Apache Felix File Install (3.1.11.fuse-00-43)
                    [   8] [Active     ] [            ] [       ] [   20] Apache Aries Proxy Bundle (0.3.0)
                    [   9] [Active     ] [            ] [       ] [   20] Apache Aries Util (0.3.0)
                    [  10] [Active     ] [Created     ] [       ] [   20] Apache Aries Blueprint Bundle (0.3.1)
                    [  11] [Active     ] [            ] [       ] [   20] Apache ServiceMix :: Bundles :: asm (3.3.0.1)
                    [  12] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: Various Commands (2.2.0.fuse-00-43)
                    [  13] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Deployer :: Wrap Non OSGi Jar (2.2.0.fuse-00-43)
                    [  14] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: Development Commands (2.2.0.fuse-00-43)
                    [  15] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Deployer :: Karaf Archive (.kar) (2.2.0.fuse-00-43)
                    [  16] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: JAAS :: Modules (2.2.0.fuse-00-43)
                    [  17] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: SSH (2.2.0.fuse-00-43)
                    [  18] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Features :: Command (2.2.0.fuse-00-43)
                    [  19] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Deployer :: Spring (2.2.0.fuse-00-43)
                    [  20] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Admin :: Core (2.2.0.fuse-00-43)
                    [  21] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: OSGi Commands (2.2.0.fuse-00-43)
                    [  22] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Diagnostic :: Management (2.2.0.fuse-00-43)
                    [  23] [Active     ] [            ] [       ] [   30] Apache Mina SSHD :: Core (0.5.0)
                    [  24] [Active     ] [            ] [       ] [   30] Apache Karaf :: Diagnostic :: Core (2.2.0.fuse-00-43)
                    [  25] [Active     ] [            ] [       ] [   30] Apache Aries JMX Blueprint Bundle (0.3.0)
                    [  26] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Features :: Management (2.2.0.fuse-00-43)
                    [  27] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Diagnostic :: Common (2.2.0.fuse-00-43)
                    [  28] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Admin :: Management (2.2.0.fuse-00-43)
                    [  29] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Jaas :: Command (2.2.0.fuse-00-43)
                    [  30] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: JAAS :: Config (2.2.0.fuse-00-43)
                    [  31] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: Log Commands (2.2.0.fuse-00-43)
                    [  32] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Deployer :: Features (2.2.0.fuse-00-43)
                    [  33] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Admin :: Command (2.2.0.fuse-00-43)
                    [  34] [Active     ] [            ] [       ] [   30] Apache Aries JMX Bundle (0.3.0)
                    [  35] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Features :: OBR Resolver (2.2.0.fuse-00-43)
                    [  36] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Diagnostic :: Command (2.2.0.fuse-00-43)
                    [  37] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Management (2.2.0.fuse-00-43)
                    [  38] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: Console (2.2.0.fuse-00-43)
                    [  39] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: PackageAdmin Commands (2.2.0.fuse-00-43)
                    [  40] [Active     ] [            ] [       ] [   30] Apache MINA Core (2.0.1)
                    [  41] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Features :: Core (2.2.0.fuse-00-43)
                    [  42] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Deployer :: Blueprint (2.2.0.fuse-00-43)
                    [  43] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: asm (3.3.0.2)
                    [  44] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: ConfigAdmin Commands (2.2.0.fuse-00-43)
                    [  45] [Active     ] [            ] [       ] [   60] activemq-pool (5.5.0.fuse-00-43)
                    [  46] [Active     ] [            ] [       ] [   60] activemq-console (5.5.0.fuse-00-43)
                    [  47] [Active     ] [            ] [       ] [   60] kahadb (5.5.0.fuse-00-43)
                    [  48] [Active     ] [            ] [       ] [   60] activemq-ra (5.5.0.fuse-00-43)
                    [  49] [Active     ] [Created     ] [       ] [   60] activemq-core (5.5.0.fuse-00-43)
                                                           Fragments: 63
                    [  50] [Active     ] [            ] [       ] [   60] Apache Aries Transaction Manager (0.2.0.incubating)
                    [  51] [Active     ] [Created     ] [       ] [   60] activemq-karaf (5.5.0.fuse-00-43)
                    [  52] [Active     ] [            ] [       ] [   60] geronimo-j2ee-management_1.1_spec (1.0.1)
                    [  53] [Active     ] [            ] [       ] [   60] Commons Pool (1.5.4)
                    [  54] [Active     ] [            ] [       ] [   60] geronimo-jms_1.1_spec (1.1.1)
                    [  55] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: commons-codec (1.3.0.3)
                    [  56] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: xpp3-1.1.4c (1.1.0.4c_3)
                    [  57] [Active     ] [            ] [       ] [   60] Commons Collections (3.2.1)
                    [  58] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: oro-2.0.8 (2.0.8.3)
                    [  59] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: jasypt (1.6.0.1)
                    [  60] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: commons-lang (2.4.0.4)
                    [  61] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: jdom (1.1.0.3)
                    [  62] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: velocity (1.7.0.1)
                    [  63] [Resolved   ] [            ] [       ] [   60] activemq-blueprint (5.5.0.fuse-00-43)
                                                           Hosts: 49
                    [  64] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: Scripting API 1.0 (1.8.0)
                    [  65] [Active     ] [Created     ] [       ] [   60] Apache XBean :: OSGI Blueprint Namespace Handler (3.7)
                    [  66] [Active     ] [            ] [       ] [   60] Commons JEXL (2.0.1)
                    [  67] [Active     ] [Created     ] [       ] [   60] activemq-broker.xml (0.0.0)
                    [  68] [Active     ] [            ] [       ] [   60] Spring Beans (3.0.5.RELEASE)
                    [  69] [Active     ] [            ] [       ] [   60] Spring Context Support (3.0.5.RELEASE)
                    [  70] [Active     ] [            ] [       ] [   60] Spring Context (3.0.5.RELEASE)
                    [  71] [Active     ] [            ] [       ] [   60] Spring Expression Language (3.0.5.RELEASE)
                    [  72] [Active     ] [            ] [       ] [   60] Spring ASM (3.0.5.RELEASE)
                    [  73] [Active     ] [            ] [       ] [   60] Spring Core (3.0.5.RELEASE)
                    [  74] [Active     ] [            ] [       ] [   60] Spring AOP (3.0.5.RELEASE)
                    [  75] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: aopalliance (1.0.0.5)
                    [  76] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: jaxb-impl (2.2.1.1_1)
                    [  77] [Active     ] [            ] [       ] [   60] camel-core (2.7.1.fuse-00-43)
                    [  78] [Active     ] [            ] [       ] [   60] Commons Management (1.0)
                    [  79] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: JAXB API 2.2 (1.8.0)
                    [  80] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: Stax API 1.0 (1.8.0)
                    [  81] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: Activation API 1.4 (1.8.0)
                    [  82] [Active     ] [            ] [       ] [   60] spring-osgi-core (1.2.1)
                    [  83] [Active     ] [            ] [       ] [   60] spring-osgi-io (1.2.1)
                    [  84] [Active     ] [            ] [       ] [   60] spring-osgi-annotation (1.2.1)
                    [  85] [Active     ] [            ] [       ] [   60] spring-osgi-extender (1.2.1)
                    [  86] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: cglib (2.1.0.3_7)
                    [  87] [Active     ] [            ] [       ] [   60] camel-spring (2.7.1.fuse-00-43)
                    [  88] [Active     ] [            ] [       ] [   60] Spring Transaction (3.0.5.RELEASE)
                    [  89] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: dom4j-1.6.1 (1.6.1.2)
                    [  90] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: xstream-1.3 (1.3.0.3)
                    [  91] [Active     ] [            ] [       ] [   60] camel-jms (2.7.1.fuse-00-43)
                    [  92] [Active     ] [            ] [       ] [   60] Spring JMS (3.0.5.RELEASE)
                    [  93] [Active     ] [            ] [       ] [   60] activemq-camel (5.5.0.fuse-00-43)
                    [  94] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Document (1.5.0.fuse-00-43)
                    [  95] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: NMR :: Commands (1.5.0.fuse-00-43)
                    [  96] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: NMR :: Management (1.5.0.fuse-00-43)
                    [  97] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: NMR :: OSGi (1.5.0.fuse-00-43)
                    [  98] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: NMR :: Core (1.5.0.fuse-00-43)
                    [  99] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: NMR :: API (1.5.0.fuse-00-43)
                    [ 100] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Utils (1.5.0.fuse-00-43)
                    [ 101] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Features :: Camel Support :: Component (4.4.0.fuse-00-43)
                    [ 102] [Active     ] [            ] [       ] [   60] Web Services Metadata 2.0 (1.1.3)
                    [ 103] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: JAXWS API 2.2 (1.8.0)
                    [ 104] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: SAAJ API 1.3 (1.8.0)
                    [ 105] [Active     ] [            ] [       ] [   60] Jetty :: JNDI Naming (7.4.1.v20110513)
                    [ 106] [Active     ] [            ] [       ] [   60] Jetty :: Continuation (7.4.1.v20110513)
                    [ 107] [Active     ] [            ] [       ] [   60] Jetty :: Http Utility (7.4.1.v20110513)
                    [ 108] [Active     ] [            ] [       ] [   60] Jetty :: Asynchronous HTTP Client (7.4.1.v20110513)
                    [ 109] [Active     ] [            ] [       ] [   60] Jetty :: Server Core (7.4.1.v20110513)
                    [ 110] [Active     ] [            ] [       ] [   60] Jetty :: Servlet Handling (7.4.1.v20110513)
                    [ 111] [Active     ] [            ] [       ] [   60] Jetty :: IO Utility (7.4.1.v20110513)
                    [ 112] [Active     ] [            ] [       ] [   60] Jetty :: Security (7.4.1.v20110513)
                    [ 113] [Active     ] [            ] [       ] [   60] Jetty :: XML utilities (7.4.1.v20110513)
                    [ 114] [Active     ] [            ] [       ] [   60] Jetty :: Utilities (7.4.1.v20110513)
                    [ 115] [Active     ] [            ] [       ] [   60] Jetty :: Plus (7.4.1.v20110513)
                    [ 116] [Active     ] [            ] [       ] [   60] Jetty :: JMX Management (7.4.1.v20110513)
                    [ 117] [Active     ] [            ] [       ] [   60] Jetty :: Utility Servlets and Filters (7.4.1.v20110513)
                    [ 118] [Active     ] [            ] [       ] [   60] Jetty :: Webapp Application Support (7.4.1.v20110513)
                    [ 119] [Active     ] [            ] [       ] [   60] geronimo-servlet_2.5_spec (1.1.2)
                    [ 120] [Active     ] [            ] [       ] [   60] JavaMail API (1.4.3)
                    [ 121] [Active     ] [            ] [       ] [   60] jettison (1.2)
                    [ 122] [Active     ] [Created     ] [       ] [   60] camel-cxf (2.7.1.fuse-00-43)
                    [ 123] [Active     ] [Created     ] [       ] [   60] Apache CXF Bundle Jar (2.4.1.fuse-00-43)
                    [ 124] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: xmlsec (1.4.4.1)
                    [ 125] [Active     ] [            ] [       ] [   60] WSS4J (1.6.0)
                    [ 126] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: xmlbeans (2.5.0.1)
                    [ 127] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: velocity (1.7.0.2)
                    [ 128] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: asm-2.2.3 (2.2.3.3)
                    [ 129] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: saaj-impl-1.3.2 (1.3.2.1)
                    [ 130] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: FastInfoset (1.2.7.3)
                    [ 131] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: xmlresolver-1.2 (1.2.0.2)
                    [ 132] [Active     ] [            ] [       ] [   60] XmlSchema Core (2.0)
                    [ 133] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: JSR-311 API 1.1 (1.8.0)
                    [ 134] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: wsdl4j (1.6.2.3)
                    [ 135] [Active     ] [            ] [       ] [   60] Apache Neethi (3.0.0)
                    [ 136] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: antlr-2.7.7 (2.7.7.2)
                    [ 137] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: opensaml-1.1 (1.1.0.3)
                    [ 138] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: ant (1.7.0.4)
                    [ 139] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Naming (1.5.0.fuse-00-43)
                    [ 140] [Active     ] [            ] [       ] [   60] Apache Aries Transaction Manager (0.3.0)
                    [ 141] [Active     ] [            ] [       ] [   60] Apache Aries Transaction Enlisting JDBC Datasource (0.3.0)
                    [ 142] [Active     ] [Created     ] [       ] [   60] Apache Aries Transaction Blueprint (0.3.0)
                    [ 143] [Active     ] [            ] [       ] [   60] Stax2 API (3.0.2)
                    [ 144] [Active     ] [            ] [       ] [   60] Woodstox XML-processor (4.0.8)
                    [ 145] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: JBI :: Deployer (1.5.0.fuse-00-43)
                    [ 146] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: JBI :: Commands (1.5.0.fuse-00-43)
                    [ 147] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: JBI :: OSGi (1.5.0.fuse-00-43)
                    [ 148] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: JBI :: Runtime (1.5.0.fuse-00-43)
                    [ 149] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: Shared Libraries :: Common (2011.02.0.fuse-00-43)
                    [ 150] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: JBI API 1.0 (1.8.0)
                    [ 151] [Active     ] [            ] [       ] [   60] Apache XBean :: Classloader (3.7)
                    [ 152] [Active     ] [            ] [       ] [   60] Apache XBean :: Spring (3.7)
                    [ 153] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: JBI :: Clustering :: Requestor (1.5.0.fuse-00-43)
                    [ 154] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: JBI :: Clustering :: Engine (1.5.0.fuse-00-43)
                    [ 155] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: JBI :: Clustering :: Config (1.5.0.fuse-00-43)
                    [ 156] [Active     ] [            ] [       ] [   60] OPS4J Pax Web - API (1.0.3)
                    [ 157] [Active     ] [            ] [       ] [   60] OPS4J Pax Web - Runtime (1.0.3)
                    [ 158] [Active     ] [            ] [       ] [   60] OPS4J Pax Web - Service SPI (1.0.3)
                    [ 159] [Active     ] [            ] [       ] [   60] OPS4J Pax Web - Jetty (1.0.3)
                    [ 160] [Active     ] [            ] [       ] [   60] OPS4J Pax Web - Extender - Whiteboard (1.0.3)
                    [ 161] [Active     ] [            ] [       ] [   60] OPS4J Pax Web - Extender - WAR (1.0.3)
                    [ 162] [Active     ] [            ] [       ] [   60] OPS4J Pax Url - war (1.2.6)
                    [ 163] [Active     ] [            ] [       ] [   60] OPS4J Pax Web - Jsp Support (1.0.3)
                    [ 164] [Active     ] [            ] [       ] [   60] OPS4J Pax Web - FileInstall Deployer (1.0.3)
                    [ 165] [Active     ] [Created     ] [       ] [   30] Apache Karaf :: Shell :: Web Commands (2.2.0.fuse-00-43)
                    [ 166] [Active     ] [            ] [       ] [   60] Servlet 3.0 (1.0)
                    [ 167] [Active     ] [            ] [       ] [   60] Axiom API (1.2.10)
                    [ 168] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: CXF Binding Component (2011.02.0.fuse-00-43)
                    [ 169] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Components :: Shared Libraries :: SOAP Stack v2 (2011.02.0.fuse-00-43)
                    [ 170] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: File Binding Component (2011.02.0.fuse-00-43)
                    [ 171] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: FTP Binding Component (2011.02.0.fuse-00-43)
                    [ 172] [Active     ] [            ] [       ] [   60] Commons Net (2.2)
                    [ 173] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: HTTP Binding Component (2011.02.0.fuse-00-43)
                    [ 174] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: jetty (6.1.26.1)
                    [ 175] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: commons-httpclient (3.1.0.5)
                    [ 176] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Components :: Shared Libraries :: SOAP Stack (2011.02.0.fuse-00-43)
                    [ 177] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: JMS Binding Component (2011.02.0.fuse-00-43)
                    [ 178] [Active     ] [            ] [       ] [   60] geronimo-j2ee-connector_1.5_spec (2.0.0)
                    [ 179] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: Mail Binding Component (2011.02.0.fuse-00-43)
                    [ 180] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: SMPP Binding Component (2011.02.0.fuse-00-43)
                    [ 181] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: jsmpp (2.1.0.2)
                    [ 182] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: SNMP Binding Component (2011.02.0.fuse-00-43)
                    [ 183] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: snmp4j (1.8.1.4)
                    [ 184] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: VFS Binding Component (2011.02.0.fuse-00-43)
                    [ 185] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: commons-vfs (1.0.0.5)
                    [ 186] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: Bean Service Engine (2011.02.0.fuse-00-43)
                    [ 187] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: Camel Service Engine (2011.02.0.fuse-00-43)
                    [ 188] [Active     ] [            ] [       ] [   60] Apache CXF Runtime JBI Transport (2.4.1.fuse-00-43)
                    [ 189] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Components :: CXF Service Engine (2011.02.0.fuse-00-43)
                    [ 190] [Active     ] [            ] [       ] [   60] Apache CXF Runtime JBI Binding (2.4.1.fuse-00-43)
                    [ 191] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: mvel2 (2.0.8.4)
                    [ 192] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: antlr-runtime (3.0.1.2)
                    [ 193] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: core (3.2.3.4)
                    [ 194] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: Drools Service Engine (2011.02.0.fuse-00-43)
                    [ 195] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: quartz (1.8.3.2)
                    [ 196] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: drools (5.1.1.1)
                    [ 197] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: EIP Service Engine (2011.02.0.fuse-00-43)
                    [ 198] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: OSWorkflow Service Engine (2011.02.0.fuse-00-43)
                    [ 199] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: oscore (2.2.4.4)
                    [ 200] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: osworkflow (2.7.0.4)
                    [ 201] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: propertyset (1.3.0.4)
                    [ 202] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: Quartz Service Engine (2011.02.0.fuse-00-43)
                    [ 203] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: JSR-223 Scripting Service Engine (2011.02.0.fuse-00-43)
                    [ 204] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: groovy (1.5.6.4)
                    [ 205] [Active     ] [            ] [       ] [   60] ScriptEngines :: Groovy (1.1)
                    [ 206] [Active     ] [            ] [       ] [   60] ScriptEngines :: JavaScript (1.1)
                    [ 207] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: js (1.0.0.7R1_3)
                    [ 208] [Active     ] [            ] [       ] [   60] ScriptEngines :: JRuby (1.1)
                    [ 209] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: jruby (1.1.2.3)
                    [ 210] [Active     ] [            ] [       ] [   60] camel-http (2.7.1.fuse-00-43)
                    [ 211] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: Validation Service Engine (2011.02.0.fuse-00-43)
                    [ 212] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: Saxon Service Engine (2011.02.0.fuse-00-43)
                    [ 213] [Active     ] [            ] [       ] [   60] Apache ServiceMix :: Bundles :: saxon (9.1.0.8_1)
                    [ 214] [Active     ] [Created     ] [       ] [   60] Apache ServiceMix :: Components :: WS-Notification Service Engine (2011.02.0.fuse-00-43)
                    [ 215] [Active     ] [            ] [       ] [   60] camel-jetty (2.7.1.fuse-00-43)
                    [ 216] [Active     ] [Created     ] [       ] [   60] camel-blueprint (2.7.1.fuse-00-43)
                    [ 217] [Active     ] [            ] [       ] [   60] camel-quartz (2.7.1.fuse-00-43)
                    [ 218] [Active     ] [            ] [       ] [   60] Commons DBCP (1.3)
                    [ 219] [Resolved   ] [            ] [       ] [   60] Apache ServiceMix Bundles: openjpa-1.2.1 (1.2.1.2)
                    [ 220] [Installed  ] [            ] [       ] [   60] camel-jpa (2.7.1.fuse-00-43)
                    [ 221] [Resolved   ] [            ] [       ] [   60] Apache ServiceMix :: Specs :: Java Persistence API 1.4 (1.8.0)
                    [ 222] [Resolved   ] [            ] [       ] [   60] Apache ServiceMix Bundles: serp-1.13.1 (1.13.1.2)
                    [ 223] [Resolved   ] [            ] [       ] [   60] Spring ORM (3.0.5.RELEASE)
                    [ 224] [Resolved   ] [            ] [       ] [   60] Spring JDBC (3.0.5.RELEASE)
                    [ 225] [Active     ] [            ] [       ] [   60] camel-jdbc (2.7.1.fuse-00-43)
                    [ 226] [Active     ] [            ] [       ] [   60] camel-sql (2.7.1.fuse-00-43)
                    [ 227] [Active     ] [            ] [       ] [   60] camel-juel (2.7.1.fuse-00-43)
                    [ 228] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: juel-2.1.2 (2.1.2.1)
                    [ 232] [Active     ] [            ] [       ] [   60] Sun Microsystems' JDBC Driver for MySQL (5.1.17)
                    [ 244] [Active     ] [            ] [       ] [   60] labo-global-beans (1.0.0.SNAPSHOT)
                    [ 246] [Active     ] [            ] [       ] [   60] camel-jackson (2.7.1.fuse-00-43)
                    [ 247] [Active     ] [            ] [       ] [   60] Data mapper for Jackson JSON processor (1.7.1)
                    [ 248] [Active     ] [            ] [       ] [   60] Jackson JSON processor (1.7.1)
                    [ 249] [Active     ] [            ] [       ] [   60] camel-xmpp (2.7.1.fuse-00-43)
                    [ 250] [Active     ] [            ] [       ] [   60] Apache ServiceMix Bundles: smack-3.1.0 (3.1.0.1)
                    [ 251] [Active     ] [            ] [       ] [   60] Labo ServiceMix :: REST :: match (4.4.0.fuse-00-43)
                    

                     

                     

                    karaf@root> osgi:headers 251
                    
                    Labo ServiceMix :: REST :: match (251)
                    --------------------------------------
                    Manifest-Version = 1.0
                    Bnd-LastModified = 1315855722009
                    Tool = Bnd-0.0.357
                    Built-By = labo
                    Build-Jdk = 1.6.0_22
                    Created-By = Apache Maven Bundle Plugin
                    
                    Bundle-Vendor = FuseSource
                    Bundle-Name = Labo ServiceMix :: REST :: match
                    Bundle-DocURL = http://fusesource.com/
                    Bundle-Description = JAX-RS API for matches
                    Bundle-SymbolicName = cxf-rest-match-osgi
                    Bundle-Version = 4.4.0.fuse-00-43
                    Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt
                    Bundle-ManifestVersion = 2
                    
                    DynamicImport-Package =
                            javax.ws.rs.*
                    Import-Package =
                            META-INF.cxf,
                            META-INF.cxf.osgi,
                            com.mysql.jdbc,
                            javax.security.auth.callback,
                            javax.sql,
                            javax.ws.rs;version=1.1,
                            javax.wsdl,
                            javax.xml.bind;version=2.2,
                            javax.xml.bind.annotation;version=2.2,
                            net.labo.global.bean,
                            net.labo.servicemix.cxf.jaxrs,
                            org.apache.camel;version=2.6,
                            org.apache.commons.httpclient;version=3.1,
                            org.apache.commons.httpclient.methods;version=3.1,
                            org.apache.cxf.attachment,
                            org.apache.cxf.binding,
                            org.apache.cxf.bus,
                            org.apache.cxf.bus.resource,
                            org.apache.cxf.bus.spring,
                            org.apache.cxf.configuration.security,
                            org.apache.cxf.configuration.spring,
                            org.apache.cxf.interceptor,
                            org.apache.cxf.jaxrs.client,
                            org.apache.cxf.jaxrs.provider,
                            org.apache.cxf.jaxrs.utils,
                            org.apache.cxf.message,
                            org.apache.cxf.phase,
                            org.apache.cxf.resource,
                            org.apache.cxf.transport.http,
                            org.apache.cxf.ws.security.wss4j,
                            org.apache.ws.security,
                            org.codehaus.jettison.mapped;version=1.2,
                            org.springframework.beans.factory.annotation;version=3.0,
                            org.springframework.beans.factory.config;version=3.0,
                            org.springframework.jdbc.core;version=3.0,
                            org.springframework.jdbc.datasource;version=3.0,
                            org.xml.sax
                    Export-Package =
                            net.labo.servicemix.cxf.jaxrs;
                                    uses:="org.apache.cxf.jaxrs.client,
                                            net.labo.global.bean,
                                            org.apache.camel,
                                            javax.ws.rs,
                                            org.apache.cxf.configuration.security,
                                            org.springframework.beans.factory.annotation,
                                            org.apache.cxf.message,
                                            org.apache.cxf.phase"
                    Require-Bundle =
                            org.apache.cxf.bundle
                    
                    

                     

                     

                    Normally my machine has got an internet connection (sometimes in the train it is broken       )

                     

                    Regards

                    labo

                    • 7. Re: CXF - REST - JSON Question
                      Freeman(Yue) Fang Master

                      Hi,

                       

                      Yes, cxf now optional import jettison with higher version

                      org.codehaus.jettison.mapped;resolution:=optional;version="[1.3,2)",

                       

                      As a workaround

                      You can edit

                      $FUSE_ESB/system/org/apache/servicemix/apache-servicemix/4.4.0-fuse-00-43/apache-servicemix-4.4.0-fuse-00-43-features.xml

                      in "cxf" feature, change

                       

                       

                      And remove $FUSE_ESB/data folder then restart FUSE ESB, it should be ok.

                       

                      In the future we will reuse cxf feature from apache-cxf-feaures.xml so will get rid of such version mismatch problem.

                       

                      Freeman

                      • 8. Re: CXF - REST - JSON Question
                        Jochen Lauer Apprentice

                        After perfoming the steps my servicemix shows extremly strange behaviour...... no libs could be found mentioned in the import-package

                         

                        I started with a new downloaded version, changed the

                         

                        Cannot find data format in registry with ref: jsonProvider

                         

                        karaf@root> 2011-09-13 21:28:40.567:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
                        Exception in thread "SpringOsgiExtenderThread-4" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to crea
                        te route route1 at: >>> Choice[[When[simple{${in.header.CamelHttpMethod} == 'GET'} -> [To[sql:SELECT * FROM matches p where p.matchID =#?dataSourceRef
                        =dataSource], Bean[ref:GetMatchBean], Marshal[ref:jsonProvider]]], When[simple{${in.header.CamelHttpMethod} == 'POST'} -> [To[log:POST], Bean[ref:Post
                        MatchBean]]], When[simple{${in.header.CamelHttpMethod} == 'PUT'} -> [To[log:PUT], Bean[ref:PutMatchBean]]], When[simple{${in.header.CamelHttpMethod} =
                        = 'DELETE'} -> [To[sql:DELETE FROM matches p where p.matchID =#?dataSourceRef=dataSource]]]] Otherwise[[To[log:ERROR calling REST Service for matches]
                        ]]] <<< in route: Route[[From[cxfrs://bean://rsServer]] -> [Choice[[When[simpl... because of Cannot find data format in registry with ref: jsonProvide
                        r
                                at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1139)
                                at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
                                at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:238)
                                at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
                                at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)
                                at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)
                                at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
                                at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.ja
                        va:358)
                                at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
                                at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplication
                        Context.java:320)
                                at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(Dependen
                        cyWaiterApplicationContextExecutor.java:132)
                                at java.lang.Thread.run(Thread.java:662)
                        Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> Choice[[When[simple{${in.header.CamelHttpMethod} == 'G
                        ET'} -> [To[sql:SELECT * FROM matches p where p.matchID =#?dataSourceRef=dataSource], Bean[ref:GetMatchBean], Marshal[ref:jsonProvider]]], When[simple
                        {${in.header.CamelHttpMethod} == 'POST'} -> [To[log:POST], Bean[ref:PostMatchBean]]], When[simple{${in.header.CamelHttpMethod} == 'PUT'} -> [To[log:PU
                        T], Bean[ref:PutMatchBean]]], When[simple{${in.header.CamelHttpMethod} == 'DELETE'} -> [To[sql:DELETE FROM matches p where p.matchID =#?dataSourceRef=
                        dataSource]]]] Otherwise[[To[log:ERROR calling REST Service for matches]]]] <<< in route: Route[[From[cxfrs://bean://rsServer]] -> [Choice[[When[simpl
                        ... because of Cannot find data format in registry with ref: jsonProvider
                                at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:818)
                                at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
                                at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:708)
                                at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1650)
                                at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1439)
                                at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1338)
                                at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:164)
                                at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
                                at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
                                at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1316)
                                at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:203)
                                at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)
                                ... 10 more
                        Caused by: java.lang.IllegalArgumentException: Cannot find data format in registry with ref: jsonProvider
                                at org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:75)
                                at org.apache.camel.model.MarshalDefinition.createProcessor(MarshalDefinition.java:144)
                                at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:391)
                                at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:136)
                                at org.apache.camel.impl.DefaultRouteContext.createProcessor(DefaultRouteContext.java:106)
                                at org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:155)
                                at org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:100)
                                at org.apache.camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69)
                                at org.apache.camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java:71)
                                at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:433)
                                at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:181)
                                at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:815)
                                ... 21 more
                        
                        
                        

                         

                         

                         

                        removing

                         

                        ...
                        <marshal ref="jsonProvider"/>
                        ....
                        <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider"></bean>
                        ...
                        

                         

                        seems to produce the expected result.

                         

                        Output from client

                         

                        Response from GET 200

                        Match :{"match":{"groupID":13,"idTeam1":87,"idTeam2":55,"leagueSaison":2006,"leagueShortcut":"bl1","matchID":123,"pointsTeam1":0,"pointsTeam2":1}}

                         

                        Is it not required to explicit marshal to json ?

                        • 9. Re: CXF - REST - JSON Question
                          Claus Ibsen Master

                          Hi

                           

                          You have mixed up Camel and CXF here. The  in Camel requires a Camel DataFormat instance.

                          http://camel.apache.org/data-format

                           

                          However you can just use the default  to marshal to JSon.

                          • 10. Re: CXF - REST - JSON Question
                            Jochen Lauer Apprentice

                            Thanks to all, now everything works as expected and all open questions are answered.