EJB startup service? (JBoss 3.2.0)
javajedi Apr 25, 2003 2:13 AMI'm trying to put together an MBean to invoke an EJB operation as part of my ear's deployment process (from what I can tell, this is really the only way to accomplish this in JBoss.) In other words, a "startup" service. The MBean's start() method performs a JNDI lookup on the EJB and then calls a method on it. The problem I'm running into is that I can't seem to get the dependency ordering right. I have the MBean defined in jboss-app.xml. Here's what I've tried:
1) Don't specify any dependencies in my MBean's service xml. When start() runs, I get
javax.naming.NameNotFoundException: FooLocal not bound
2) Specify a dependency on "jboss.j2ee:service=EJB,jndiName=FooLocal". When start() runs, the JNDI lookup now succeeds, but the EJB seems to be incompletely deployed. As soon as the EJB tries to invoke a finder, I get
java.lang.NullPointerException
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createBeanClassInstance(JDBCStoreManager.java:555)
at org.jboss.ejb.plugins.CMPPersistenceManager.createBeanClassInstance(CMPPersistenceManager.java:137)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createBeanClassInstance(CachedConnectionInterceptor.java:251)
at org.jboss.ejb.EntityContainer.createBeanClassInstance(EntityContainer.java:226)
... (rest omitted)
3) Specify a dependency on "jboss.management.local:J2EEApplication=foo.ear,J2EEServer=Local,j2eeType=EJBModule,name=foo.jar"
This "feels" like the right solution to me, as I'm specifying a dependency on the entire EJB-jar getting deployed. However, when I do this, my start() method never gets invoked. It never gets a notification that this ObjectName has finished deploying, even tthough it appears in my JMX console.
Any suggestions? I've scoured the JBoss book, its examples, and the forums. I found Scott's chap2/ex3 example, which follows my approach #2 as described above, but his startService() method doesn't actually invoke any methods on the EJB; let alone anything that touches CMP, so I imagine if I enhanced the example to try that, I would run into a similar problem. Thanks for any help!
--Tim