[jboss-user] [JBoss Seam] - No application context active

jcarlos_andia do-not-reply at jboss.com
Mon Feb 11 15:27:12 EST 2008


Hi.

I have a jbpm Action handler associated to the event NODE_ENTER of a state. The first time it executes (when the token enters the node) a timer is created. The next "n" times (which is fired by the timer and not by the event) the method tries to look for a Stateful session bean in context. This is the code:


  | public class MyActionHandler implements ActionHandler{
  | 	
  | 	private static final long serialVersionUID = -7574831777028763706L;
  | 
  | 	public void execute(ExecutionContext context) throws Exception{
  | 		
  | 		if(context.getTimer()==null){
  | 			System.out.println("ADDING TIMER ...");
  | 			Calendar cal=Calendar.getInstance();
  | 			BusinessCalendar bc=new BusinessCalendar();
  | 			Duration duration=new Duration("20 seconds");
  | 			Date dueDate=bc.add(cal.getTime(), duration);
  | 			
  | 			Timer myTimer=new Timer();
  | 			myTimer.setName("[TIMER] "+context.getEventSource().getName());
  | 			myTimer.setDueDate(dueDate);
  | 			myTimer.setRepeat("20 seconds");
  | 			myTimer.setRetries(3);
  | 			
  | 			myTimer.setAction(context.getAction());
  | 			
  | 			context.setTimer(myTimer);
  | 			
  | 			context.getJbpmContext().getServices().getSchedulerService().createTimer(myTimer);
  | 		}else{
  | 			System.out.println("EXECUTING ...");
  | System.out.println("CommonUtil="+Component.getInstance("commonUtil"));
  | 
  | 		}
  | 	}
  | 



It fails when it tries to retrieve the SFSB from the context. The log:


  | 14:43:25,612 INFO  [STDOUT] EXECUTING ...
  | 14:43:25,618 WARN  [Timer] timer action threw exception
  | java.lang.IllegalStateException: No application context active
  |         at org.jboss.seam.Component.forName(Component.java:1799)
  |         at org.jboss.seam.Component.getInstance(Component.java:1849)
  |         at org.jboss.seam.Component.getInstance(Component.java:1832)
  |         at org.jboss.seam.Component.getInstance(Component.java:1826)
  |         at com.jotatech.vgrc.action.visual.MyActionHandler.execute(MyActionHandler.java:43)
  |         at org.jbpm.graph.def.Action.execute(Action.java:122)
  |         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:585)
  |         at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializ
  | er.java:173)
  |         at org.jbpm.graph.def.Action_$$_javassist_316.execute(Action_$$_javassist_316.java)
  |         at org.jbpm.job.Timer.execute(Timer.java:58)
  |         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:585)
  |         at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializ
  | er.java:173)
  |         at org.jbpm.job.Job_$$_javassist_307.execute(Job_$$_javassist_307.java)
  |         at org.jbpm.job.executor.JobExecutorThread.executeJob(JobExecutorThread.java:161)
  |         at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:62)
  | 

It seems that when the timer if fired it doesn't "look" in the context where all beans are. Any idea of how can I solve this?. Or a way to inject seam components within a jbpm timer context? Thanks in advance.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128483#4128483

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4128483



More information about the jboss-user mailing list