You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vinay <vi...@yahoo.com> on 2013/07/18 07:07:02 UTC

camel error with simple program with camel-core-2.11.1.jar

Hi All,

I am new to camel, here is what I am trying and is giving me exception.....

$groovy -v
Groovy Version: 2.1.3 JVM: 1.7.0_11 Vendor: Oracle Corporation OS: Linux
$groovy  CallCallista1.groovy

give following exception...............
[main] INFO camelLogger - Exchange[ExchangePattern:InOut, BodyType:String,
Body
test message]
Caught: java.lang.ClassCastException: java.lang.Boolean cannot be cast to
java.
ang.String
java.lang.ClassCastException: java.lang.Boolean cannot be cast to
java.lang.Str
ng
        at
org.apache.camel.impl.DefaultCamelContext.getProperty(DefaultCamelCo
text.java:2594)
        at
org.apache.camel.util.MessageHelper.extractBodyForLogging(MessageHel
er.java:161)
        at
org.apache.camel.util.MessageHelper.extractBodyForLogging(MessageHel
er.java:144)
        at
org.apache.camel.impl.DefaultMessage.toString(DefaultMessage.java:46

        at
org.apache.camel.impl.DefaultExchange.toString(DefaultExchange.java:
0)
        at CallCallista1.run(CallCallista1.groovy:25)


and, here is program.......
=============================================
@Grab('org.apache.camel:camel-core:')
@Grab('org.slf4j:slf4j-simple:')
import org.apache.camel.*
import org.apache.camel.impl.*
import org.apache.camel.builder.*

class MyRouteBuilder extends org.apache.camel.builder.RouteBuilder {
  void configure() {
    from("direct://foo")
     .to("log://camelLogger?level=INFO")
     .to("mock://result?retainLast=10")
  }
}

def mrb = new MyRouteBuilder()
def ctx = new org.apache.camel.impl.DefaultCamelContext()
ctx.getProperties().put(Exchange.LOG_DEBUG_BODY_STREAMS, true);
ctx.addRoutes mrb
ctx.start()
p = ctx.createProducerTemplate()
p.sendBody("direct:foo", ExchangePattern.InOut, "test message")

e = ctx.getEndpoint("mock://result?retainLast=10");
def ex = e.exchanges
println "INFO> ${ex.first()}"
println "INFO> ${ex.first().getException()}"





--
View this message in context: http://camel.465427.n5.nabble.com/camel-error-with-simple-program-with-camel-core-2-11-1-jar-tp5735829.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel error with simple program with camel-core-2.11.1.jar

Posted by vinay <vi...@yahoo.com>.
Hi Willem,

Sorry about the delayed response....

Groovy Version: 2.1.3 JVM: 1.7.0_11 Vendor: Oracle Corporation OS: Linux

Also, i get following warning.....
WARNING: Module [camel-groovy] - Unable to load extension class [class
org.apache.camel.groovy.extend.CamelGroovyMethods] due to
[org/apache/camel/Expression
Maybe this module is not supported by your JVM version.



--
View this message in context: http://camel.465427.n5.nabble.com/camel-error-with-simple-program-with-camel-core-2-11-1-jar-tp5735829p5736248.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel error with simple program with camel-core-2.11.1.jar

Posted by Willem jiang <wi...@gmail.com>.
Which version JDK are you using?


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem




On Monday, July 22, 2013 at 12:33 PM, vinay wrote:

> update......
>  
> I get following warning when starting camel...............
>  
> WARNING: Module [camel-groovy] - Unable to load extension class [class
> org.apach
> e.camel.groovy.extend.CamelGroovyMethods] due to
> [org/apache/camel/Expression].
> Maybe this module is not supported by your JVM version.
>  
> regards,
> Vinay
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-error-with-simple-program-with-camel-core-2-11-1-jar-tp5735829p5736000.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: camel error with simple program with camel-core-2.11.1.jar

Posted by vinay <vi...@yahoo.com>.
update......

I get following warning when starting camel...............

WARNING: Module [camel-groovy] - Unable to load extension class [class
org.apach
e.camel.groovy.extend.CamelGroovyMethods] due to
[org/apache/camel/Expression].
Maybe this module is not supported by your JVM version.

regards,
Vinay



--
View this message in context: http://camel.465427.n5.nabble.com/camel-error-with-simple-program-with-camel-core-2-11-1-jar-tp5735829p5736000.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel error with simple program with camel-core-2.11.1.jar

Posted by vinay <vi...@yahoo.com>.
Hi Claus,

Sorry about the delayed response....

I tried, adding "{Exchange it -> .....}" but didn't worked.....

    .process ({ Exchange it -> println "in processor: ${it.in.body}"
                it.out.body = it.in.body.toUpperCase()
              } )

following works...

     .process ({ Exchange it -> println "in processor: ${it.in.body}"
                 it.out.body = it.in.body.toUpperCase()
               } as org.apache.camel.Processor)



any suggestions......

thanks,
Vinay





--
View this message in context: http://camel.465427.n5.nabble.com/camel-error-with-simple-program-with-camel-core-2-11-1-jar-tp5735829p5735990.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel error with simple program with camel-core-2.11.1.jar

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

Yeah wonder why it cannot infer it as Exchange?

You can take a peak at the unit tests of camel-groovy to see some examples
https://github.com/apache/camel/tree/master/components/camel-groovy

And the docs for groovy dsl is here
https://camel.apache.org/groovy-dsl.html

Though you can try with

.process{ Exchange e -> println e.in.body}




On Fri, Jul 19, 2013 at 4:15 AM, vinay <vi...@yahoo.com> wrote:
> Thanks Claus, that fixed it.....but have another problem
>
> now, I changed route as follows and I get exception for .process closure
> class MyRouteBuilder extends org.apache.camel.builder.RouteBuilder {
>   void configure() {
>     from("direct://foo")
>      .to("log://camelLogger?level=INFO")
>      .process { println it.in.body }
>      .to("mock://result?retainLast=10")
>   }
> }
>
> Caught: groovy.lang.MissingMethodException: No signature of method:
> org.apache.camel.model.RouteDefinition.process() is applicable for argument
> types: (MyRouteBuilder$_configure_closure1) values:
> [MyRouteBuilder$_configure_closure1@6af5e140
> ]
> Possible solutions: process(org.apache.camel.Processor),
> processRef(java.lang.String)
> groovy.lang.MissingMethodException: No signature of method:
> org.apache.camel.mod
> el.RouteDefinition.process() is applicable for argument types:
> (MyRouteBuilder$_
> configure_closure1) values: [MyRouteBuilder$_configure_closure1@6af5e140]
> Possible solutions: process(org.apache.camel.Processor),
> processRef(java.lang.St
> ring)
>         at MyRouteBuilder.configure(CallCallista1.groovy:10)
>         at
> org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:322)
>         at
> org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:276)
>         at
> org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:262)
>         at
> org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:650)
>         at org.apache.camel.CamelContext$addRoutes.call(Unknown Source)
>         at CallCallista1.run(CallCallista1.groovy:20)
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-error-with-simple-program-with-camel-core-2-11-1-jar-tp5735829p5735880.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

