JMX client and Log4j
gjb9876 Feb 18, 2004 8:40 PMHello. I have written a standalone java application that uses Log4j. I'm using the apache log4j, not the log4j that came with jboss.
Next, I've added some functionality to this java application so that I can remotely connect to my JBoss server on which I've deployed several JMX MBeans. (I have a different client application that successfully connects with JMX, but it does not use log4j).
After adding the JMX code, my log4j has stopped working. I think there is a conflict between log4j-1.2.8.jar and the jbossall-client.jar ??? I'm using jboss-3.2.1
Here is the code in my java client application: (cut and paste relevent lines)
------------------------------------------------
import org.apache.log4j.*;
import org.apache.log4j.xml.*;
public Logger log = Logger.getLogger(getClass());
DOMConfigurator.configure("log4j.xml");
log.info("hello log4j");
System.out.println("should have seen log4j by now");
--------------------------------------------------
This worked great!!! UNTIL I ADDED jbossclient-all.jar onto my classpath!!! then I no longer get any of my log4j logitems to my file or console!!!!!
I need to add jbossclient-all.jar and jboss-jmx.jar onto my client application's classpath in order to do the following code to connect with my JMX MBEans on the remote server
------------------------------------------
try
{
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.provider.url", serverURL + ":1099");
env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
InitialContext ctx = new InitialContext(env);
RMIAdaptor server = (RMIAdaptor)ctx.lookup("jmx/rmi/RMIAdaptor");
ObjectName objName = new ObjectName("nokia.ans:service=Management");
String method = "getFullList";
Object[] params = { new Integer(dataType) };
String[] signature = { "java.lang.Integer" };
Object result = server.invoke(objName, method, params, signature);
log.debug("result obj: " + result);
resultList = (List)result;
log.debug("resultList size: " + resultList.size());
}
catch (Exception ex)
{
log.error("EX: " + ex);
//ex.printStackTrace();
}
------------------------------------------
Does anyone have any suggestions? Either I need to stop using the apache log4j and start using the log4j that jboss has extended..... or I need to find out how to continue using the original apache log4j AND add the necessary jboss client .jar files to use the naming lookup to jmx.
Thanks, Gretel