5

I have a java application which does some JMS send&receive work. But I found an interesting problem. For example, I set the following for java.naming.provider.url.

tcp://hostnameA.foo.bar:7222

But I got the error as below. Only hostname in it, not the full qualified domain name.

javax.jms.JMSException: Failed to connect to the server at tcp://hostnameA:7222

Unless I add hostnameA in my hosts file manually, it won't connect to Tibco server.

How can I fix it?

Thanks in advance.

Smartmarkey
  • 1,979
  • 5
  • 22
  • 25

2 Answers2

10

The EMS Server has its own built-in JNDI server. What you're actually doing when you connect is 1) querying the EMS:s JNDI server for a connection factory definition and then 2) creating a connection based on the returned factory. This is implied by the fact that you're using java.naming.provider.url.

Change the connection factory definition (factories.conf) on the EMS server for the connection factory you're using. The default definition for the default factories (e.g. QueueConnectionFactory) on a fresh install is "tcp://7222" which will be replaced by "tcp://hostname:7222" by the server when retrieved. You can change this definition to e.g. "tcp://hostname.myfqdn.com:7222" and things should work.

You could also bypass the JNDI server completely by creating a connection directly, but I wouldn't recommend this since the connection factory definition returned by the server may contain information about load balanced and fault tolerant pairs, SSL settings, or point to a completely different server pair etc. It also allows the EMS administrators to change the definition of connection factories without the clients having to change their code or even their configuration.

stoft
  • 1,265
  • 8
  • 21
  • To clarify, you need to update `factories.conf` that is in your Tibco EMS server configuration folder that was specified during installation. For Windows and Tibco 8.3 installation without any parameters that might be `c:\ProgramData\TIBCO_HOME`. – GKalnytskyi Nov 27 '19 at 01:13
  • And don't forget to configure firewall rules so outside clients could connect. – GKalnytskyi Nov 27 '19 at 02:27
1

I guess this has nothing to do with the programming layer.
Your DNS query for that name is unresolvable, that's why it works when you edit your hosts-file.
Either check your system's DNS settings (or make sure the dns server which is in your system's configuration replies to your name query), or use the IP-address instead.

unNamed
  • 969
  • 1
  • 10
  • 18
  • You are right. I know 99% it is a DNS issue. But I would like to know what exactly caused this problem. :) – Smartmarkey Sep 16 '11 at 06:16
  • If you have a MS DC environment with build-in DNS server, there are options that clients also update their corresponding A and PTR entries. Those expire after a specific time. Which means they get deleted and aren't resolvable anymore. This can also apply to manual entries. – unNamed Sep 16 '11 at 06:45