Re: camel error with simple program with camel-core-2.11.1.jar

Posted by vinay <vi...@yahoo.com>.
Thanks Claus, that fixed it.....but have another problem

now, I changed route as follows and I get exception for .process closure
class MyRouteBuilder extends org.apache.camel.builder.RouteBuilder {
  void configure() {
    from("direct://foo")
     .to("log://camelLogger?level=INFO")
     .process { println it.in.body }
     .to("mock://result?retainLast=10")
  }
}

Caught: groovy.lang.MissingMethodException: No signature of method:
org.apache.camel.model.RouteDefinition.process() is applicable for argument
types: (MyRouteBuilder$_configure_closure1) values:
[MyRouteBuilder$_configure_closure1@6af5e140
]
Possible solutions: process(org.apache.camel.Processor),
processRef(java.lang.String)
groovy.lang.MissingMethodException: No signature of method:
org.apache.camel.mod
el.RouteDefinition.process() is applicable for argument types:
(MyRouteBuilder$_
configure_closure1) values: [MyRouteBuilder$_configure_closure1@6af5e140]
Possible solutions: process(org.apache.camel.Processor),
processRef(java.lang.St
ring)
        at MyRouteBuilder.configure(CallCallista1.groovy:10)
        at
org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:322)
        at
org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:276)
        at
