veeras
veeras

Reputation: 61

ResourceAdapter already set | JBoss 5.2 with Active MQ

We have JBoss 5 integrated with TIBCO Queue and MDB queue listener and its working as expected more over calling stop() and then start() methods in the JBoss JMX console is working fine. Now we replaced TIBCO with ActiveMQ. All functionalities are working as expected except stop and start MDB from JMX console. Getting below ERROR.

my ejb-jar.xml file

<?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)

Let me know if you need any more information. Kindly give us some clue.

Upvotes: 0

Views: 103

Answers (1)

Justin Bertram
Justin Bertram

Reputation: 34973

I took a look at the ActiveMQ code that is throwing that exception from 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;
}

It references section 5.3.3 of the JCA 1.5 specification which states, in part:

The setResourceAdapter method on the ActivationSpec JavaBean must be called exactly once; that is, the association must not change during the lifetime of an ActivationSpec JavaBean.

So it appears that there's either a bug in JBoss in that it is calling setResourceAdapter more than once during the lifetime of the ActivationSpec or there's a bug in ActiveMQ in the way it is interpreting the JCA 1.5 specification and throwing an exception. Any bug in JBoss Application Server 5.x is not going to be fixed at this point (5.0 was released over 10 years ago now) so you could upgrade to the latest release (i.e. Wildfly 17.0.1). Or perhaps someone in the Apache ActiveMQ community would look at the issue, conclude it's a bug, and fix it. Your best bet here is to alert the community using the ActiveMQ User Mailing List.

You could also fix the issue yourself since both projects are open-source.

Upvotes: 1

Related Questions