You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ted <na...@pritchard.uk.net> on 2015/03/30 17:06:06 UTC

Bindy running within a WAR

Hi,

I have a self executable Spring Boot (1.2.2) and Camel Boot (2.15.0)
application built as a WAR.  My route makes use of Bindy to unmarshal CSV to
my object class.  Everything work well when I run the code directly using
Maven (mvn spring-boot:run) or if I run using Eclipse.  However if I build
my WAR file and execute that (java -jar myWebApp.war) then I get errors

java.lang.IllegalArgumentException: The separator has not been defined in
the annotation @CsvRecord or not instantiated during initModel. must be
specified
	at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
	at
org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:137)
	at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
	at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)


In the Camel/Bindy code I can see that
DefaultPackageScanClassResolver.loadImplementationsInJar obviously has
special provision for jar files but what about the equivalent for WAR files? 
Class files are located under WEB-INF in war files which means my annotated
classes are not being found.  See method
DefaultPackageScanClassResolver.doLoadImplementationsInJar where the code is
attempting to find classes that start with a particular package but will
never find any because the file locations include WEB-INF, which would not
be the case with a jar file.

Is there another way of doing this or does Bindy need fixing?



--
View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bindy running within a WAR

Posted by RaviP <ra...@hotmail.com>.
I've moved on by changing it to beanio.  

thanks
Ravi.



--
View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5766174.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bindy running within a WAR

Posted by RaviP <ra...@hotmail.com>.
I tried deploying the war in ... wildfly-camel-patch option ...I'm getting
LinkageError exception

I'm using ContextLoaderListener to load the camel context. 

                 <dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>4.1.5.RELEASE</version>
		</dependency>

wildfly-camel-patch also contains 4.1.5.RELEASE.

thanks
Ravi.



--
View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5765831.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bindy running within a WAR, widlfly 8.2.0 and Camel

Posted by "sanjay.gautam" <sa...@gmail.com>.
Hi I am also facing the same issue , I looked at the code and looks like that
here is exactly the issue Class Name : *BindyCsvDataFormat*at
org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.BindyCsvFactory
*factory* =
(BindyCsvFactory)getFactory(exchange.getContext().getPackageScanClassResolver());       
ObjectHelper.notNull(factory, "not instantiated");        // List of Pojos       
List<Map&lt;String, Object>> models = new ArrayList<Map&lt;String,
Object>>();        // Pojos of the model        Map<String, Object> model;       
InputStreamReader in = new InputStreamReader(inputStream,
IOHelper.getCharsetName(exchange));        // Scanner is used to read big
file        Scanner scanner = new Scanner(in);        // Retrieve the
separator defined to split the record      *  String separator =
factory.getSeparator();*        String quote = factory .getQuote();Please
let me know why the factory is not getting populated with the seperator even
though I have defined it correctly . *ERROR *at
org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
[camel-core-2.15.0.jar:2.15.0]	at
org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:137)
[camel-bindy-2.15.0.jar:2.15.0]	at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
[camel-core-2.15.0.jar:2.15.0]	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
[camel-core-2.15.0.jar:2.15.0]	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
[camel-core-2.15.0.jar:2.15.0]	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
[camel-core-2.15.0.jar:2.15.0]	at
org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
[camel-core-2.15.0.jar:2.15.0]



--
View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5765884.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bindy running within a WAR

Posted by Charles Moulliard <ch...@gmail.com>.
Hi Ravi,

