Working MDB example in JBoss 7.0.1?
Here's an EJB3 MDB that used to work for me in JBoss 5.1:
@TransactionAttribute( TransactionAttributeType.NOT_SUPPORTED )
@org.jboss.ejb3.annotation.Depends("jboss.messaging.destination:service=Topic,name=IncomingArticleNotifications")
@MessageDriven(
activationConfig = {
@ActivationConfigProperty( propertyName="destinationType", propertyValue="javax.jms.Topic"),
@ActivationConfigProperty( propertyName="destination", propertyValue="topic/IncomingArticleNotificationsDest"),
@ActivationConfigProperty( propertyName="subscriptionDurability", propertyValue="Durable"),
@ActivationConfigProperty( propertyName="messageSelector", propertyValue ="type='IncomingArticleNotification'")
}
)
public class IncomingArticleHandler implements MessageListener
{
[...]
}
Try as I might, I can't migrate this to JBoss 7.0.1. JMS is set up OK, and I can publish to the destination OK (from my main JAR), but my EJB listener just isn't listening. I get no deploy or runtime errors for my EJB / WAR / EAR:
01:02:40,600 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) Starting deployment of "product-ear-1.0-SNAPSHOT.ear"
01:02:41,752 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "product-ejb-1.0-SNAPSHOT.jar"
01:02:41,753 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "product.war"
I've also fixed the JNDI names, as per instructions, so here's what I have now:
// Ignore for now: @TransactionAttribute( TransactionAttributeType.NOT_SUPPORTED )
@ResourceAdapter("ejb3-rar.rar") // ??? As per docs. No idea what this should be, an attempt to get something working.
@MessageDriven(
activationConfig = {
@ActivationConfigProperty( propertyName="destinationType", propertyValue="javax.jms.Topic"),
@ActivationConfigProperty( propertyName="destination", propertyValue="java:/topic/IncomingArticleNotificationsDest"), // updated
@ActivationConfigProperty( propertyName="subscriptionDurability", propertyValue="Durable")
// Ignore for now: @ActivationConfigProperty( propertyName="messageSelector", propertyValue ="type='IncomingArticleNotification'")
}
)
public class IncomingArticleHandler implements MessageListener
{
[...]
}
Setting all loggers to ALL
before deploying reveals that the only time my MDB classes are mentioned is when the org.jboss.vfs.util.SuffixMatchFilter
sees them - that can't be good.
I've been following the issue of MDB support since 7.0.0 and have read through dozens of JIRAs, not to mention the migration guide, EJB3 docs and so on, but I'm left confused. I know MDBs should work in 7.0.1, but is the above doable? I think mine is quite a simple case, so does anyone have a simple working example, a single document that states exactly what does / doesn't work in 7.0.1, or a migration guide?
Edit: just thought I'd add that this is my only EJB, so this is probably as much an EJB problem as a JMS/MDB one.
Updates:
I can deploy a dummy @Stateless
with no problems, but no combination of @MessageDriven
/@ActivationConfigProperty
has had any effect at all (bodging the destinationType
to javax.jms.XXX
produces no errors!). I've tried setting the destination property to all possible JNDI combinations.
I've checked my standalone.xml
against standalone-preview.xml
and there are no substantial differences.
The nearest I get to any kind of error is this:
00:53:25,886 DEBUG [org.hornetq.ra.Util] (MSC service thread 1-4) org.jboss.as.messaging.jms.TransactionManagerLocator from [Module "org.hornetq.ra:main" from local module loader @15a62c31 (roots: /Users/andrewregan/Desktop/jboss-as-7.0.1.Final/modules)]: java.lang.ClassNotFoundException: org.jboss.as.messaging.jms.TransactionManagerLocator from [Module "org.hornetq.ra:main" from local module loader @15a62c31 (roots: /Users/andrewregan/Desktop/jboss-as-7.0.1.Final/modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:358)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:30开发者_运维百科7)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:101)
at org.hornetq.ra.Util.locateTM(Util.java:261) [hornetq-ra-2.2.7.Final.jar:]
at org.hornetq.ra.HornetQResourceAdapter.locateTM(HornetQResourceAdapter.java:1555) [hornetq-ra-2.2.7.Final.jar:]
at org.hornetq.ra.HornetQResourceAdapter.start(HornetQResourceAdapter.java:210) [hornetq-ra-2.2.7.Final.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]
at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]
at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.startContext(AbstractResourceAdapterDeployer.java:339) [ironjacamar-deployers-common-1.0.3.Final.jar:1.0.3.Final]
at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:1883) [ironjacamar-deployers-common-1.0.3.Final.jar:1.0.3.Final]
at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:825) [ironjacamar-deployers-common-1.0.3.Final.jar:1.0.3.Final]
at org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator.doDeploy(ResourceAdapterActivatorService.java:140) [jboss-as-connector-7.0.1.Final.jar:7.0.1.Final]
at org.jboss.as.connector.services.ResourceAdapterActivatorService.start(ResourceAdapterActivatorService.java:93) [jboss-as-connector-7.0.1.Final.jar:7.0.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765) [jboss-msc-1.0.0.GA.jar:1.0.0.GA]
at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291) [jboss-msc-1.0.0.GA.jar:1.0.0.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
Might that be a problem? I get that by adding @ResourceAdapter(value="hornetq-ra.rar")
as I've seen suggested elsewhere.
I finally managed to solve this myself. JNDI was a red-herring. I didn't need to upgrade to JBoss 7.1.0alpha, nor did I need to change my project to use Java EE 6 deployment (moving my EJBs into the WAR).
In the end, all I needed to do was turn off JBoss's EJB3 "lite" mode (this was set to true in the standalone-preview.xml I copied from). Presumably MDBs are not supported in that mode. As soon as I did this, my MDBs became visible.
<subsystem xmlns="urn:jboss:domain:ejb3:1.1" lite="false">
[...]
</subsystem>
My working MDB now looks like this:
@TransactionAttribute( TransactionAttributeType.NOT_SUPPORTED )
@MessageDriven(
activationConfig = {
@ActivationConfigProperty( propertyName="destinationType", propertyValue="javax.jms.Topic"),
@ActivationConfigProperty( propertyName="destination", propertyValue="java:/topic/IncomingArticleNotificationsDest"),
@ActivationConfigProperty( propertyName="subscriptionDurability", propertyValue="Durable"),
@ActivationConfigProperty( propertyName="messageSelector", propertyValue ="type='IncomingArticleNotification'"),
@ActivationConfigProperty( propertyName="clientID", propertyValue="myValue") // See: http://jgurukulam.blogspot.com/2011/09/jboss-7.html
}
)
public class IncomingArticleHandler implements MessageListener
{
[...]
}
UPDATE:
"EJB lite" mode has been removed !
精彩评论