You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by paramjyotsingh <pa...@gmail.com> on 2012/07/03 01:16:59 UTC

Camel Velocity Template throwing error

I am trying to use velocity template to  generate Email for error
notification with configuration as below:

<camel:route trace="true">
     <camel:from uri="direct:failureProcessing" />
     <camel:to
uri="velocity:test/template/sampleEmail.vm?propertiesFile=velocity.properties"/>
     <camel:to uri="direct:sendEmail" />
</camel:route>

But I somehow it is failing and I am not able to get complete stacktrace of
exception. I am getting a INFO message in log

org.apache.camel.component.velocity.VelocityEndpoint  ¬ Runtime : ran out of
parsers. Creating a new one.  Please increment the parser.pool.size
property. The current value is too small.

In velocity.properties i tried specifying parser.pool.size=20.

Does this message in log has something to do with failure.

Please help me I am stuck and I am not getting stackTrace to figure out
problem.

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Velocity Template throwing error

Posted by paramjyotsingh <pa...@gmail.com>.
What version of Camel and Velocity are you using? 
-- Camel: 2,8.1, velocity: 1.7
And what else have you configured in velocity.properties? 
-- No other property
And do you see this issue during high concurrency (eg processing many 
messages concurrently) 
-- I am just processing one file in one route.

Did it work before? 
-- No 

Do you run Camel inside a container such as Tomcat / ServiceMix / Karaf etc? 
-- No standalone Camel application in eclipse.

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388p5715411.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Velocity Template throwing error

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

What version of Camel and Velocity are you using?
And what else have you configured in velocity.properties?
And do you see this issue during high concurrency (eg processing many
messages concurrently)
Did it work before?
Do you run Camel inside a container such as Tomcat / ServiceMix / Karaf etc?


On Tue, Jul 3, 2012 at 1:16 AM, paramjyotsingh <pa...@gmail.com> wrote:
> I am trying to use velocity template to  generate Email for error
> notification with configuration as below:
>
> <camel:route trace="true">
>      <camel:from uri="direct:failureProcessing" />
>      <camel:to
> uri="velocity:test/template/sampleEmail.vm?propertiesFile=velocity.properties"/>
>      <camel:to uri="direct:sendEmail" />
> </camel:route>
>
> But I somehow it is failing and I am not able to get complete stacktrace of
> exception. I am getting a INFO message in log
>
> org.apache.camel.component.velocity.VelocityEndpoint  ¬ Runtime : ran out of
> parsers. Creating a new one.  Please increment the parser.pool.size
> property. The current value is too small.
>
> In velocity.properties i tried specifying parser.pool.size=20.
>
> Does this message in log has something to do with failure.
>
> Please help me I am stuck and I am not getting stackTrace to figure out
> problem.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388.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, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Velocity Template throwing error

Posted by paramjyotsingh <pa...@gmail.com>.
It is working for me now, I missed some commons jars initially.

Thanks for your reply.

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388p5715772.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Velocity Template throwing error

Posted by paramjyotsingh <pa...@gmail.com>.
sorry I was not able to do that because i am working in different VPN and i
don't have access to maven repository on internet and they have their own
repository.

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388p5715753.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Velocity Template throwing error

Posted by Christian Müller <ch...@gmail.com>.
Why you don't do it by your own? It's really simple with Maven:

Christian-Muellers-MacBook-Pro:camel-velocity cmueller$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]

[INFO]
------------------------------------------------------------------------
[INFO] Building Camel :: Velocity 2.11-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.4:tree (default-cli) @ camel-velocity
---
[INFO] org.apache.camel:camel-velocity:bundle:2.11-SNAPSHOT
[INFO] +- org.apache.camel:camel-core:jar:2.11-SNAPSHOT:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.apache.velocity:velocity:jar:1.7:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] |  \- commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.apache.camel:camel-test-spring:jar:2.11-SNAPSHOT:test
[INFO] |  +- org.apache.camel:camel-test:jar:2.11-SNAPSHOT:test
[INFO] |  +- org.apache.camel:camel-spring:jar:2.11-SNAPSHOT:test
[INFO] |  |  +- org.springframework:spring-context:jar:3.0.7.RELEASE:test
[INFO] |  |  |  +- org.springframework:spring-beans:jar:3.0.7.RELEASE:test
[INFO] |  |  |  +- org.springframework:spring-core:jar:3.0.7.RELEASE:test
[INFO] |  |  |  +-
org.springframework:spring-expression:jar:3.0.7.RELEASE:test
[INFO] |  |  |  \- org.springframework:spring-asm:jar:3.0.7.RELEASE:test
[INFO] |  |  +- org.springframework:spring-aop:jar:3.0.7.RELEASE:test
[INFO] |  |  |  \- aopalliance:aopalliance:jar:1.0:test
[INFO] |  |  \- org.springframework:spring-tx:jar:3.0.7.RELEASE:test
[INFO] |  \- org.springframework:spring-test:jar:3.0.7.RELEASE:test
(version managed from 3.1.1.RELEASE)
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.6:test
[INFO] |  \- log4j:log4j:jar:1.2.17:test
[INFO] +- junit:junit:jar:4.10:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- commons-io:commons-io:jar:1.4:test
[INFO] \- org.apache.velocity:velocity-tools:jar:2.0:test
[INFO]    +- commons-beanutils:commons-beanutils:jar:1.7.0:test
[INFO]    +- commons-digester:commons-digester:jar:1.8:test
[INFO]    +- commons-chain:commons-chain:jar:1.1:test
[INFO]    +- commons-logging:commons-logging:jar:1.1.1:test
[INFO]    +- commons-validator:commons-validator:jar:1.3.1:test
[INFO]    +- dom4j:dom4j:jar:1.1:test
[INFO]    +- oro:oro:jar:2.0.8:test
[INFO]    +- sslext:sslext:jar:1.2-0:test
[INFO]    +- org.apache.struts:struts-core:jar:1.3.8:test
[INFO]    |  \- antlr:antlr:jar:2.7.2:test
[INFO]    +- org.apache.struts:struts-taglib:jar:1.3.8:test
[INFO]    \- org.apache.struts:struts-tiles:jar:1.3.8:test
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 4.111s
[INFO] Finished at: Sat Jul 07 13:28:50 CEST 2012
[INFO] Final Memory: 9M/81M
[INFO]
------------------------------------------------------------------------

Best,
Christian

On Sat, Jul 7, 2012 at 12:00 AM, paramjyotsingh <pa...@gmail.com>wrote:

> My be i am missing some libraries.
>
> Can you please give me list of libraries you used for running this code.
>
> Thanks,
> Paramjyot Singh
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388p5715641.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel Velocity Template throwing error

Posted by paramjyotsingh <pa...@gmail.com>.
My be i am missing some libraries.

Can you please give me list of libraries you used for running this code.

Thanks,
Paramjyot Singh

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388p5715641.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Velocity Template throwing error

Posted by Henryk Konsek <he...@gmail.com>.
> I tried JUnit sample to test velocity in camel given by Claus at
> http://camel.apache.org/velocity.html
>
> And it is failing for me. I am getting following AssertionError:
>
> java.lang.AssertionError: mock://result Received message count. Expected:
> <1> but was: <0>

I copied the code to my IntelliJ and executed it - works like a charm
:) . No assertion error.

Could you provide us minimal Maven module with test which fails on
'mvn test'? I can't help you with bug I cannot reproduce :) .

Laters.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Camel Velocity Template throwing error

Posted by paramjyotsingh <pa...@gmail.com>.
Hi Henryk,

I tried JUnit sample to test velocity in camel given by Claus at
http://camel.apache.org/velocity.html

	private Exchange createLetter() {
	    Exchange exchange = context.getEndpoint("direct:a").createExchange();
	    Message msg = exchange.getIn();
	    msg.setHeader("firstName", "Claus");
	    msg.setHeader("lastName", "Ibsen");
	    msg.setHeader("item", "Camel in Action");
	    msg.setBody("PS: Next beer is on me, James");
	    return exchange;
	}

	@Test
	public void testVelocityLetter() throws Exception {
	    MockEndpoint mock = getMockEndpoint("mock:result");
	    mock.expectedMessageCount(1);
	    mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order
of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on
me, James");

	    template.send("direct:a", createLetter());

	    mock.assertIsSatisfied();
	}

	protected RouteBuilder createRouteBuilder() throws Exception {
	    return new RouteBuilder() {
	        public void configure() throws Exception {
	           
from("direct:a").to("velocity:com/test/letter.vm").to("mock:result");
	        }
	    };
	}


And it is failing for me. I am getting following AssertionError:

java.lang.AssertionError: mock://result Received message count. Expected:
<1> but was: <0>
	at
org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:1172)
	at
org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:1154)
	at
org.apache.camel.component.mock.MockEndpoint.doAssertIsSatisfied(MockEndpoint.java:369)
	at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:348)
	at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:336)
	at
com.test.TestVelocityTemplate.testVelocityLetter(TestVelocityTemplate.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47)
	at org.junit.rules.RunRules.evaluate(RunRules.java:18)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Let me know if this helps.


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388p5715561.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Velocity Template throwing error

Posted by Henryk Konsek <he...@gmail.com>.
> -- That is the problem, I am running Camel route and when i tried to
> retrieve  Exception Stack Trace in onException route, i am not getting any
> exception stack trace; just camel exception as I mentioned in my initial
> post.

But what "camel exception" exactly :) .

> -- I think  you are right it is just an INFO message in logs, but I was just
> wondering if this problem cause camel to fail route and stop further
> processing.

It should not affect the routing.

>  -- I am just trying to use velocity to generate email body, but my route
> keep failing and I am not getting any stack trace so can not pin point the
> actual exception/cause. I will try to give you a small test case with my
> route.

You can also try to debug your route with Eclipse/IntelliJ debugger's
breakpoint set to "Any exception".

Once again - minimal Maven case example will be appreciated and will
lead to faster problem resolution.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Camel Velocity Template throwing error

Posted by paramjyotsingh <pa...@gmail.com>.
Hi, 

> But I somehow it is failing and I am not able to get complete stacktrace
> of 
> exception. 

"To fail somehow" is a bit vague term :) . Could you elaborate what 
exactly is wrong with your message processing? 

-- That is the problem, I am running Camel route and when i tried to
retrieve  Exception Stack Trace in onException route, i am not getting any
exception stack trace; just camel exception as I mentioned in my initial
post.

> org.apache.camel.component.velocity.VelocityEndpoint  ¬ Runtime : ran out
> of 
> parsers. Creating a new one.  Please increment the parser.pool.size 
> property. 

This only slows down message processing since Velocity needs to create 
additional parsers. But the processing should work correctly. 

-- I think  you are right it is just an INFO message in logs, but I was just
wondering if this problem cause camel to fail route and stop further
processing.

Can you provider us more information? What exactly gets wrong? Ideally 
you could try to reproduce the problem with minimal Maven project with 
test case attached - then we will help you to fix the problem for 100% 
:) . 
 -- I am just trying to use velocity to generate email body, but my route
keep failing and I am not getting any stack trace so can not pin point the
actual exception/cause. I will try to give you a small test case with my
route.

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388p5715412.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Velocity Template throwing error

Posted by Henryk Konsek <he...@gmail.com>.
Hi,

> But I somehow it is failing and I am not able to get complete stacktrace of
> exception.

"To fail somehow" is a bit vague term :) . Could you elaborate what
exactly is wrong with your message processing?

> org.apache.camel.component.velocity.VelocityEndpoint  ¬ Runtime : ran out of
> parsers. Creating a new one.  Please increment the parser.pool.size
> property.

This only slows down message processing since Velocity needs to create
additional parsers. But the processing should work correctly.

Can you provider us more information? What exactly gets wrong? Ideally
you could try to reproduce the problem with minimal Maven project with
test case attached - then we will help you to fix the problem for 100%
:) .

Best regards.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com