Hello!
I hope someone can help me figure out an issue I'm having with JNDI
FSContext resolution under Linux (RHEL). In short, a JMS Queue and
ConnectionFactory are setup on a GlassFish v3 instance (Windows XP machine).
A simple Java client connects to these JMS resources via a local JNDI
FSContext created using IMQADMIN utility bundled with GlassFish MQ. During
FSContext Object Store creation the PROVIDER_URL was specified in
C:\TMP\ObjStore. After creation, I've noticed this directory contains a
.bindings file in which all the JMS resource mapping is specified. So, in
order to deploy the client application on any Windows client it's sufficient
to copy this .bindings file to any directory and just specify this directory
in Context.PROVIDER_URL in the client application code. However, when I
tried to copy the same .bindings file on a Linux client machine (in a
/tmp/objstore directory) and specified this path in Context.PROVIDER_URL the
following exception was raised when running the Linux client app:
javax.naming.NameNotFoundException: testQueueFactory Apparently, for some
reason the application doesn't "see" the FSContext bindings as the same error
is raised if .bindings file is not present in /tmp/objstore. I've tried
playing with permissions, removing hidden property, renaming .bindings but it
didn't help much.. Can anyone please shed a light onto the cause of this
weird FSContext resolution behaviour on Linux platform? Thank you! Here
is the working client application code for a Windows client (imq.jar, jms.jar
and fscontext.jar should be present in the app classpath): <code> import
java.util.Hashtable; import javax.jms.Connection; import
javax.jms.ConnectionFactory; import javax.jms.MessageProducer; import
javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage;
import javax.naming.Context; import javax.naming.InitialContext; public
class JMSClient { public static void main(String[] args) { Context
jndiContext = null; ConnectionFactory connectionFactory = null; Connection
connection = null; Session session = null; Queue queue = null;
MessageProducer messageProducer = null; try { Hashtable env = new
Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL,
"file:///C:/TMP/ObjStore"); jndiContext = new InitialContext(env);
connectionFactory = (ConnectionFactory)
jndiContext.lookup("jms/testQueueFactory"); queue = (Queue)
jndiContext.lookup("jms/testQueue"); connection =
connectionFactory.createConnection(); session =
connection.createSession(false, Session.AUTO_ACKNOWLEDGE); messageProducer =
session.createProducer(queue); TextMessage message =
session.createTextMessage("test 1"); messageProducer.send(message); }
catch (Exception ex) { System.out.println(ex); } finally { if (connection !=
null) { try { connection.close(); } catch (Exception e) {
System.out.println(e); } } } } } </code> And here is the client
application code for a Linux client, which raises the following exception
when looking up the ConnectionFactory: javax.naming.NameNotFoundException:
testQueueFactory <code> import java.util.Hashtable; import
javax.jms.Connection; import javax.jms.ConnectionFactory; import
javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session;
import javax.jms.TextMessage; import javax.naming.Context; import
javax.naming.InitialContext; public class JMSClient { public static
void main(String[] args) { Context jndiContext = null; ConnectionFactory
connectionFactory = null; Connection connection = null; Session session =
null; Queue queue = null; MessageProducer messageProducer = null; try {
Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL,
"file:///tmp/objstore"); jndiContext = new InitialContext(env);
connectionFactory = (ConnectionFactory)
jndiContext.lookup("jms/testQueueFactory"); queue = (Queue)
jndiContext.lookup("jms/testQueue"); connection =
connectionFactory.createConnection(); session =
connection.createSession(false, Session.AUTO_ACKNOWLEDGE); messageProducer =
session.createProducer(queue); TextMessage message =
session.createTextMessage("test unix 1"); messageProducer.send(message); }
catch (Exception ex) { System.out.println(ex); } finally { if (connection !=
null) { try { connection.close(); } catch (Exception e) {
System.out.println(e); } } } } } </code>
--
[Message sent by forum member 'XDex']
View Post: http://forums.java.net/node/882261