Have you tried to use the camel bindy "module" instead of packaging all the
deps within the war file (
http://wildflyext.gitbooks.io/wildfly-camel/content/components/camel-bindy.html,
http://wildflyext.gitbooks.io/wildfly-camel/content/start/index.html) ?

Regards,

On Mon, Apr 13, 2015 at 7:34 PM, RaviP <ra...@hotmail.com>
wrote:

> I'm facing the similar issue with my war.  I'm using wildfly 8.2.0 & Camel
> 2.14.1.  My route uses bindy to unmarshal csv to domain object. Junits are
> working & war deployed on tomcat also works.
>
> I'm getting the following exception when i deploy the war on wildfly 8.2.0
>
> java.lang.IllegalArgumentException: The separator has not been defined in
> the annotation @CsvRecord or not instantiated during initModel. must be
> specified.
>
> I see that a solution recommended was to use PackageScanClassResolver.
>
> Can you please tell me how to do that incase of wildfly ?  Do i've to add
> additional dependencies.
>
> thanks
> Ravi.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5765711.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



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

RE: Bindy running within a WAR

Posted by Bonnet Benjamin <be...@soprasteria.com>.
Hi,
If you use it inside jBoss/wildfly, you should use jboss package scan class resolver. See camel-extra (https://code.google.com/a/apache-extras.org/p/camel-extra/).
Regards

-----Message d'origine-----
De : RaviP [mailto:ravikumar-penumetsa@hotmail.com] 
Envoyé : lundi 13 avril 2015 19:35
À : users@camel.apache.org
Objet : Re: Bindy running within a WAR

I'm facing the similar issue with my war.  I'm using wildfly 8.2.0 & Camel 2.14.1.  My route uses bindy to unmarshal csv to domain object. Junits are working & war deployed on tomcat also works.

I'm getting the following exception when i deploy the war on wildfly 8.2.0

java.lang.IllegalArgumentException: The separator has not been defined in the annotation @CsvRecord or not instantiated during initModel. must be specified.

I see that a solution recommended was to use PackageScanClassResolver.

Can you please tell me how to do that incase of wildfly ?  Do i've to add additional dependencies.

thanks
Ravi.



--
View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5765711.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bindy running within a WAR

Posted by RaviP <ra...@hotmail.com>.
I'm facing the similar issue with my war.  I'm using wildfly 8.2.0 & Camel
2.14.1.  My route uses bindy to unmarshal csv to domain object. Junits are
working & war deployed on tomcat also works.

I'm getting the following exception when i deploy the war on wildfly 8.2.0

java.lang.IllegalArgumentException: The separator has not been defined in
the annotation @CsvRecord or not instantiated during initModel. must be
specified.

I see that a solution recommended was to use PackageScanClassResolver.

Can you please tell me how to do that incase of wildfly ?  Do i've to add
additional dependencies.

thanks
Ravi.



--
View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5765711.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bindy running within a WAR

Posted by Ted <na...@pritchard.uk.net>.
Okay, thanks Claus.



--
View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5765084.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bindy running within a WAR

Posted by Claus Ibsen <cl...@gmail.com>.
That is for using spring xml, with <camelContext>.

On Tue, Mar 31, 2015 at 12:59 PM, Ted <na...@pritchard.uk.net> wrote:
> Thanks, I've created a PackageScanClassResolver for my project that works
> with WAR files.
>
> In the documentation http://camel.apache.org/pluggable-class-resolvers.html
> it says I simply need to create a spring bean but when I tried the bean was
> never referenced.  I had a quick look in DefaultCamelContext and
> SpringCamelContext but all I could see was a hard coded reference to the
> DefaultPackageScanClassResolver.  My Spring config looks like this:
>
>         @Bean
>         BeltPackageScanClassResolver beltResolver() {
>                 BeltPackageScanClassResolver resolver = new
> BeltPackageScanClassResolver();
>
>                 return resolver;
>         }
>
> Am I missing something?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5765077.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Bindy running within a WAR

Posted by Ted <na...@pritchard.uk.net>.
Thanks, I've created a PackageScanClassResolver for my project that works
with WAR files.

In the documentation http://camel.apache.org/pluggable-class-resolvers.html
it says I simply need to create a spring bean but when I tried the bean was
never referenced.  I had a quick look in DefaultCamelContext and
SpringCamelContext but all I could see was a hard coded reference to the
DefaultPackageScanClassResolver.  My Spring config looks like this:

	@Bean
	BeltPackageScanClassResolver beltResolver() {
		BeltPackageScanClassResolver resolver = new
BeltPackageScanClassResolver();

		return resolver;
	}

Am I missing something?



--
View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035p5765077.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bindy running within a WAR

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What web server do you use for the War? Is it jetty or tomcat or something else?

Yeah bindy unfortunately uses that annotation scanning on classpath.
There is a ticket to improve this for the future.
You can impement a custom yourself that can load in the WAR.
http://camel.apache.org/pluggable-class-resolvers.html

On Mon, Mar 30, 2015 at 5:06 PM, Ted <na...@pritchard.uk.net> wrote:
> Hi,
>
> I have a self executable Spring Boot (1.2.2) and Camel Boot (2.15.0)
> application built as a WAR.  My route makes use of Bindy to unmarshal CSV to
> my object class.  Everything work well when I run the code directly using
> Maven (mvn spring-boot:run) or if I run using Eclipse.  However if I build
> my WAR file and execute that (java -jar myWebApp.war) then I get errors
>
> java.lang.IllegalArgumentException: The separator has not been defined in
> the annotation @CsvRecord or not instantiated during initModel. must be
> specified
>         at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
>         at
> org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:137)
>         at
> org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
>         at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
>         at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
>         at
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
>         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129)
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
>         at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
>         at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
>
>
> In the Camel/Bindy code I can see that
> DefaultPackageScanClassResolver.loadImplementationsInJar obviously has
> special provision for jar files but what about the equivalent for WAR files?
> Class files are located under WEB-INF in war files which means my annotated
> classes are not being found.  See method
> DefaultPackageScanClassResolver.doLoadImplementationsInJar where the code is
> attempting to find classes that start with a particular package but will
> never find any because the file locations include WEB-INF, which would not
> be the case with a jar file.
>
> Is there another way of doing this or does Bindy need fixing?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Bindy-running-within-a-WAR-tp5765035.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/