[EJB 3.0] - TimerService.createTimer() in @Service POJO, 4.2.3 vs 5.1.0
by vskytta
Hello,
When migrating @Service POJOs from JBoss AS 4.2.3 to 5.1.0, I ran into a problem (bug?) with EJB timers (among others, more about those later in separate posts) . Simplified example:
DummyService.java:
package example;
|
| public interface DummyService
| {
| void start()
| throws Exception;
| }
DummyServiceBean.java:
package example;
|
| import java.util.Date;
|
| import javax.annotation.Resource;
| import javax.ejb.Timeout;
| import javax.ejb.Timer;
| import javax.ejb.TimerService;
|
| import org.jboss.ejb3.annotation.Management;
| import org.jboss.ejb3.annotation.Service;
|
| @Service
| @Management(DummyService.class)
| public class DummyServiceBean
| implements DummyService
| {
| @Resource
| protected TimerService timerService;
|
| public void start()
| throws Exception
| {
| timerService.createTimer(new Date(), 5000, "DUMMY");
| }
|
| @Timeout
| public void timeout(Timer timer)
| {
| System.out.println("PING");
| }
| }
This works with AS 4.2.3 (annotation packages obviously changed to the old ones), but the createTimer() fails in 5.1.0 with an InvocationTargetException whose root cause is:
Caused by: java.lang.IllegalStateException: Cannot obtain inMethodFlag for: TimerService.createTimer
| at org.jboss.ejb.AllowedOperationsAssociation.assertAllowedIn(AllowedOperationsAssociation.java:145)
| at org.jboss.as.ejb3.timerservice.TimerServiceFacade.assertAllowedIn(TimerServiceFacade.java:59)
| at org.jboss.as.ejb3.timerservice.TimerServiceFacade.createTimer(TimerServiceFacade.java:64)
| at example.DummyServiceBean.start(DummyServiceBean.java:24)
| [...]
I don't remember seeing any instructions except the annotation package changes in the 5.x release notes for migrating @Service POJOs. Ideas?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4243256#4243256
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4243256
17 years
[JBoss Messaging] - Re: Embedded server - how to create JMS Topic?
by Leos.Bitto
"ataylor" wrote : anonymous wrote : Cool, it is nice to see that you guys from JBoss are willing to suggest a straight replacement of JBoss Microcontainer by Spring Framework
|
| I wouldnt say that, this is just something i was messing round with.
|
Well, I have actually suspected that the omission of JBoss Microcontainer in your example would be most probably considered a mistake by most RedHat-employed people. :-)
"ataylor" wrote :
| anonymous wrote : Your example is missing the JMS objects needed at the client side, though - at least javax.jms.(XA)ConnectionFactory and some javax.jms.Destination (Queue or Topic) would be needed, unless you want to use your core API directly.
|
| These are defined in the jbm-configuration, jbm-jms.xml and jbm-users.xml files.
Sure, but that is where the server picks them. I wrote that your example (unlike mine) does not show how the client is supposed to reach these objects.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4243251#4243251
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4243251
17 years