English 中文(简体)
JMS error: can not send into foreign destinations
原标题:

I use Spring-configured jms template with tibco jms library. I get jms connection factory and topic with JNDI and these objects are not null. But when I try to send message or add listener I get this exception:

For listener:

Exception in thread "main" org.springframework.jms.InvalidDestinationException: Can not send into foreign destinations; nested exception is javax.jms.InvalidDestinationException: Can not send into foreign destinations
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:277)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
    at org.springframework.jms.core.JmsTemplate.receiveSelected(JmsTemplate.java:700)
    at org.springframework.jms.core.JmsTemplate.receive(JmsTemplate.java:682)
    at org.springframework.jms.core.JmsTemplate.receive(JmsTemplate.java:674)

For sender:

Exception in thread "main" org.springframework.jms.InvalidDestinationException: Invalid or foreigndestination; nested exception is javax.jms.InvalidDestinationException: Invalid or foreigndestination
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:277)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:539)
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:531)

Client app is working with the same topic without problems (so jms server is running). Do you have any ideas? I read about this exception in javadoc, but can t find how to understand the root issue and fix it. Thanks

UPD: JMS-related part of config:

<bean id="JmsFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
          <property name="jndiName" value="${jms.factory}"/>
          <property name="proxyInterface" value="javax.jms.TopicConnectionFactory" />
          <property name="lookupOnStartup" value="false" />
          <property name="jndiEnvironment">
            <props>
              <prop key="java.naming.provider.url">${jms.namingProvider}</prop>
              <prop key="java.naming.factory.initial">${jms.namingFactory}</prop>
              <prop key="java.naming.referral">${jms.namingReferral}</prop>
              <prop key="java.naming.security.credentials">${jms.securityCredentials}</prop>
              <prop key="java.naming.security.principal">${jms.securityPrincipal}</prop>
            </props>
          </property>
      </bean>

        <bean id="JmsTopic" class="org.springframework.jndi.JndiObjectFactoryBean">
          <property name="jndiName" value="${jms.topic}"/>
          <property name="proxyInterface" value="javax.jms.Topic" />
          <property name="lookupOnStartup" value="false" />
          <property name="jndiEnvironment">
            <props>
              <prop key="java.naming.provider.url">${jms.namingProvider}</prop>
              <prop key="java.naming.factory.initial">${jms.namingFactory}</prop>
              <prop key="java.naming.referral">${jms.namingReferral}</prop>
              <prop key="java.naming.security.credentials">${jms.securityCredentials}</prop>
              <prop key="java.naming.security.principal">${jms.securityPrincipal}</prop>
            </props>
          </property>
      </bean>

      <bean id="UserCredentialsConnectionFactory"
        class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
        <property name="targetConnectionFactory">
          <ref bean="JmsFactory" />
        </property>
        <property name="username" value="${jms.user}" />
        <property name="password" value="${jms.password}" />
      </bean>

      <bean id="JmsTemplate"
        class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory"
          ref="UserCredentialsConnectionFactory" />
        <property name="defaultDestination">
            <ref bean="JmsTopic"/>
        </property>
        <property name="pubSubDomain" value="true" />
      </bean>
最佳回答

It sounds like you have it configured so that it is attempting to create a destination rather than do a jndi lookup to get the destination that has been defined on the EMS instance.

You need to post your spring config to be sure though.

edit: if you set a destinationname on the JmsTemplate and provide it with a JndiDestinationResolver then it should work

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签