[jboss-user] [EJB 3.0] - Entity EJBs, @Service & Thread
galo.navarro
do-not-reply at jboss.com
Fri Sep 8 12:05:57 EDT 2006
Hi, I'm trying to get a service running on my JBoss server that would awake every now and then, get a list of entity beans and throw a message to a JMS queue for each of those items, and sleep for a while.
If I strip the bit loading Entity beans off, everything works, I send a test message to the queue, etc.
But if I do the same loading the beans, I get the exception below. I guess I'm doing something wrong but cannot figure out what.
| 17:02:32,650 ERROR [STDERR] Exception in thread "Thread-16"
| 17:02:32,650 ERROR [STDERR] java.lang.NullPointerException
| 17:02:32,650 ERROR [STDERR] at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getNonTxEntityManager(ManagedEntityManagerFactory.java:58)
| 17:02:32,650 ERROR [STDERR] at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getTransactionScopedEntityManager(ManagedEntityManagerFactory.java:163)
| 17:02:32,650 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManager.createNamedQuery(TransactionScopedEntityManager.java:132)
| 17:02:32,650 ERROR [STDERR] at tal.noc.beans.NOCManagerService.loadNOCs(NOCManagerService.java:79)
| 17:02:32,650 ERROR [STDERR] at tal.noc.beans.NOCManagerService.run(NOCManagerService.java:86)
| 17:02:32,650 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
|
This is my service:
| @Service(objectName="jboss:custom=NOCManagerService")
| public class NOCManagerService implements Runnable, NOCManagementService {
|
| ....
|
| public void run() {
| this.running=true;
| while(this.running) {
| System.out.println("Awaken");
| Iterator nocs=this.loadNOCs().iterator();
| while(nocs.hasNext()) {
| NOC noc = (NOC)nocs.next();
| try {
| MessageSender ms=new MessageSender();
| ms.sendMessage("NOC: " + noc.toString(), "queue/msgQueue");
| } catch (Exception e) {
| e.printStackTrace(System.out);
| }
| }
| try {
| MessageSender ms=new MessageSender();
| ms.sendMessage("NOC", "queue/msgQueue");
| } catch (Exception e) {
| e.printStackTrace(System.out);
| }
| try {
| synchronized (this) {
| wait(60*1000);
| }
| } catch (Exception e) {
| e.printStackTrace(System.out);
| }
| }
| }
|
The service implements the following interface, just in case it makes any difference
| @Management
| public interface NOCManagementService {
|
Thanks a lot.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970402#3970402
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970402
More information about the jboss-user
mailing list