cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <>
Subject [c3] CallStack.getCurrentFrame() returns null - why?
Date Tue, 13 Mar 2012 12:22:03 GMT
Hi all,

as I mentioned in another thread I am ATM extracting various code from 
our main c3 block into separate ones. The extraction works fine for i18n 
and some general pipes. However we use a activemq queue and when I try 
to invoke a java pipeline from within a javax.jms.MessageListener I get 
a NPE in invoking pipe.execute().

I use something like:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Pipeline<SAXPipelineComponent> emailPipe = 
this.applicationContext.getBean("emailPipe", Pipeline.class);
emailPipe.setup(baos, parameters);
emailPipe.execute(); -> here we get NPE

I debugged the whole thing and found out that we never enter in the 
execute() method of the pipeline because before the 
CallStackCollectorDataStore.set is called.

public void set(String key, Object value) {
         CallStack.getCurrentFrame().setAttribute(key, value);

This provokes the following:

Now finally I found that CallStack.getCurrentFrame() is NULL,  because 
in CallStack
public static CallFrame getCurrentFrame() {
  final Stack stack = (Stack) callStack.get();
the stack is null and then the method is returning null provoking this 
very ugly NPE (which took me ages to track down).

Now my question is how can it be that the stack is null and how can I 
prevent it from happening? Further I would strongly vote to refactor 
CallStack.getCurrentFrame().setAttribute to something like
CallFrame frame = CallStack.getCurrentFrame();
   frame.setAttribute(key, value);
   // should we throw here an exception or is there an alternative?

Any ideas are welcome.


Thorsten Scherler<>
codeBusters S.L. - web based systems
<consulting, training and solutions>

View raw message