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 » ConfigManagerProxy setLogger method fails

Post new topic  Reply to topic
 ConfigManagerProxy setLogger method fails « View previous topic :: View next topic » 
Author Message
j.f.sorge
PostPosted: Tue May 06, 2008 8:54 am    Post subject: ConfigManagerProxy setLogger method fails Reply with quote

Master

Joined: 27 Feb 2008
Posts: 218

Hi all!

I wanted to log from an application using a wrapped ConfigManagerProxy API. For this I used the ConfigManagerProxy.setLogger(String) method as below
Code:
ConfigManagerProxy.setLogger(MessageBrokerProxyLogger.class.getName());


The class MessageBrokerProxyLogger is implemented as shown below
Code:
/*
 * Created on May 6, 2008
 * Created by d291663
 */
package com.ibm.broker.config.proxy;

//removed imports

/**
 * Class to wrap TubLogger into ConfigManagerProxy API.
 *
 * @author d291663
 * @version $Id$
 */
public class MessageBrokerProxyLogger extends Logger {

   //removed logger

   /**
    * Create instance of MessageBrokerProxyLogger - will wrap TubLogger into ConfigManagerProxy
    * API.
    */
   public MessageBrokerProxyLogger() {
      super();
   }

   /**
    * overriden method. Log with debug log level and call super method.
    *
    * @see com.ibm.broker.config.proxy.Logger#fine(java.lang.String).
    */
   public void fine(String aMessage) {
      if (logger.isDebugEnabled()) {
         logger.debug(aMessage);
      }
      super.fine(aMessage);
   }

   /**
    * overriden method. Log with debug log level and call super method.
    *
    * @see com.ibm.broker.config.proxy.Logger#finer(java.lang.String).
    */
   public void finer(String aMessage) {
      if (logger.isDebugEnabled()) {
         logger.debug(aMessage);
      }
      super.finer(aMessage);
   }

   /**
    * overriden method. Log with debug log level and call super method.
    *
    * @see com.ibm.broker.config.proxy.Logger#finest(java.lang.String).
    */
   public void finest(String aMessage) {
      if (logger.isDebugEnabled()) {
         logger.debug(aMessage);
      }
      super.finest(aMessage);
   }

   /**
    * overriden method. Log with info log level and call super method.
    *
    * @see com.ibm.broker.config.proxy.Logger#info(java.lang.String).
    */
   public void info(String aMessage) {
      logger.info(aMessage);
      super.info(aMessage);
   }

   /**
    * overriden method. Log with fatal log level and call super method.
    *
    * @see com.ibm.broker.config.proxy.Logger#severe(java.lang.String).
    */
   public void severe(String aMessage) {
      logger.fatal(aMessage);
      super.severe(aMessage);
   }

   /**
    * overriden method. Log with warn log level and call super method.
    *
    * @see com.ibm.broker.config.proxy.Logger#warning(java.lang.String).
    */
   public void warning(String aMessage) {
      logger.warn(aMessage);
      super.warning(aMessage);
   }

}


When I try to set the logger it fails with the following StackTraces

Code:
2008-05-06 18:37:27,203 FATAL MessageBrokerProxy.setLogger():197  could not initialize logger com.ibm.broker.config.proxy.MessageBrokerProxyLogger
com.ibm.broker.config.proxy.ConfigManagerProxyLoggedException: Could not instantiate com.ibm.broker.config.proxy.MessageBrokerProxyLogger after com.ibm.broker.config.proxy.ConfigManagerProxyLoggedException (Could not instantiate  after java.lang.ClassNotFoundException ())
   at com.ibm.broker.config.proxy.Logger.getLogger(Logger.java:156)
   at com.ibm.broker.config.proxy.ConfigManagerProxy.setLogger(ConfigManagerProxy.java:938)
   at com.ibm.broker.config.proxy.ConfigManagerProxy.setLogger(ConfigManagerProxy.java:965)


Does anyone know how to initialize the logger correctly?

Thanks in advance!
Back to top
View user's profile Send private message
mqmatt
PostPosted: Wed May 07, 2008 5:23 am    Post subject: Reply with quote

Grand Master

Joined: 04 Aug 2004
Posts: 1213
Location: Hursley, UK

The error suggests a simple CLASSPATH error; the CMP is just trying to load your class using Class.forName(). Make sure that the JAR file containing your class is available on the CLASSPATH.

Also, it's good practice to use your own package name rather than com.ibm.broker.config.proxy.

Cheers
-Matt
Back to top
View user's profile Send private message
j.f.sorge
PostPosted: Thu May 08, 2008 12:20 am    Post subject: Reply with quote

Master

Joined: 27 Feb 2008
Posts: 218

mqmatt wrote:
The error suggests a simple CLASSPATH error; the CMP is just trying to load your class using Class.forName(). Make sure that the JAR file containing your class is available on the CLASSPATH.

Also, it's good practice to use your own package name rather than com.ibm.broker.config.proxy.

Cheers
-Matt

I wanted to use a different package than the IBM one, but the constructor / the class Logger is not visible of I use a different one. Therefore I created my own class in the same package. My own logger class should be in CLASSPATH as it is in the same .jar as the class which intializes the ConfigManagerProxy API.

Probably it is a version issue?!

my ConfigManagerProxy.jar manifest says
Code:
Manifest-Version: 1.0
Created-By: 1.4.2 (IBM Corporation)
Back to top
View user's profile Send private message
mqmatt
PostPosted: Thu May 08, 2008 1:01 am    Post subject: Reply with quote

Grand Master

Joined: 04 Aug 2004
Posts: 1213
Location: Hursley, UK

The simple way to find out if your class is available is to try instantiating your class from your main() method.

The exception you're seeing is the ClassNotFoundException from this method:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#forName(java.lang.String)
...which has quite an explicit meaning.

Include the (java.lang.String) bit on the URL to get to the method directly. I couldn't get the [url] tag to work.
Back to top
View user's profile Send private message
j.f.sorge
PostPosted: Fri May 16, 2008 5:34 am    Post subject: Reply with quote

Master

Joined: 27 Feb 2008
Posts: 218

mqmatt wrote:
The simple way to find out if your class is available is to try instantiating your class from your main() method.

The exception you're seeing is the ClassNotFoundException from this method:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#forName(java.lang.String)
...which has quite an explicit meaning.

Include the (java.lang.String) bit on the URL to get to the method directly. I couldn't get the [url] tag to work.


I implemented a JUnit test to instantiate the Logger and it works
Code:
/**
 * Test if Class.forName works.
 *
 * @throws Exception
 *             Is thrown if anything goes wrong.
 */
public void testClassForName() throws Exception {
   Class test = Class.forName(MessageBrokerProxyLogger.class.getName());
   assertNotNull(test);

   MessageBrokerProxyLogger logger = (MessageBrokerProxyLogger) test.newInstance();
   assertNotNull(logger);
}


So I really don't know why it fails when I use the setLogger method.
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 » ConfigManagerProxy setLogger method fails
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.