You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claire <cl...@newgens.com.sg> on 2013/11/27 04:02:15 UTC

Using org.apache.camel.Exchange

Hi,

I used org.apache.camel.Exchange to modify my body but I got following
error:

Initialization of bean failed; nested exception is
java.lang.NoClassDefFoundError: org/apache/camel/Exchange

is there something I still need to define or add jar before I used Exchange?

Thanks,
Claire



--
View this message in context: http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Using org.apache.camel.Exchange

Posted by Claire <cl...@newgens.com.sg>.
Hi,

Thank you, this issues has resolved. Yes I left to add some dependencies.

Regards,
Claire



--
View this message in context: http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878p5744339.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Using org.apache.camel.Exchange

Posted by Claire <cl...@newgens.com.sg>.
it happens when I use exchange in my java. There's no such issue when I use
other method in java to get body and header of file.

I have already verified that jar file. It is aready there :(



--
View this message in context: http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878p5744072.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Using org.apache.camel.Exchange

Posted by Charles Moulliard <ch...@gmail.com>.
You still have a classpath issue. Verify that camel-core jar file is well
included


On Fri, Nov 29, 2013 at 3:46 AM, Claire <cl...@newgens.com.sg>wrote:

> I wonder if this because of the way I called Exchange? Here's the full
> exception.
>
> *Application context refresh failed
>
> (OsgiBundleXmlApplicationContext(bundle=com.swift.iplasa.flows.NTUCLite2Adapter-FromSWIFT-Exchange,
> config=osgibundle:/META-INF/spring/*.xml))
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> with name 'headerBean' defined in URL
> [bundle://331.0:0/META-INF/spring/routes.xml]: Initialization of bean
> failed; nested exception is java.lang.NoClassDefFoundError:
> org/apache/camel/Exchange*
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878p5744059.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>



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

Re: Using org.apache.camel.Exchange

Posted by Claire <cl...@newgens.com.sg>.
I wonder if this because of the way I called Exchange? Here's the full
exception.

*Application context refresh failed
(OsgiBundleXmlApplicationContext(bundle=com.swift.iplasa.flows.NTUCLite2Adapter-FromSWIFT-Exchange,
config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'headerBean' defined in URL
[bundle://331.0:0/META-INF/spring/routes.xml]: Initialization of bean
failed; nested exception is java.lang.NoClassDefFoundError:
org/apache/camel/Exchange*



--
View this message in context: http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878p5744059.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Using org.apache.camel.Exchange

Posted by Claire <cl...@newgens.com.sg>.
Charles,

I called bean the way you suggested me  but I can't add attribute name class
inside <camelContext>. Following is my xml.

<bean id="headerBean" class="com.ntuclite2.fromswift.ProcessHeader" />

    
    <camelContext xmlns="http://camel.apache.org/schema/spring">
<bean ref="headerBean" method="setHeaderIfNotNull" />
</camelContext>

but once I run it, I got following error inside log:

*Application context refresh failed
(OsgiBundleXmlApplicationContext(bundle=com.swift.iplasa.flows.NTUCLite2Adapter-FromSWIFT-Exchange,
config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'headerBean' defined in URL*

When I added class attribute for bean inside camelContext tag. I got this
error >>>>>> *Attribute 'class' is not allowed to appear in element 'bean'.*

Actually, the file might not have header, so I also want to setHeader when
header for that file is null.

Thank you very much for helping me out. I am newbie to this apache camel and
spring DSL. I am reading Camel in Action book but it's more applicable to
java xml. I wonder if you have any other resource which I can refer to deal
with apache camel in spring DSL.

Thanks,
Claire




--
View this message in context: http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878p5744058.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Using org.apache.camel.Exchange

Posted by Charles Moulliard <ch...@gmail.com>.
Can you change your route to specify the method that you would like to call
and in debug mode add  break at that line  if (headerName == null) to see
what you receive from Camel Exchange (In.body, in.headers ...) ?

<bean ref="headerBean" class="Test"/> --> <bean ref="headerBean" class="Test"
method="setHeaderIfNotNull"/>

NameOfTheHeader should correspond to the name of the header that you are
looking for.

public Class Test {

public void
setHeaderIfNotNull(Exchange exchange) {

    String headerName = exchange.getIn().getHeader("NameOfTheHeader");
if (headerName == null) {

			throw new RuntimeException("Impossible to set header to value:
headerName is null!");
		}
		if (value != null) {
			exchange.getIn().setHeader(headerName, value);
		}
	}
	
}




On Thu, Nov 28, 2013 at 9:28 AM, Claire <cl...@newgens.com.sg>wrote:

> Charles,
>
> Thank you for reply.
>
> There's a file I would like to read body and specify some tag as header for
> that file. I would also want to get content of that file as body.
>
> Following is my xml file and java in which I used exchange:
> testJava.java
> <http://camel.465427.n5.nabble.com/file/n5743996/testJava.java>
> testRoute.xml
> <http://camel.465427.n5.nabble.com/file/n5743996/testRoute.xml>
>
> But still no luck to use exchange to play around those content for the
> file.
>
> Thanks,
> Claire
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878p5743996.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>



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

Re: Using org.apache.camel.Exchange

Posted by Claire <cl...@newgens.com.sg>.
Charles,

Thank you for reply.

There's a file I would like to read body and specify some tag as header for
that file. I would also want to get content of that file as body.

Following is my xml file and java in which I used exchange:
testJava.java
<http://camel.465427.n5.nabble.com/file/n5743996/testJava.java>  
testRoute.xml
<http://camel.465427.n5.nabble.com/file/n5743996/testRoute.xml>  

But still no luck to use exchange to play around those content for the file.

Thanks,
Claire





--
View this message in context: http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878p5743996.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Using org.apache.camel.Exchange

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

Could you please share with us what you would like to do (project -->
routes --> process to be applied) otherwise that will not be possible ? As
your email contains two questions not related how would you
like
 that we help you ?

Remarks : Exchange class of Camel is part of camel-core jar file

Regards,

Charles


On Wed, Nov 27, 2013 at 4:02 AM, Claire <cl...@newgens.com.sg>wrote:

> Hi,
>
> I used org.apache.camel.Exchange to modify my body but I got following
> error:
>
> Initialization of bean failed; nested exception is
> java.lang.NoClassDefFoundError: org/apache/camel/Exchange
>
> is there something I still need to define or add jar before I used
> Exchange?
>
> Thanks,
> Claire
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Using-org-apache-camel-Exchange-tp5743878.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>



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