ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Locating additional classes in a custom Java Node.

Post new topic  Reply to topic
 Locating additional classes in a custom Java Node. « View previous topic :: View next topic » 
Author Message
kolban
PostPosted: Sun Oct 13, 2002 5:38 pm    Post subject: Locating additional classes in a custom Java Node. Reply with quote

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
View user's profile Send private message
kolban
PostPosted: Sun Oct 13, 2002 5:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
kolban
PostPosted: Sun Oct 13, 2002 6:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
kolban
PostPosted: Mon Oct 14, 2002 8:24 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Locating additional classes in a custom Java Node.
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.