0

我们将 JBoss 5 与 TIBCO 队列和 MDB 队列侦听器集成在一起,它的工作方式比预期的要好于调用stop(),然后start()JBoss JMX 控制台中的方法工作正常。现在我们用 ActiveMQ 替换了 TIBCO。除了从 JMX 控制台停止和启动 MDB 之外,所有功能都按预期工作。低于错误。

我的 ejb-jar.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
    <enterprise-beans>
        <message-driven>
            <ejb-name>MsgSubscriber</ejb-name>
            <ejb-class>MsgSubscriber</ejb-class>
            <activation-config>
                <activation-config-property>
                    <activation-config-property-name>destinationType</activation-config-property-name>
                    <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
                </activation-config-property>
                <activation-config-property>
                    <activation-config-property-name>destination</activation-config-property-name>
                    <activation-config-property-value>HelloWorldQueue</activation-config-property-value>
                </activation-config-property>
                <activation-config-property>
                    <activation-config-property-name>acknowledgeMode</activation-config-property-name>
                    <activation-config-property-value>Auto-acknowledge</activation-config-property-value>
                </activation-config-property>
            </activation-config>
    </message-driven>
</enterprise-beans>
</ejb-jar>
ERROR [[HtmlAdaptor]] Servlet.service() for servlet HtmlAdaptor threw exception
javax.resource.ResourceException: ResourceAdapter already set
        at org.apache.activemq.ra.ActiveMQActivationSpec.setResourceAdapter(ActiveMQActivationSpec.java:240)
        at org.jboss.resource.deployers.RARDeployment.endpointActivation(RARDeployment.java:329)
        at org.jboss.resource.deployers.RARDeployment.internalInvoke(RARDeployment.java:284)
        at org.jboss.system.ServiceDynamicMBeanSupport.invoke(ServiceDynamicMBeanSupport.java:156)
        at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
        at org.jboss.ejb3.JmxClientKernelAbstraction.invoke(JmxClientKernelAbstraction.java:58)
        at org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory.activate(JBossMessageEndpointFactory.java:344)
        at org.jboss.ejb3.mdb.MessagingContainer.startDelivery(MessagingContainer.java:184)
        at org.jboss.ejb3.mdb.MessagingDelegateWrapper.startDelivery(MessagingDelegateWrapper.java:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
        at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
        at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:223)
        at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet$3.run(HtmlAdaptorServlet.java:400)
        at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet$3.run(HtmlAdaptorServlet.java:397)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:396)
        at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:300)
        at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:104)
        at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:86)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:534)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.internalProcess(ActiveRequestResponseCacheValve.java:74)
        at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:47)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:599)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
        at java.lang.Thread.run(Thread.java:748)

如果您需要更多信息,请告诉我。请给我们一些线索。

4

1 回答 1

1

我查看了引发异常的 ActiveMQ 代码org.apache.activemq.ra.ActiveMQActivationSpec#setResourceAdapter

public void setResourceAdapter(ResourceAdapter resourceAdapter) throws ResourceException {
    // spec section 5.3.3
    if (this.resourceAdapter != null) {
        throw new ResourceException("ResourceAdapter already set");
    }
    if (!(resourceAdapter instanceof MessageResourceAdapter)) {
        throw new ResourceException("ResourceAdapter is not of type: " + MessageResourceAdapter.class.getName());
    }
    this.resourceAdapter = (MessageResourceAdapter)resourceAdapter;
}

它引用了 JCA 1.5 规范的第 5.3.3 节,其中部分说明:

ActivationSpec JavaBean 上的 setResourceAdapter 方法必须只调用一次;也就是说,关联在 ActivationSpec JavaBean 的生命周期内不得更改。

因此,似乎 JBoss 中存在错误,即它setResourceAdapter在生命周期内多次调用,ActivationSpec 或者ActiveMQ 中存在错误,它解释 JCA 1.5 规范并引发异常的方式。JBoss Application Server 5.x 中的任何错误目前都不会被修复(5.0 已在 10 多年前发布),因此您可以升级到最新版本(即Wildfly 17.0.1)。或者,Apache ActiveMQ 社区中的某个人可能会查看该问题,得出结论这是一个错误并修复它。您最好的选择是使用ActiveMQ 用户邮件列表提醒社区。

您也可以自己解决问题,因为这两个项目都是开源的。

于 2019-09-27T18:04:10.193 回答