You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by j_h_scheufen <ja...@sungard.com> on 2010/03/19 18:12:08 UTC

JPA consumer starts up, but is not polling

Hi all,

I really don't know what could be going wrong in my JPA scenario. I'm using
the following route:

		from("jpa:com.infinity.bpm.jpa.beans.TransactionTracker")
		.to("bean:transactionMessageTranslator")
		.choice()
			// the presence of the header field "correlationMap" indicates that the
transaction message
			// is intended to update an existing transaction process.
			.when( header("correlationMap").isNotNull() )
				//.to("bean:searchTransactionActivity")
				.to("bean:transactionActivitySearch")
			// Otherwise a new transaction process needs to be created
			.otherwise()
				.setHeader("processID", constant("TransactionProcessing"))
		.end()
		.to("activemq:queue:ApplicationQueue?jmsMessageType=Object");

When I load the spring application context in a unit test, everything is
fine. I have SQL output turned on and I see the JPA consumer polling the DB
and triggering the route when my test case inserts a line into the table:

Hibernate: select transactio0_.id as id0_, transactio0_.plan_id as plan2_0_,
transactio0_.status as status0_, transactio0_.trans_id as trans4_0_ from
db.workqueue transactio0_
Hibernate: select transactio0_.id as id0_, transactio0_.plan_id as plan2_0_,
transactio0_.status as status0_, transactio0_.trans_id as trans4_0_ from
db.workqueue transactio0_
Hibernate: select transactio0_.id as id0_, transactio0_.plan_id as plan2_0_,
transactio0_.status as status0_, transactio0_.trans_id as trans4_0_ from
db.workqueue transactio0_
Hibernate: select id from db.workqueue where id =? for update
12:58:14 INFO  [aComponent] Tracer                    -
a77f0f0b-f858-4a65-940d-cf1a3439ba75 >>> (route1)
from(jpa://com.infinity.bpm.jpa.beans.TransactionTracker) -->
bean://transactionMessageTranslator <<< Pattern:InOnly,
Headers:{CamelJpaTemplate=org.springframework.orm.jpa.JpaTemplate@161e946},
BodyType:com.infinity.bpm.jpa.beans.TransactionTracker,
Body:com.infinity.bpm.jpa.beans.TransactionTracker@e16021
12:58:14 INFO  [aComponent] Tracer                    -
a77f0f0b-f858-4a65-940d-cf1a3439ba75 >>> (route1)
bean://transactionMessageTranslator --> choice <<< Pattern:InOnly,
Headers:{CamelJpaTemplate=org.springframework.orm.jpa.JpaTemplate@161e946},
BodyType:java.util.HashMap, Body:{status=null, transId=242424, planId=34534}
12:58:14 INFO  [aComponent] Tracer                    -
a77f0f0b-f858-4a65-940d-cf1a3439ba75 >>> (route1) choice -->
setHeader[processID] <<< Pattern:InOnly,
Headers:{CamelJpaTemplate=org.springframework.orm.jpa.JpaTemplate@161e946},
BodyType:java.util.HashMap, Body:{status=null, transId=242424, planId=34534}

So far so good. Now I deploy everything on a local Tomcat instance with the
only difference being that the Spring context is now bootstrapped via the
web context loader. All beans including the CamelContext get loaded without
problems, but then the JPA consumer is just sitting there and is not polling
the DB at all, i.e. there's no SQL trace of the consumer ever querying the
DB. I even enabled JMX and used JConsole to look into the camel MBeans and
all looks fine.

Does anyone have an idea what the reason could be for the JPA consumer not
to be polling in the Tomcat environment? There are no exceptions whatsoever
...

Any thought that I could investigate would help right now ...

Thanks a lot!


-- 
View this message in context: http://old.nabble.com/JPA-consumer-starts-up%2C-but-is-not-polling-tp27951000p27951000.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JPA consumer starts up, but is not polling

Posted by j_h_scheufen <ja...@sungard.com>.
Claus,

I was using Camel 2.1.0. Switched to 2.2.0 now and I can confirm that the
error is now logged correctly.

Thanks again and have a nice weekend!

Jan

-----------------------------
10:21:58 ERROR [aComponent] JpaConsumer               - Consumer
Consumer[jpa://com.infinity.bpm.jpa.beans.TransactionTracker?consumer.initialDelay=5000]
could not poll endpoint:
jpa://com.infinity.bpm.jpa.beans.TransactionTracker?consumer.initialDelay=5000
caused by: antlr/ANTLRException
java.lang.NoClassDefFoundError: antlr/ANTLRException
	at
org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:58)
	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:98)
	at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
	at
