You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Johan Haleby <jo...@gmail.com> on 2011/01/18 11:40:51 UTC

Camel bootstrap with one-jar plugin fails

Hi, 

I'm trying to create an executable jar-file containing all dependencies for
my Spring and Camel based project so that I can execute it use java -jar
myjar.jar. How ever when I try this it fails during startup:

Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'defaultCamelContext': Invocation of init method
failed; nested exception is
org.apache.camel.NoTypeConversionAvailableException: No type converter
available to convert from type: java.lang.String to the required type:
java.lang.Boolean with value false
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
	at
org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:95)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	... 27 more
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
converter available to convert from type: java.lang.String to the required
type: java.lang.Boolean with value false
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:142)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:125)
	at
org.apache.camel.util.CamelContextHelper.parseBoolean(CamelContextHelper.java:259)
	at
org.apache.camel.core.xml.AbstractCamelContextFactoryBean.initCamelContext(AbstractCamelContextFactoryBean.java:606)
	at
org.apache.camel.core.xml.AbstractCamelContextFactoryBean.afterPropertiesSet(AbstractCamelContextFactoryBean.java:268)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)

I'm using the onejar maven plugin (which embeeds jar files inside and uses a
custom classloader to load the embedded libs). What can be the reason for
this?

/Johan
-- 
View this message in context: http://camel.465427.n5.nabble.com/Camel-bootstrap-with-one-jar-plugin-fails-tp3345975p3345975.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re:

Posted by Remi Malessa <re...@llgc.org.uk>.
On 01/19/2011 01:54 PM, Claus Ibsen wrote:
> Yeah most camel consumers will just log the exception. They have a
> ExceptionHandler which you can customize.
> However some like JMS consumer will rollback if its transacted, and
> the file consumer will lave the file as is, and try it again on next
> poll (it has a moveFailed option to move the file to some other
> directory on rollback).
Got it. Thanks.

Remi

Re:

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jan 19, 2011 at 2:22 PM, Remi Malessa <re...@llgc.org.uk> wrote:
> On 01/19/2011 10:45 AM, Claus Ibsen wrote:
>>
>> See figure 5.5. When handled=true, the caused exception will be
>> removed from the exchange, and the route consumer will not "detect"
>> any exceptions caused processing the exchange.
>>
>> When handled=false, the caused exception will be placed on the
>> exchange, and the route consumer will "detect" the exception and can
>> react for example by rolling back. This is consumer specific what
>> action they do on detecting an exception.
>
> Alright, so if there is no handle=true and no exception handling implemented
> in the
> consumer, it can even skip/ignore the message ?
>

Yeah most camel consumers will just log the exception. They have a
ExceptionHandler which you can customize.
However some like JMS consumer will rollback if its transacted, and
the file consumer will lave the file as is, and try it again on next
poll (it has a moveFailed option to move the file to some other
directory on rollback).



> Remi
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re:

Posted by Remi Malessa <re...@llgc.org.uk>.
On 01/19/2011 10:45 AM, Claus Ibsen wrote:
> See figure 5.5. When handled=true, the caused exception will be
> removed from the exchange, and the route consumer will not "detect"
> any exceptions caused processing the exchange.
>
> When handled=false, the caused exception will be placed on the
> exchange, and the route consumer will "detect" the exception and can
> react for example by rolling back. This is consumer specific what
> action they do on detecting an exception.
Alright, so if there is no handle=true and no exception handling 
implemented in the
consumer, it can even skip/ignore the message ?

Remi

