You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by easyl <ea...@gmail.com> on 2010/03/26 14:10:03 UTC

sudden NullPointerException from ActiveMQSessionExecutor.wakeup

AMQ 4.1.2 embedded in Geronimo 2.1.3

setup in deployment plan with 
<config-property-setting name="ServerUrl">
vm://localhost?async=true&amp;jms.asyncDispatch=false&amp;jms.copyMessageOnSend=false&amp;jms.watchTopicAdvisories=false
</config-property-setting>
			
there are 6 different Queues listened by MDBs which may send messages to
each other (almost with sync send/reply).

When the message traffic get huge, I would got such NPE

Exception in thread "VMTransport" java.lang.NullPointerException
	at
org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:76)
	at
org.apache.activemq.ActiveMQSessionExecutor.execute(ActiveMQSessionExecutor.java:61)
	at org.apache.activemq.ActiveMQSession.dispatch(ActiveMQSession.java:1344)
	at
org.apache.activemq.ActiveMQConnection.onCommand(ActiveMQConnection.java:1485)
	at
org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:95)
	at
org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:65)
	at
org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:201)
	at
org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:120)
	at
org.apache.activemq.thread.PooledTaskRunner.access$100(PooledTaskRunner.java:26)
	at
org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
	at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
	at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
	at java.lang.Thread.run(Thread.java:619)


then some messages will be stalled in queue (checked with jconsole).

what does the NPE mean? 
how can I avoid the problem?

-- 
View this message in context: http://n3.nabble.com/sudden-NullPointerException-from-ActiveMQSessionExecutor-wakeup-tp676485p676485.html
Sent from the Users mailing list archive at Nabble.com.

Re: sudden NullPointerException from ActiveMQSessionExecutor.wakeup

Posted by easyl <ea...@gmail.com>.

kevan wrote:
> 
> It sounded like you can also avoid using asyncDispatch=false. If you have
> slow consumers, this might be a problem for you...
> 
yes, I set asyncDispatch=false with vm:// protocol, and the NPE happens less
possible,,,but still happens.
Now I change to use tcp:// protocol and run test, till now the problem did
not happen yet.
Is that only "VM"Transport problem?


kevan wrote:
> 
> Would you be able to build a patched version of ActiveMQ? Would also like
> to know if that fixes your problem...
> 
I would like to, but actually I am using IBM WASCE (based on Geronimo) and
modifying server side code is almost not allowed (not technically). I would
only try to find a workaround.

btw. i created a ticket here
https://issues.apache.org/activemq/browse/AMQ-2679

really thanks for your help :)
-- 
View this message in context: http://n3.nabble.com/sudden-NullPointerException-from-ActiveMQSessionExecutor-wakeup-tp676485p683549.html
Sent from the Users mailing list archive at Nabble.com.

Re: sudden NullPointerException from ActiveMQSessionExecutor.wakeup

Posted by Kevan Miller <ke...@gmail.com>.
On Mar 29, 2010, at 8:27 AM, easyl wrote:

> 
> hallo kevan,
> 
> what do you mean close() exactly?
> I just use following send/reply pattern.

I meant something like Connection.close() or Session.close(). I'm not 100% certain, but I think the codepath that is causing the NullPointerException is driven by close() (or cleanup processing after an error has occurred). Avoiding the connection.close() call, might avoid your error. Coulc you cache/reuse the Connection/Session/Consumer, rather than creating/tearing them down? You might be able to avoid the problem, this way. 

It sounded like you can also avoid using asyncDispatch=false. If you have slow consumers, this might be a problem for you...

Would you be able to build a patched version of ActiveMQ? Would also like to know if that fixes your problem...

--kevan


Re: sudden NullPointerException from ActiveMQSessionExecutor.wakeup

Posted by easyl <ea...@gmail.com>.
hallo kevan,

what do you mean close() exactly?
I just use following send/reply pattern.