org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
	at
org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
	at
org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
	at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)
	at
org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.springframework.orm.jpa.JpaTemplate$CloseSuppressingInvocationHandler.invoke(JpaTemplate.java:404)
	at $Proxy105.createQuery(Unknown Source)
	at
org.apache.camel.component.jpa.QueryBuilder$1.makeQueryObject(QueryBuilder.java:44)
	at
org.apache.camel.component.jpa.QueryBuilder.createQuery(QueryBuilder.java:152)
	at
org.apache.camel.component.jpa.JpaConsumer$1.doInJpa(JpaConsumer.java:83)
...
-- 
View this message in context: http://old.nabble.com/JPA-consumer-starts-up%2C-but-is-not-polling-tp27951000p28119549.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JPA consumer starts up, but is not polling

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

I dont know what version of Camel you are using, but we have recently
fixed the scheduled polling consumer to catch java.lang.Error and have
that logged as well
https://issues.apache.org/activemq/browse/CAMEL-2339

That should help catch those NoClassDefFoundError and other errors being thrown.
So could you try with Camel 2.2.0 ?

You should see this in the log now:

            } catch (Error e) {
                // log the fatal error as the JDK itself may not log it for us
                log.fatal("Consumer " + this +  " could not poll
endpoint: " + getEndpoint().getEndpointUri() + " caused by: " +
e.getMessage(), e);
                throw e;
            }



On Tue, Mar 30, 2010 at 3:05 PM, j_h_scheufen
<ja...@sungard.com> wrote:
>
> Claus,
>
> thanks for the hint. I implemented a regular Spring-based DAO layer and hit
> a NoClassDefFoundError. It turns out it wasn't the JPA configuration at all;
> I missed the transitive dependency on ANTLR. Once that was on the classpath,
> the JPA consumer started polling.
>
> I don't have the resources to investigate this further, but I surely wished,
> the Camel JPA polling consumer would've been a little more verbose. Could it
> be that it's swallowing an underlying exception somewhere?
>
> Thanks again and keep up the good work!
>
> Jan
> --
> View this message in context: http://old.nabble.com/JPA-consumer-starts-up%2C-but-is-not-polling-tp27951000p28082231.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: JPA consumer starts up, but is not polling

Posted by j_h_scheufen <ja...@sungard.com>.
Claus,

thanks for the hint. I implemented a regular Spring-based DAO layer and hit
a NoClassDefFoundError. It turns out it wasn't the JPA configuration at all;
I missed the transitive dependency on ANTLR. Once that was on the classpath,
the JPA consumer started polling.

I don't have the resources to investigate this further, but I surely wished,
the Camel JPA polling consumer would've been a little more verbose. Could it
be that it's swallowing an underlying exception somewhere?

Thanks again and keep up the good work!

Jan
-- 
View this message in context: http://old.nabble.com/JPA-consumer-starts-up%2C-but-is-not-polling-tp27951000p28082231.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JPA consumer starts up, but is not polling

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

Try to get a JPA example working on Tomcat without Camel.
JPA is not that trivial to get working on various contains as it got
classloading tricks to do for the JPA stuff.
So I would look for a JPA + Tomcat. Maybe there is a example WAR ready
to just try out.

And if you use Hibernate for JPA then check Hibernate docs to get it
working in Tomcat.


