Camel bindy not working in Spring boot

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Camel bindy not working in Spring boot

cgsk
Hi There,

I am using Bindy csv format to marshal to csv file. Everything works fine if i run from ecplise, but fails with the below exception if ran as a spring boot jar from command line. I tried creating custom  PackageScanClassResolver extending DefaultPackageScanClassResolver, but no luck. I also tried with latest version of camel as well, but same error

java.lang.NullPointerException
        at org.apache.camel.dataformat.bindy.util.ConverterUtils.getByteReturn(ConverterUtils.java:41) ~[camel-bindy-2.15.6.jar!/:2.15.6]
        at org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.marshal(BindyCsvDataFormat.java:69) ~[camel-bindy-2.15.6.jar!/:2.15.6]
        at org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:81) ~[camel-core-2.15.6.jar!/:2.15.6]


Regards,
CGSK
Reply | Threaded
Open this post in threaded view
|

Re: Camel bindy not working in Spring boot

cgsk
Could someone help with the below issue? Below is the custom packageresolver:

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;

import org.apache.camel.impl.DefaultPackageScanClassResolver;
import org.springframework.stereotype.Component;
@Component
public class SpringBootPackageResolver extends DefaultPackageScanClassResolver {

        private final String resourcePath;
       
        public SpringBootPackageResolver() {
                this.resourcePath = "META-INF/services/org/apache/camel/TypeConverter";
        }
       
         public static boolean isWebSphereClassLoader(ClassLoader loader) {
                return loader != null ? loader.getClass().getName().startsWith("com.") : false;
            }

       
       
        @Override
    protected Enumeration<URL> getResources(ClassLoader loader, String packageName) throws IOException {
        // try super first, just in vase
        Enumeration<URL> enumeration = super.getResources(loader, "com/domain/");
        if (!enumeration.hasMoreElements()) {
           
            enumeration = loader.getResources("com/domain/");
        }

        return enumeration;
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Camel bindy not working in Spring boot

Charles Moulliard-2
Hi,

Do you have a test case to reproduce the error ?

Regards,

On Wed, Apr 13, 2016 at 5:18 PM, cgsk <[hidden email]> wrote:

> Could someone help with the below issue? Below is the custom
> packageresolver:
>
> import java.io.IOException;
> import java.net.URL;
> import java.util.Enumeration;
>
> import org.apache.camel.impl.DefaultPackageScanClassResolver;
> import org.springframework.stereotype.Component;
> @Component
> public class SpringBootPackageResolver extends
> DefaultPackageScanClassResolver {
>
>         private final String resourcePath;
>
>         public SpringBootPackageResolver() {
>                 this.resourcePath =
> "META-INF/services/org/apache/camel/TypeConverter";
>         }
>
>          public static boolean isWebSphereClassLoader(ClassLoader loader) {
>                 return loader != null ?
> loader.getClass().getName().startsWith("com.") : false;
>             }
>
>
>
>         @Override
>     protected Enumeration<URL> getResources(ClassLoader loader, String
> packageName) throws IOException {
>         // try super first, just in vase
>         Enumeration<URL> enumeration = super.getResources(loader,
> "com/domain/");
>         if (!enumeration.hasMoreElements()) {
>
>             enumeration = loader.getResources("com/domain/");
>         }
>
>         return enumeration;
>     }
> }
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-bindy-not-working-in-Spring-boot-tp5780995p5781012.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
Reply | Threaded
Open this post in threaded view
|

Re: Camel bindy not working in Spring boot

cgsk
I dont have a test case, but below is the route where I pass a List of Map of my model class.

from(Constants.ROUTE_CONVERT_TO_CSV)
                        .log("Received request for S3 upload")
                        .marshal().bindy(BindyType.Csv, "com.domain")
                        .setHeader(S3Constants.KEY, simple("${date:now:yyyy-MM-dd}"+"/"+Constants.FILENAME_PREIX+"${date:now:yyyyMMddHHmmss}")) //Sets Filename in S3
                        .to("aws-s3://{{s3.bucket.name.prefix}}?"
                                        + "accessKey={{aws.accesskey}}"
                                        + "&secretKey=RAW({{aws.secretkey}})");
                       
               

Regards,
CGSK
Reply | Threaded
Open this post in threaded view
|

Re: Camel bindy not working in Spring boot

Charles Moulliard-2
In order to help you, a test case will be required with the code
reproducing the issue.

On Wed, Apr 13, 2016 at 5:47 PM, cgsk <[hidden email]> wrote:

> I dont have a test case, but below is the route where I pass a List of Map
> of
> my model class.
>
> from(Constants.ROUTE_CONVERT_TO_CSV)
>                         .log("Received request for S3 upload")
>                         .marshal().bindy(BindyType.Csv, "com.domain")
>                         .setHeader(S3Constants.KEY,
>
> simple("${date:now:yyyy-MM-dd}"+"/"+Constants.FILENAME_PREIX+"${date:now:yyyyMMddHHmmss}"))
> //Sets Filename in S3
>                         .to("aws-s3://{{s3.bucket.name.prefix}}?"
>                                         + "accessKey={{aws.accesskey}}"
>                                         +
> "&secretKey=RAW({{aws.secretkey}})");
>
>
>
> Regards,
> CGSK
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-bindy-not-working-in-Spring-boot-tp5780995p5781017.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io