3

我在创建与 Tibco EMS JMS 队列的连接(并从中读取)时遇到了一些问题。

<beans>
    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">com.tibco.tibjms.naming.TibjmsInitialContextFactory</prop>
                <prop key="java.naming.provider.url">tcp://ems-dit-am-uat-1.app.xxx.net:30055</prop>
            </props>
        </property>
    </bean>

    <bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate" /> <property name="jndiName"
        value="DRDRFIQueueConnectionFactory" /> </bean>

    <bean id="jmsDestinationResolver"
        class="org.springframework.jms.support.destination.JndiDestinationResolver">
        <property name="jndiTemplate" ref="jndiTemplate" />
        <property name="cache" value="true" />
    </bean>

    <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate" />
        <property name="jndiName" value="Q.NY.DERIV.DRD.RFI" />
    </bean>

    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="jmsConnectionFactory" />
        <property name="destinationResolver" ref="jmsDestinationResolver" />
        <property name="defaultDestination" ref="destination" />
    </bean>


    <bean id="jmsReceiver" class="com.csfb.fao.rds.rfi.application.DRDReceiverTst">
        <property name="jmsTemplate">
            <ref bean="jmsTemplate" />
        </property>
    </bean>

</beans>

我得到的例外是:

javax.naming.AuthenticationException:不允许:com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:668) 的名称或密码无效 [根异常是 javax.jms.JMSSecurityException:无效的名称或密码]。 tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:489) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)在 org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) 在 org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.lookup)java:105) at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201) at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 还有 12 个invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 12 更多invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 12 更多

我得到的唯一用户/密码是 JMS 队列本身 - 我在哪里设置?

谢谢克里斯

4

3 回答 3

2

明白了 - 需要将连接工厂包装在 UserCredentialsConnectionFactory 中:

<bean id="authenticationConnectionFactory"
    class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="jmsConnectionFactory" />
    <property name="username" value="yyyyy" />
    <property name="password" value="xxxx" />
</bean>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="authenticationConnectionFactory" />
    <property name="destinationResolver" ref="jmsDestinationResolver" />
    <property name="defaultDestination" ref="destination" />
于 2011-07-22T16:06:47.617 回答
2

我有一些类似的问题,解决方案是添加(除了这个问题的解决方案)

<prop key="java.naming.security.principal">username</prop>
<prop key="java.naming.security.credentials">password</prop>

jndiTemplatebean 配置

于 2013-09-30T12:42:05.910 回答
1

我对 EMS 没有任何经验,但用户和密码通常是在连接工厂中设置的,因此您需要在 JNDI 提供的对象上进行配置。

于 2011-07-20T16:16:09.450 回答