[JBoss Seam] - No application context active
by jcarlos_andia
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
18 years, 2 months
[JBoss jBPM] - Injection of bean in Timer
by jcarlos_andia
Hi.
I have an 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 bean 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(JavassistLazyInitializer.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(JavassistLazyInitializer.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 timer context? Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128480#4128480
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4128480
18 years, 2 months
[JBoss Seam] - Re: Seam & Services management
by norman.richards@jboss.com
Make them Seam components and use them as you wish. In general, I think you'll find that you can define your entire application in terms of those "service layer" things and write very little in terms of glue code. (the "action" layer, as you describe it) Where you can't, you simply layer your application. There's absolutely nothing tricky about any of this.
As to the DAO issue, I think you'll find in Seam that if you are doing anything tricky you'll want to use some sort of controller object to manage your entities. That's what the EntityHome and EntityQuery objects do in Seam. If you are forced to over-architect your application, you'll probably end up either modifying your DAOs to actually perform some useful functions in the context of Seam or creating a controller of some sort that delegates off to your DAO.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128477#4128477
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4128477
18 years, 2 months