however the consumer (receiver) may do a long running tasks.
(consumers are slower than producer.)


 
> connection = factory.createQueueConnection();
> connection.start();
> 
> session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
> sender = session.createSender(requestQueue);
> 
> replyQueue = session.createTemporaryQueue();
> 
> jmsRequestMessage = session.createTextMessage();
> 
> sender.send(jmsRequestMessage, DeliveryMode.NON_PERSISTENT,
> Message.DEFAULT_PRIORITY, timeToLive);
> 
> receiver = session.createReceiver(replyQueue);
> jmsReplyMessage = receiver.receive();
> 
> connection.close();
> 
-- 
View this message in context: http://n3.nabble.com/sudden-NullPointerException-from-ActiveMQSessionExecutor-wakeup-tp676485p683291.html
Sent from the Users mailing list archive at Nabble.com.

Re: sudden NullPointerException from ActiveMQSessionExecutor.wakeup

Posted by easyl <ea...@gmail.com>.
however with setting jms.asyncDispatch=false I did not get the NPE yet
http://activemq.apache.org/consumer-dispatch-async.html

-- 
View this message in context: http://n3.nabble.com/sudden-NullPointerException-from-ActiveMQSessionExecutor-wakeup-tp676485p680662.html
Sent from the Users mailing list archive at Nabble.com.

Re: sudden NullPointerException from ActiveMQSessionExecutor.wakeup

Posted by Kevan Miller <ke...@gmail.com>.
On Mar 26, 2010, at 9:10 AM, easyl wrote:

> 
> AMQ 4.1.2 embedded in Geronimo 2.1.3
> 
> setup in deployment plan with 
> <config-property-setting name="ServerUrl">
> vm://localhost?async=true&amp;jms.asyncDispatch=false&amp;jms.copyMessageOnSend=false&amp;jms.watchTopicAdvisories=false
> </config-property-setting>
> 			
> there are 6 different Queues listened by MDBs which may send messages to
> each other (almost with sync send/reply).
> 
> When the message traffic get huge, I would got such NPE
> 
> Exception in thread "VMTransport" java.lang.NullPointerException
> 	at
> org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:76)
> 	at
> org.apache.activemq.ActiveMQSessionExecutor.execute(ActiveMQSessionExecutor.java:61)
> 	at org.apache.activemq.ActiveMQSession.dispatch(ActiveMQSession.java:1344)
> 	at
> org.apache.activemq.ActiveMQConnection.onCommand(ActiveMQConnection.java:1485)
> 	at
> org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:95)
> 	at
> org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:65)
> 	at
> org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:201)
> 	at
> org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:120)
> 	at
> org.apache.activemq.thread.PooledTaskRunner.access$100(PooledTaskRunner.java:26)
> 	at
> org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
> 	at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
> 	at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
> 	at java.lang.Thread.run(Thread.java:619)
> 
> 
> then some messages will be stalled in queue (checked with jconsole).
> 
> what does the NPE mean? 
> how can I avoid the problem?

Looks like there's a timing hole in ActiveMQSessionExecutor. Are you driving any close() processing? ActiveMQSessionExecutor.stop() can clear "taskRunner", without properly synchronizing with a Thread that's executing ActiveMQSessionExecutor.wakeup(). 

Rebuilding AMQ 4.1.2 with a patch similar to the following should avoid the NPE (but won't avoid whatever is causing the close() processing):

Index: activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java
===================================================================
--- activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java	(revision 663068)
+++ activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java	(working copy)
@@ -118,10 +118,14 @@
         try {
             if (messageQueue.isRunning()) {
                 messageQueue.stop();
-                if (taskRunner != null) {
-                    taskRunner.shutdown();
-                    taskRunner = null;
+                TaskRunner tempTaskRunner;
+                synchronized (this) {
+                    tempTaskRunner = this.taskRunner;
+                    this.taskRunner = null;
                 }
+                if (tempTaskRunner != null) {
+                    tempTaskRunner.shutdown();
+                }
             }
         } catch (InterruptedException e) {
             Thread.currentThread().interrupt();

If you could create a Geronimo Jira, that would be great... Looks like this is a problem in ActiveMQ 5.3 (used by Geronimo 2.2/trunk) and ActiveMQ 4.1.2 (used by G 2.1.x)

--kevan