On Fri, Mar 19, 2010 at 6:12 PM, j_h_scheufen
<ja...@sungard.com> wrote:
>
> Hi all,
>
> I really don't know what could be going wrong in my JPA scenario. I'm using
> the following route:
>
>                from("jpa:com.infinity.bpm.jpa.beans.TransactionTracker")
>                .to("bean:transactionMessageTranslator")
>                .choice()
>                        // the presence of the header field "correlationMap" indicates that the
> transaction message
>                        // is intended to update an existing transaction process.
>                        .when( header("correlationMap").isNotNull() )
>                                //.to("bean:searchTransactionActivity")
>                                .to("bean:transactionActivitySearch")
>                        // Otherwise a new transaction process needs to be created
>                        .otherwise()
>                                .setHeader("processID", constant("TransactionProcessing"))
>                .end()
>                .to("activemq:queue:ApplicationQueue?jmsMessageType=Object");
>
> When I load the spring application context in a unit test, everything is
> fine. I have SQL output turned on and I see the JPA consumer polling the DB
> and triggering the route when my test case inserts a line into the table:
>
> Hibernate: select transactio0_.id as id0_, transactio0_.plan_id as plan2_0_,
> transactio0_.status as status0_, transactio0_.trans_id as trans4_0_ from
> db.workqueue transactio0_
> Hibernate: select transactio0_.id as id0_, transactio0_.plan_id as plan2_0_,
> transactio0_.status as status0_, transactio0_.trans_id as trans4_0_ from
> db.workqueue transactio0_
> Hibernate: select transactio0_.id as id0_, transactio0_.plan_id as plan2_0_,
> transactio0_.status as status0_, transactio0_.trans_id as trans4_0_ from
> db.workqueue transactio0_
> Hibernate: select id from db.workqueue where id =? for update
> 12:58:14 INFO  [aComponent] Tracer                    -
> a77f0f0b-f858-4a65-940d-cf1a3439ba75 >>> (route1)
> from(jpa://com.infinity.bpm.jpa.beans.TransactionTracker) -->
> bean://transactionMessageTranslator <<< Pattern:InOnly,
> Headers:{CamelJpaTemplate=org.springframework.orm.jpa.JpaTemplate@161e946},
> BodyType:com.infinity.bpm.jpa.beans.TransactionTracker,
> Body:com.infinity.bpm.jpa.beans.TransactionTracker@e16021
> 12:58:14 INFO  [aComponent] Tracer                    -
> a77f0f0b-f858-4a65-940d-cf1a3439ba75 >>> (route1)
> bean://transactionMessageTranslator --> choice <<< Pattern:InOnly,
> Headers:{CamelJpaTemplate=org.springframework.orm.jpa.JpaTemplate@161e946},
> BodyType:java.util.HashMap, Body:{status=null, transId=242424, planId=34534}
> 12:58:14 INFO  [aComponent] Tracer                    -
> a77f0f0b-f858-4a65-940d-cf1a3439ba75 >>> (route1) choice -->
> setHeader[processID] <<< Pattern:InOnly,
> Headers:{CamelJpaTemplate=org.springframework.orm.jpa.JpaTemplate@161e946},
> BodyType:java.util.HashMap, Body:{status=null, transId=242424, planId=34534}
>
> So far so good. Now I deploy everything on a local Tomcat instance with the
> only difference being that the Spring context is now bootstrapped via the
> web context loader. All beans including the CamelContext get loaded without
> problems, but then the JPA consumer is just sitting there and is not polling
> the DB at all, i.e. there's no SQL trace of the consumer ever querying the
> DB. I even enabled JMX and used JConsole to look into the camel MBeans and
> all looks fine.
>
> Does anyone have an idea what the reason could be for the JPA consumer not
> to be polling in the Tomcat environment? There are no exceptions whatsoever
> ...
>
> Any thought that I could investigate would help right now ...
>
> Thanks a lot!
>
>
> --
> View this message in context: http://old.nabble.com/JPA-consumer-starts-up%2C-but-is-not-polling-tp27951000p27951000.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus