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.

Reply via email to