Re:

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jan 19, 2011 at 11:32 AM, Remi Malessa <re...@llgc.org.uk> wrote:
>
>
>
>
>
>
> On 01/19/2011 01:51 AM, Hadrian Zbarcea wrote:
>>
>> If you don't have the Camel in Action book (please don't interpret the
>> previous answer as a request to buy the book) you can find more details
>> about exception handling here:
>> http://camel.apache.org/exception-clause.html. If you are curious to look at
>> the code, look at how CatchProcessor.handles(Exchange) is implemented and
>> used.
>
> Thanks Hadrian. Ha ha. I did think it was an invite to buy the book :-) I've
> looked at the web page as well, thanks.
>
>> You didn't post your throwing code, but it looks like camel found an exact
>> match.
>
> Yes, the code always throws "my.camel.package.ErrorFoundException".
>
>>  If no handled expression is defined, the exception is considered handled
>> by default, which explains why the behavior you see is the same.
>
> The book says "(...)whereas onException will, by default, not handle it.
> That’s why you use handled(true) (#1) to
> instruct Camel to handle this exception."
> I wonder if there's an advantage of using <handled/> in one of my examples ?
> Is it any better then the other ?
>

See figure 5.5. When handled=true, the caused exception will be
removed from the exchange, and the route consumer will not "detect"
any exceptions caused processing the exchange.

When handled=false, the caused exception will be placed on the
exchange, and the route consumer will "detect" the exception and can
react for example by rolling back. This is consumer specific what
action they do on detecting an exception.



>> Cheers,
>> Hadrian
>
> Thanks
> Remi
>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re:

Posted by Remi Malessa <re...@llgc.org.uk>.





On 01/19/2011 01:51 AM, Hadrian Zbarcea wrote:
> If you don't have the Camel in Action book (please don't interpret the previous answer as a request to buy the book) you can find more details about exception handling here: http://camel.apache.org/exception-clause.html. If you are curious to look at the code, look at how CatchProcessor.handles(Exchange) is implemented and used.
Thanks Hadrian. Ha ha. I did think it was an invite to buy the book :-) 
I've looked at the web page as well, thanks.

> You didn't post your throwing code, but it looks like camel found an exact match.
Yes, the code always throws "my.camel.package.ErrorFoundException".

>   If no handled expression is defined, the exception is considered handled by default, which explains why the behavior you see is the same.
The book says "(...)whereas onException will, by default, not handle it. 
That’s why you use handled(true) (#1) to
instruct Camel to handle this exception."
I wonder if there's an advantage of using <handled/> in one of my 
examples ? Is it any better then the other ?

> Cheers,
> Hadrian

Thanks
Remi


Re:

Posted by Hadrian Zbarcea <hz...@gmail.com>.
If you don't have the Camel in Action book (please don't interpret the previous answer as a request to buy the book) you can find more details about exception handling here: http://camel.apache.org/exception-clause.html. If you are curious to look at the code, look at how CatchProcessor.handles(Exchange) is implemented and used.

You didn't post your throwing code, but it looks like camel found an exact match. If no handled expression is defined, the exception is considered handled by default, which explains why the behavior you see is the same. There is more than meets the eye when it comes to exception handling. Spending a bit of time to understand how it works is well worth the effort.

Cheers,
Hadrian


On Jan 18, 2011, at 10:26 AM, Claus Ibsen wrote:

> Hi
> 
> Read chapter 5 in the Camel in Action book, it covers all about error handling.
> 
> 
> On Tue, Jan 18, 2011 at 4:20 PM, Remi Malessa <re...@llgc.org.uk> wrote:
>> Hi.
>> Could you please explain me what is the difference in handling an exception
>> with two methods below?
>> 
>> 1) I use <handled/> :
>> 
>> <bean id="readException"
>> class="my.camel.package.ReadMessageExceptionClass"/>
>> .
>> .
>> .
>> <onException>
>> <exception>my.camel.package.ErrorFoundException</exception>
>> <handled><static>true</static><handled>
>> <bean ref="readException"/>
>> <to uri="activemq:read_error_queue"/>
>> </onException>
>> 
>> 2) I don't use <handled/>
>> 
>> <onException>
>> <exception>my.camel.package.ErrorFoundException</exception>
>> <to uri="class:my.camel.package.ReadMessageExceptionClass"/>
>> <to uri="activemq:read_error_queue"/>
>> </onException>
>> 
>> 
>> As far as I tested the two above, the results from both methods are the
>> same..., but are they ?
>> The class my.camel.package.ReadMessageExceptionClass, returns a message ,
>> with text body , saying what was the
>> exception and the message body.
>> 
>> Thanks
>> Remi
>> 
>> 
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/


Re:

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

Read chapter 5 in the Camel in Action book, it covers all about error handling.


