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 » Initial context javax.naming.NoInitialContextException

Post new topic  Reply to topic
 Initial context javax.naming.NoInitialContextException « View previous topic :: View next topic » 
Author Message
sajtron
PostPosted: Wed Jun 15, 2011 11:58 pm    Post subject: Initial context javax.naming.NoInitialContextException Reply with quote

Novice

Joined: 31 May 2011
Posts: 24

Hi,

I have following setup:

-AIX 6.1, WMB 7
-in shared-classes there is jar library with static method for initializing log4j (called Log4JInitializator)
-in shared-classes there is log4j.jar
-there is JMSAppender configured in log4j configuration
-initial context factory is com.sun.jndi.fscontext.RefFSContextFactory
-provider url is correctly configured
-JNDI is correctly configured using JMSAdmin (there is connection factory and topic configured)
-one msgflow calls external java method of Log4JInitializator from ESQL code to initialize log4j
-when JMSAppender is going to get InitialContext it ends with:

Code:

javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {java.naming.provider.url=file:/var/tif/wmb/WMBD1D21_INT/CF/jms, java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory} [Root exception is java.lang.NullPointerException]
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:243)
        at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:327)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:357)
        at javax.naming.InitialContext.internalInit(InitialContext.java:295)
        at javax.naming.InitialContext.<init>(InitialContext.java:212)
        at org.apache.log4j.net.JMSAppender.activateOptions(JMSAppender.java:200)
        at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)
        at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:285)
        at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:171)
        at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:184)
        at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:502)
        at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:415)
        at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:919)
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:790)
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:682)
        at org.apache.log4j.xml.XMLWatchdog.doOnChange(DOMConfigurator.java:1033)
        at org.apache.log4j.helpers.FileWatchdog.checkAndConfigure(FileWatchdog.java:89)
        at org.apache.log4j.helpers.FileWatchdog.<init>(FileWatchdog.java:58)
        at org.apache.log4j.xml.XMLWatchdog.<init>(DOMConfigurator.java:1025)
        at org.apache.log4j.xml.DOMConfigurator.configureAndWatch(DOMConfigurator.java:662)
        at cz.trask.tif.wmb.tca.logging.Log4JInitializator.configureLog4J(Log4JInitializator.java:55)
Caused by: java.lang.NullPointerException
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
        ... 20 more


Strange things:
-it is working on Windows Server 2003
-there is second message flow with java user defined node which calls same Log4JInitializator method
-the second msgflow is deployed to different EG than first one
-the second msgflow uses same log4j configuration as first one
-the second flows JMSAppender is initialized correctly and works correctly

I have experimented with copying some WMQ jars to shared-classes but still with no luck. I also tried to get InitialContext from some test msgflow with JCN and it is working.

Does anybody know what to do to get rid of the exception?
Back to top
View user's profile Send private message
sajtron
PostPosted: Thu Jun 16, 2011 12:36 am    Post subject: Reply with quote

Novice

Joined: 31 May 2011
Posts: 24

If there is any JCN before initializing log4j (and JMSAppender) it works fine.

So it seems that WMB does not load some classes when using external method calling from ESQL. Needed classes are loaded when JCN or java user-defined node are used. I am wondering how to force WMB to load all needed classes.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 16, 2011 2:49 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

So you are calling Log4JInitializator from esql as a Java external procedure?

And it is not properly loading all of the needed jar files?

Or?
Back to top
View user's profile Send private message
sajtron
PostPosted: Thu Jun 16, 2011 4:06 am    Post subject: Reply with quote

Novice

Joined: 31 May 2011
Posts: 24

Yes, I am calling external java method and it SEEMS that it cannot load all jars. Only exception is NullPointer which is not very descriptive.

As workaround I put JCN into the flow and log4j is initialized from the JCN.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 16, 2011 4:11 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

So one possibility here is that you have a properties file somewhere, that is not actually inside a jar file.

The Shared classloader and other named class loaders do not currently load anything that is not a jar file.

So if you have any kind of properties file that needs to be accessed or loaded that you have put into shared-classes, you should put it into a jar file instead and see if that helps.
Back to top
View user's profile Send private message
sajtron
PostPosted: Thu Jun 16, 2011 4:57 am    Post subject: Reply with quote

Novice

Joined: 31 May 2011
Posts: 24

I don't know any properties file which has to be loaded.

Anyway, if you were right how is it possible that it is working when JCN is used? I thought that there is one classloader for both approaches.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 16, 2011 5:13 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

sajtron wrote:
I don't know any properties file which has to be loaded.

Anyway, if you were right how is it possible that it is working when JCN is used? I thought that there is one classloader for both approaches.


That's correct, there is only one set of classloaders for both approaches.

But it's possible, for example, that the code that runs from an ESQL external procedure is called with the shared-class loader as it's parent class loader and the code that runs from a JCN is called with the EG-Shared classloader as it's parent classloader. I don't have solid information at that level, outside whatever is published in the InfoCenter.

Are you calling only and exactly the same method in the JCN that you are calling in the ESQL external procedure? You say you're calling the same method, but are you doing any other configuration?

Does the behavior change if you deploy the jar file that contains the initialization class in the BAR file or if you put it in shared-classes?
Back to top
View user's profile Send private message
sajtron
PostPosted: Thu Jun 16, 2011 5:26 am    Post subject: Reply with quote

Novice

Joined: 31 May 2011
Posts: 24

Yes I am calling exactly the same method. I will try to add jar file into BAR.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 16, 2011 5:31 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

sajtron wrote:
Yes I am calling exactly the same method. I will try to add jar file into BAR.


I guess I was asking if you were ONLY calling exactly the same method. Does the JCN do anything else or have any other import statements other than the initialization class.
Back to top
View user's profile Send private message
sajtron
PostPosted: Thu Jun 16, 2011 6:05 am    Post subject: Reply with quote

Novice

Joined: 31 May 2011
Posts: 24

Sorry I missed that.
JCN calls external initialization method (in class Log4JInitializator) and passes input assembly to output terminal. JCN has different import statements than Log4JInitializator.
Previous ESQL code calls external initialization method (in class Log4JInitializator) and then it does some message tranformation.
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 » Initial context javax.naming.NoInitialContextException
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.