4 Replies Latest reply on Jul 6, 2013 1:10 AM by Freeman(Yue) Fang

    camel xslt an osgi - java.io.FileNotFoundException

    labo32 Newbie

      Hello,


      I try to get a route with a xslt as osgi package up and running.


      Environment:

      karaf - camel 2.11, camel 2.10

      servicemix 4 and 5

      route as simple xml file or as jar

      blueprint or spring

      xsl file in etc directory or as resource in the jar

       

      (the same route bundled as war - deployed in a tomcat works fine)


      A lot of combinations - no luck.


      Everything ends in


      Caused by: javax.xml.transform.TransformerException: java.io.FileNotFoundException: Cannot find resource in classpath for URI: removeNS.xsl


      I read about problems with the osgi resource loader but for the freemarker bundle the resource template is found.


      Is there a way to get camel xslt and osgi up and running ?


      Thanks

      labo

        • 1. Re: camel xslt an osgi - java.io.FileNotFoundException
          Freeman(Yue) Fang Master

          Hi,

           

          Append your camel router or even a testcase is more helpful here.

           

          In camel-itest-osgi module, there's a XsltRouteTest, you may wanna check it out.

           

          Freeman

          • 2. Re: camel xslt an osgi - java.io.FileNotFoundException
            labo32 Newbie

            Hi,

             

            to reproduce the problem download a karaf 2.3.1.

            Then install some camel bundles

             

            features:chooseurl camel 2.11-SNAPSHOT

             

            features:install camel-core camel-spring camel-restlet camel-jetty camel-josql camel-jpa camel-xmljson camel-gson camel-xstream camel-stream camel-freemarker camel-script camel-groovy camel-http camel-blueprint camel-jms

             

             

            add the resource file in etc folder (subdir net/test/resources) and deploy the route

             

            <?xml version="1.0" encoding="UTF-8"?>

            <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

                <bean id="restletComponent" class="org.restlet.Component"/>

                <bean id="camelRestletComponent" class="org.apache.camel.component.restlet.RestletComponent">

                    <argument index="0" type="org.restlet.Component" ref="restletComponent"/>

                </bean>

                <camelContext xmlns="http://camel.apache.org/schema/blueprint" id="init-match-context">

                    <route id="init-match-route">

                        <from uri="restlet:http://localhost:8888/rs/match/{leagueSaison}/{leagueShortcut}?restletMethods=GET"/>

                            <to uri="freemarker:net/test/resources/GetMatchdataByLeagueSaison.ftl"/>

                            <setHeader headerName="Content-Type">

                                <constant>text/xml; charset=UTF-8</constant>

                            </setHeader>

                            <to uri="http://www.openligadb.de/Webservices/Sportsdata.asmx"/>

                            <to uri="xslt:net/test/resources/removeNS.xsl"/>

                            <to uri="xslt:net/test/resources/openliga.xsl"/>

                            <split>

                                <xpath>//matches/match</xpath>

                                <to uri="log:match:{body}?level=DEBUG"/>

                            </split>

                    </route>

                </camelContext>

            </blueprint>

             

             

            The freemarker template seems to be found the xsl file not :-(

             

            Looks like https://issues.apache.org/jira/browse/CAMEL-5223 but this problem should be solved.

             

             

            Regards

            labo

            • 3. Re: camel xslt an osgi - java.io.FileNotFoundException
              labo32 Newbie

              Make a bundle with all the resource files did it.

               

              Is this the only way in an osgi camel route to put the resources in a separate bundle ?

              Is it not possible to load them from the classpath ?

               

              Note to myself: learn more about osgi

               

              Thanks

              labo

              • 4. Re: camel xslt an osgi - java.io.FileNotFoundException
                Freeman(Yue) Fang Master

                Hi,

                 

                We suggest put the resource file into bundle, as this way the bundle is self-contained and easy for management.

                Though  you can also put the resource file into a folder outside the bundle, provided the folder is on the classpath. This way generally is a little bit tricky as it depend on how your code looks like and which classloader is used.

                 

                Freeman