On Tue, Jan 18, 2011 at 4:20 PM, Remi Malessa <re...@llgc.org.uk> wrote:
> Hi.
> Could you please explain me what is the difference in handling an exception
> with two methods below?
>
> 1) I use <handled/> :
>
> <bean id="readException"
> class="my.camel.package.ReadMessageExceptionClass"/>
> .
> .
> .
> <onException>
> <exception>my.camel.package.ErrorFoundException</exception>
> <handled><static>true</static><handled>
> <bean ref="readException"/>
> <to uri="activemq:read_error_queue"/>
> </onException>
>
> 2) I don't use <handled/>
>
> <onException>
> <exception>my.camel.package.ErrorFoundException</exception>
> <to uri="class:my.camel.package.ReadMessageExceptionClass"/>
> <to uri="activemq:read_error_queue"/>
> </onException>
>
>
> As far as I tested the two above, the results from both methods are the
> same..., but are they ?
> The class my.camel.package.ReadMessageExceptionClass, returns a message ,
> with text body , saying what was the
> exception and the message body.
>
> Thanks
> Remi
>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Posted by Remi Malessa <re...@llgc.org.uk>.
Hi.
Could you please explain me what is the difference in handling an 
exception with two methods below?

1) I use <handled/> :

<bean id="readException" 
class="my.camel.package.ReadMessageExceptionClass"/>
.
.
.
<onException>
<exception>my.camel.package.ErrorFoundException</exception>
<handled><static>true</static><handled>
<bean ref="readException"/>
<to uri="activemq:read_error_queue"/>
</onException>

2) I don't use <handled/>

<onException>
<exception>my.camel.package.ErrorFoundException</exception>
<to uri="class:my.camel.package.ReadMessageExceptionClass"/>
<to uri="activemq:read_error_queue"/>
</onException>


As far as I tested the two above, the results from both methods are the 
same..., but are they ?
The class my.camel.package.ReadMessageExceptionClass, returns a message 
, with text body , saying what was the
exception and the message body.

Thanks
Remi


Re: Camel bootstrap with one-jar plugin fails

Posted by Johan Haleby <jo...@gmail.com>.
The one-jar plugin doesn't unpack and then re-pack everything together in the
same jar. It copies all dependencies to a folder inside the generate jar,
i.e. nothing is overwritten. The one-jar plugin then uses a custom
classloader to load jars inside the jar files.

When I downgrade to Camel 2.4.0 I don't get this problem but it still
doesn't work (it says that no route is found). Perhaps it could be related
to 
http://www.apacheserver.net/Observation-on-OSGi-and-NoTypeConversionAvailableException-at1068159.htm
this  problem?
-- 
View this message in context: http://camel.465427.n5.nabble.com/Camel-bootstrap-with-one-jar-plugin-fails-tp3345975p3346058.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel bootstrap with one-jar plugin fails

Posted by Claus Ibsen <cl...@gmail.com>.
Its related to this FAQ
http://camel.apache.org/why-do-camel-throw-so-many-noclassdeffoundexception-on-startup.html

Using a uber JAR is not recommended. As you will override service
files from the META-INF folder.
If you really want to do this you will have to merge that clashes manually.



On Tue, Jan 18, 2011 at 11:40 AM, Johan Haleby <jo...@gmail.com> wrote:
>
> Hi,
>
> I'm trying to create an executable jar-file containing all dependencies for
> my Spring and Camel based project so that I can execute it use java -jar
> myjar.jar. How ever when I try this it fails during startup:
>
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'defaultCamelContext': Invocation of init method
> failed; nested exception is
> org.apache.camel.NoTypeConversionAvailableException: No type converter
> available to convert from type: java.lang.String to the required type:
> java.lang.Boolean with value false
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
>        at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
>        at
> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
>        at
> org.apache.camel.spring.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:95)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
>        ... 27 more
> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
> converter available to convert from type: java.lang.String to the required
> type: java.lang.Boolean with value false
>        at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:142)
>        at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:125)
>        at
> org.apache.camel.util.CamelContextHelper.parseBoolean(CamelContextHelper.java:259)
>        at
> org.apache.camel.core.xml.AbstractCamelContextFactoryBean.initCamelContext(AbstractCamelContextFactoryBean.java:606)
>        at
> org.apache.camel.core.xml.AbstractCamelContextFactoryBean.afterPropertiesSet(AbstractCamelContextFactoryBean.java:268)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
>
> I'm using the onejar maven plugin (which embeeds jar files inside and uses a
> custom classloader to load the embedded libs). What can be the reason for
> this?
>
> /Johan
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-bootstrap-with-one-jar-plugin-fails-tp3345975p3345975.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/