[jboss-jira] [JBoss JIRA] (WFLY-5213) Injecting external context or its destinations in MDB fails
Jeff Mesnil (JIRA)
issues at jboss.org
Fri Aug 28 09:38:05 EDT 2015
[ https://issues.jboss.org/browse/WFLY-5213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13103197#comment-13103197 ]
Jeff Mesnil commented on WFLY-5213:
-----------------------------------
it works for me after adding an dependency to org.jboss.invocation in the org.apache.activemq.artemis module.
# Remote Artemis broker
User credentials: "user"/"pass"
2 JMS queues:
<queue name="inQueue"/>
<queue name="outQueue"/>
# WildFly Configuration:
Add an external context to connect to the remote Artemis:
{noformat}
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<external-context name="java:/remote/artemis/" module="org.apache.activemq.artemis" class="javax.naming.InitialContext" cache="true">
<environment>
<property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
<property name="java.naming.provider.url" value="tcp://127.0.0.1:61616"/>
</environment>
</external-context>
</bindings>
<remote-naming/>
</subsystem>
{noformat}
Add an outbound-socket-binding
{noformat}
<outbound-socket-binding name="remote-artemis">
<remote-destination host="localhost" port="61616"/>
</outbound-socket-binding>
{noformat}
Add a messaging-activemq's remote-connector and a pooled-connection-factory to connect to the remote Artemis:
{noformat}
<remote-connector name="remote-artemis" socket-binding="remote-artemis"/>
...
<pooled-connection-factory name="remote-artemis" password="pass" user="user" entries="java:/jms/remoteCF" connectors="remote-artemis"/>
{noformat}
# MDB Configuration:
@MessageDriven(name = "HelloWorldQueueMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "java:/jms/remoteCF"),
@ActivationConfigProperty(propertyName="user", propertyValue="user"),
@ActivationConfigProperty(propertyName="password", propertyValue="pass"),
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:/remote/artemis/dynamicQueues/inQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class HelloWorldQueueMDB implements MessageListener {
...
}
It uses the remote-artemis pooled-connection-factory and looks up the queue from the external-context.
Likewise, code to send a message to the queue from a Servlet is using the external context:
{noforma}
@Inject
@JMSConnectionFactory("java:/jms/remoteCF")
@JMSPasswordCredential(userName = "user", password = "pass")
private JMSContext context;
@Resource(lookup = "java:/remote/artemis/dynamicQueues/inQueue")
private Queue queue;
{noformat}
Without the dependency to org.jboss.invocation, it fails:
{noformat}
Caused by: javax.naming.NamingException: WFLYNAM0062: Failed to lookup remote/artemis/dynamicQueues/inQueue [Root exception is java.lang.NoClassDefFoundError: org/jboss/invocation/proxy/classloading/MethodStore]
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:157)
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:88)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:316)
{noformat}
The org.apache.activemq.artemis is missing a dependency to the org.jboss.invocation module to be used from an external-context. Once the dependency is added, the external context is working as expected and the context is propertly injected
> Injecting external context or its destinations in MDB fails
> -----------------------------------------------------------
>
> Key: WFLY-5213
> URL: https://issues.jboss.org/browse/WFLY-5213
> Project: WildFly
> Issue Type: Bug
> Components: JMS
> Affects Versions: 10.0.0.Beta2
> Reporter: Ondřej Kalman
> Assignee: Jeff Mesnil
>
> When external-context is defined in EAP and it's pointing to external Artemis broker, it can't be injected in to MDB via @Resource(lookup = "java:global/externalcontext"). Such injection results in null object.
> Injecting destinations from external context results in javax.ejb.EJBTransactionRolledbackException.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
More information about the jboss-jira
mailing list