org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:262)
        at
org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:650)
        at org.apache.camel.CamelContext$addRoutes.call(Unknown Source)
        at CallCallista1.run(CallCallista1.groovy:20)



--
View this message in context: http://camel.465427.n5.nabble.com/camel-error-with-simple-program-with-camel-core-2-11-1-jar-tp5735829p5735880.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel error with simple program with camel-core-2.11.1.jar

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

Try with

ctx.getProperties().put(Exchange.LOG_DEBUG_BODY_STREAMS, "true");

On Thu, Jul 18, 2013 at 7:07 AM, vinay <vi...@yahoo.com> wrote:
> Hi All,
>
> I am new to camel, here is what I am trying and is giving me exception.....
>
> $groovy -v
> Groovy Version: 2.1.3 JVM: 1.7.0_11 Vendor: Oracle Corporation OS: Linux
> $groovy  CallCallista1.groovy
>
> give following exception...............
> [main] INFO camelLogger - Exchange[ExchangePattern:InOut, BodyType:String,
> Body
> test message]
> Caught: java.lang.ClassCastException: java.lang.Boolean cannot be cast to
> java.
> ang.String
> java.lang.ClassCastException: java.lang.Boolean cannot be cast to
> java.lang.Str
> ng
>         at
> org.apache.camel.impl.DefaultCamelContext.getProperty(DefaultCamelCo
> text.java:2594)
>         at
> org.apache.camel.util.MessageHelper.extractBodyForLogging(MessageHel
> er.java:161)
>         at
> org.apache.camel.util.MessageHelper.extractBodyForLogging(MessageHel
> er.java:144)
>         at
> org.apache.camel.impl.DefaultMessage.toString(DefaultMessage.java:46
>
>         at
> org.apache.camel.impl.DefaultExchange.toString(DefaultExchange.java:
> 0)
>         at CallCallista1.run(CallCallista1.groovy:25)
>
>
> and, here is program.......
> =============================================
> @Grab('org.apache.camel:camel-core:')
> @Grab('org.slf4j:slf4j-simple:')
> import org.apache.camel.*
> import org.apache.camel.impl.*
> import org.apache.camel.builder.*
>
> class MyRouteBuilder extends org.apache.camel.builder.RouteBuilder {
>   void configure() {
>     from("direct://foo")
>      .to("log://camelLogger?level=INFO")
>      .to("mock://result?retainLast=10")
>   }
> }
>
> def mrb = new MyRouteBuilder()
> def ctx = new org.apache.camel.impl.DefaultCamelContext()
> ctx.getProperties().put(Exchange.LOG_DEBUG_BODY_STREAMS, true);
> ctx.addRoutes mrb
> ctx.start()
> p = ctx.createProducerTemplate()
> p.sendBody("direct:foo", ExchangePattern.InOut, "test message")
>
> e = ctx.getEndpoint("mock://result?retainLast=10");
> def ex = e.exchanges
> println "INFO> ${ex.first()}"
> println "INFO> ${ex.first().getException()}"
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-error-with-simple-program-with-camel-core-2-11-1-jar-tp5735829.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