|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Locating additional classes in a custom Java Node. |
« View previous topic :: View next topic » |
Author |
Message
|
kolban |
Posted: Sun Oct 13, 2002 5:38 pm Post subject: Locating additional classes in a custom Java Node. |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
Folks,
I am trying to use JNDI within a custom Java node.
I have the following code fragment ...
Code: |
Hashtable environment = new Hashtable();
environment.put(
Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
environment.put(
Context.PROVIDER_URL,
"file:/C:/MQ/MQSIV2/Nodes/Projects/JMSOutput/JNDI");
try {
Context ctx = new InitialDirContext(environment);
...
|
At run-time, an exception is thrown which contains:
Naming exception: javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception is java.lang.ClassNotFoundException: com/sun/jndi/fscontext/RefFSContextFactory]
Does anyone know where I should place my "fscontext.jar" file in order for the WMQI broker to pick it up? |
|
Back to top |
|
 |
kolban |
Posted: Sun Oct 13, 2002 5:45 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
It gets more interesting .... it looks like it may not be the location of external JAR files but something in JDNI ... found a match and recreated from
Google. |
|
Back to top |
|
 |
kolban |
Posted: Sun Oct 13, 2002 6:19 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
Now it gets ugly again. In my custom node class, I created a method called test as follows:
Code: |
public void test() {
out.println("About to obtain a JNDI lookup context ...");
Hashtable environment = new Hashtable();
environment.put(
Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
environment.put(
Context.PROVIDER_URL,
"file://C:/MQ/MQSIV2/Nodes/Projects/JMSOutput/JNDI");
try {
Context ctx = new InitialDirContext(environment);
out.println("Retrieved context!");
} catch (NamingException e) {
out.println("Naming exception: " + e.toString());
out.println("Explanation: " + e.getExplanation());
e.printStackTrace(out);
}
}
|
Here is the odd thing ...
when this method is called within the node constructor, no exception is thrown. When called in the evaluate() callback, the exception is thrown!!!
Yikes!!! |
|
Back to top |
|
 |
kolban |
Posted: Mon Oct 14, 2002 8:24 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
Folks,
Finally got there after finding the following on Google.
Adding the code
Code: |
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
|
solved the problem. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|