Results 1 to 1 of 1
- 01-11-2012, 12:10 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 1
- Rep Power
- 0
JNDI FSContext resolution of JMS resources under Linux
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):
And here is the client application code for a Linux client, which raises the following exception when looking up the ConnectionFactory:Java 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); } } } } }
javax.naming.NameNotFoundException: testQueueFactory
Java 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); } } } } }
Similar Threads
-
Best resolution timer
By tabchas in forum New To JavaReplies: 11Last Post: 06-14-2011, 03:15 PM -
[SOLVED] Windows Linux conflict - TrayIcon image not display in Linux
By Eranga in forum Advanced JavaReplies: 6Last Post: 04-08-2009, 04:05 AM -
Resolution problem!
By jan1ey in forum New To JavaReplies: 1Last Post: 03-03-2009, 07:36 AM -
Problem locating resources on Linux.
By jimm1 in forum New To JavaReplies: 1Last Post: 01-18-2008, 06:34 PM -
How to change the resolution ?
By samson in forum Java 2DReplies: 1Last Post: 07-17-2007, 11:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks