JBoss 7.0.1 中的工作 MDB 示例?

发布于 2024-12-06 04:20:29 字数 6091 浏览 3 评论 0原文

这是一个曾经在 JBoss 5.1 中为我工作的 EJB3 MDB:

@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
{
    [...]
}

尽我所能,我无法将其迁移到 JBoss 7.0.1。 JMS 设置正常,我可以正常发布到目标(从我的主 JAR),但我的 EJB 侦听器没有侦听。我的 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"

我还按照说明修复了 JNDI 名称,所以这就是我现在所拥有的

// 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
{
    [...]
}

:在部署之前将所有记录器添加到 ALL 中显示,唯一一次提及我的 MDB 类是在 org.jboss.vfs.util.SuffixMatchFilter 看到它们时 - 即不可能好。

我一直在关注自 7.0.0 以来的 MDB 支持问题,并阅读了数十篇文章JIRA,更不用说迁移指南、EJB3 文档等等,但我很困惑。我知道 MDB应该在 7.0.1 中工作,但是上面的方法可行吗?我认为我的情况非常简单,所以有人有一个简单的工作示例、一个准确说明 7.0.1 中哪些功能/不起作用的文档,或者一份迁移指南吗?

编辑:只是想补充一点,这是我唯一的 EJB,所以这可能既是一个 EJB 问题,又是一个 JMS/MDB 问题。

更新:

我可以毫无问题地部署虚拟@Stateless,但不能使用@MessageDriven/@ActivationConfigProperty完全没有任何影响(将 destinationType 更改为 javax.jms.XXX 不会产生任何错误!)。我尝试将目标属性设置为所有可能的 JNDI 组合。

我已对照 standalone-preview.xml 检查了我的 standalone.xml ,没有发现任何实质性差异。

我遇到的最接近的错误是:

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:307)
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]

这可能是个问题吗?我通过添加 @ResourceAdapter(value="hornetq-ra.rar") 来实现这一点,正如我在其他地方看到的建议一样。

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:307)
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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流云如水 2024-12-13 04:20:29

我终于自己解决了这个问题。 JNDI 是一个转移注意力的东西。我不需要升级到 JBoss 7.1.0alpha,也不需要更改我的项目以使用 Java EE 6 部署(将我的 EJB 移至 WAR)。

最后,我需要做的就是关闭 JBoss 的 EJB3“lite”模式(在我复制的standalone-preview.xml 中将其设置为 true)。推测该模式不支持 MDB。一旦我这样做了,我的 MDB 就变得可见了。

<subsystem xmlns="urn:jboss:domain:ejb3:1.1" lite="false">
    [...]
</subsystem>

我的工作MDB现在看起来像这样:

@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
{
    [...]
}

更新:

“EJB lite”模式已被删除

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 !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文