Authentication between Mule/Anypoint JMS and JBoss/Wildfly9?

最后都变了- 提交于 2019-12-25 03:54:58

问题


I'm struggling with a small proof of concept for a feature we need for a bigger project.

On my local machine I have a Wildfly 9 installation (with a user, password, and group configured). I can send messages via HornetQ from a small Java program, and I can fiddle with <security-enabled> and the user/password and see that it works, or not, as I expect. Great!

However, I also have a simple Mule flow that attempts to send a message via a JMS outbound endpoint -- but this always fails with "HQ119031: Unable to validate user: null" even though I do (try to) provide a name. I simply cannot figure out where and how to specify the user/password that I know (from the Java program) to be working.

I know from a coworker, who gave me not very much info to go on, that he has already been in contact with MuleSoft support, who say that "they have no knowledge of Wildfly in conjunction with Mule" and could not help.

Here's my connector and flow:

<jms:connector name="Wildfly9JMSConnector"
    jndiInitialFactory="org.jboss.naming.remote.client.InitialContextFactory"
    jndiProviderUrl="http-remoting://127.0.0.1:8085"
    connectionFactoryJndiName="jms/RemoteConnectionFactor"
    jndiDestinations="true" forceJndiDestinations="true"
    disableTemporaryReplyToDestinations="true"
    username="inara"
    password="whitefall"
    doc:name="JMS" validateConnections="true">
</jms:connector>

<flow name="jbossconnectiontestFlow">
    <http:listener config-ref="HTTP_Listener_Configuration"
        path="/jbosstest" doc:name="HTTP" />

    <set-payload value="Shiny!" doc:name="Set Payload" />

    <logger message="1. payload: #[payload]" level="INFO" doc:name="Logger" />
    <jms:outbound-endpoint exchange-pattern="request-response" queue="jms/queue/CoordReceive" connector-ref="Wildfly9JMSConnector" doc:name="JMS">
        <jms:transaction action="BEGIN_OR_JOIN"/>
    </jms:outbound-endpoint>
    <set-payload value="JMS message sent." doc:name="Set Payload"/>
    <logger message="2. payload: #[payload]" level="INFO" doc:name="Logger"/>

    <catch-exception-strategy doc:name="Catch Emdxception Strategy">
        <logger level="INFO" doc:name="Logger" />
    </catch-exception-strategy>
</flow>

Partial stack trace:

ERROR 2015-10-20 16:53:01,948 [main] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: JmsConnector
{
  name=Wildfly9JMSConnector
  lifecycle=initialise
  this=6540cf1d
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=false
  supportedProtocols=[jms]
  serviceOverrides=<none>
}
. Root Exception was: HQ119031: Unable to validate user: null. Type: class org.hornetq.api.core.HornetQSecurityException
ERROR 2015-10-20 16:53:01,956 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
org.hornetq.api.core.HornetQSecurityException: HQ119031: Unable to validate user: null

I expect you'll want more info, more details, but I don't want to flood you with the wrong data -- so ask and ye shall receive.

Update: Sadly, @RyanCarter's suggestions weren't "it", or perhaps just not "enough". If I disable "security-enabled", then it will deploy successfully, but will fail when I try to send a message:

The top of the stack trace reports "javax.jms.JMSException: There is no queue with name jms/queue/CoordReceive". I'm currently figuring out what's going on -- I know the queue exists, because the Java program works. To the Google!


回答1:


Here is an approach I have used before to use JNDI with HornetQ in Jboss 7+. Setting the username and password in 2 places. One for the JNDI connection and one for the queue-level authentiation

<spring:bean id="jndiProviderProperties" class="org.springframework.beans.factory.config.MapFactoryBean">
  <spring:property name="sourceMap">
      <spring:map>
        <spring:entry key="java.naming.security.principal" value="inara"/>
        <spring:entry key="java.naming.security.credentials" value="whitefall"/>
      </spring:map>
  </spring:property>
</spring:bean>

<jms:connector name="jms-connector" jndiInitialFactory="org.jboss.naming.remote.client.InitialContextFactory"
    jndiProviderUrl="remote://localhost:4447"
    connectionFactoryJndiName="jms/RemoteConnectionFactory" jndiDestinations="false"
    forceJndiDestinations="false" createMultipleTransactedReceivers="true" username="inara" password="whitefall"
    numberOfConcurrentTransactedReceivers="10" disableTemporaryReplyToDestinations="true" jndiProviderProperties-ref="jndiProviderProperties">
</jms:connector>



回答2:


Aha! There was a mismatch (basically due to lack of understanding on my part) between the user configurations in C:\wildfly\domain\application-users.properties and C:\wildfly\standalone\configuration\application-users.properties. Once I had configured users for the management console (in domain) as well as for the queues (in standalone), I was up and running.



来源:https://stackoverflow.com/questions/33240127/authentication-between-mule-anypoint-jms-and-jboss-wildfly9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!