Quantcast

<throwException ref="" /> with osgi service reference

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

<throwException ref="" /> with osgi service reference

m.jimen.blazquez
Hi,

I am trying to rethrow an excepcion in a <doTry><doCatch>.

When I have this code:

<bean id="forced" class="java.lang.IllegalArgumentException">
         <constructor-arg index="0" value="This is forced" /> 
</bean>

<camelContext id="camel-route" xmlns="http://camel.apache.org/schema/spring">

    <route id="routeId">
            <from uri="cxfrs:/servicios?resourceClasses=myPackage.myEndpointService" />
            <doTry>
                    <bean ref="ref1" method="start">
               <doCatch>
                           <exception>java.lang.Exception</exception>
                           <throwException ref="forced" />
                    </doCatch>
            </doTry>
        </route>
</camelContext>

The exception is rethrown normally, but if I want the exception to be rethrown by my own class registered as an osgi service:

<osgi:reference id="exceptionManager"
        interface="myOtherPackage.ExceptionManager" />

<camelContext id="camel-route" xmlns="http://camel.apache.org/schema/spring">

    <route id="routeId">
            <from uri="cxfrs:/servicios?resourceClasses=myPackage.myEndpointService" />
            <doTry>
                    <bean ref="ref1" method="start">
               <doCatch>
                           <exception>java.lang.Exception</exception>
                           <throwException ref="exceptionManager" />
                    </doCatch>
            </doTry>
        </route>
</camelContext>

public interface ExceptionManager{

        public void throwException(Exception e) throws Exception;
}

I get the following exception:

Caused by: java.lang.IllegalArgumentException: exception or ref must be specified on: ThrowExc<throwException ref="exceptionManager" />eption[ref:exceptionManager]
at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:296)
        at org.apache.camel.model.ThrowExceptionDefinition.createProcessor(ThrowExceptionDefinition.java:70)
        at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:391)
        at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:130)


Am I missing something? or this way of rethrowing only works with local beans and no with osgi service references?

kindest regards
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: <throwException ref="" /> with osgi service reference

Claus Ibsen-2
ThrowException must be a Throwable, not an interface.



On Fri, May 18, 2012 at 9:13 AM, m.jimen.blazquez
<[hidden email]> wrote:

> Hi,
>
> I am trying to rethrow an excepcion in a <doTry><doCatch>.
>
> When I have this code:
>
> <bean id="forced" class="java.lang.IllegalArgumentException">
>         <constructor-arg index="0" value="This is forced" />
> </bean>
>
> <camelContext id="camel-route"
> xmlns="http://camel.apache.org/schema/spring">
>
>    <route id="routeId">
>            <from
> uri="cxfrs:/servicios?resourceClasses=myPackage.myEndpointService" />
>            <doTry>
>                    <bean ref="ref1" method="start">
>                    <doCatch>
>                           <exception>java.lang.Exception</exception>
>                           <throwException ref="forced" />
>                    </doCatch>
>            </doTry>
>        </route>
> </camelContext>
>
> The exception is rethrown normally, but if I want the exception to be
> rethrown by my own class registered as an osgi service:
>
> <osgi:reference id="exceptionManager"
>        interface="myOtherPackage.ExceptionManager" />
>
> <camelContext id="camel-route"
> xmlns="http://camel.apache.org/schema/spring">
>
>    <route id="routeId">
>            <from
> uri="cxfrs:/servicios?resourceClasses=myPackage.myEndpointService" />
>            <doTry>
>                    <bean ref="ref1" method="start">
>                    <doCatch>
>                           <exception>java.lang.Exception</exception>
>                           <throwException ref="exceptionManager" />
>                    </doCatch>
>            </doTry>
>        </route>
> </camelContext>
>
> public interface ExceptionManager{
>
>        public void throwException(Exception e) throws Exception;
> }
>
> I get the following exception:
>
> Caused by: java.lang.IllegalArgumentException: exception or ref must be
> specified on: ThrowExc<throwException ref="exceptionManager"
> />eption[ref:exceptionManager]
> at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:296)
>        at
> org.apache.camel.model.ThrowExceptionDefinition.createProcessor(ThrowExceptionDefinition.java:70)
>        at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:391)
>        at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:130)
>
>
> Am I missing something? or this way of rethrowing only works with local
> beans and no with osgi service references?
>
> kindest regards
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/throwException-ref-with-osgi-service-reference-tp5711762.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Loading...