Log4J and JBoss classloader issue?
casadelnorte Feb 15, 2007 9:15 AMAfter upgrading (at the same time unfortunately, god how dumb) to MyEclipseIDE 5.1 and JBoss 4.0.5GA, I've been having issues with application logging:
09:53:59,242 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable to a "org.apache.log4j.spi.ErrorHandler" variable. 09:53:59,243 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.spi.ErrorHandler" was loaded by 09:53:59,244 ERROR [STDERR] log4j:ERROR [WebappClassLoader delegate: false repositories: /WEB-INF/classes/ ----------> Parent Classloader: java.net.FactoryURLClassLoader@df6322 ] whereas object of type 09:53:59,245 ERROR [STDERR] log4j:ERROR "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@7471e0]. 09:53:59,723 ERROR [STDERR] log4j:ERROR Could not create an Appender. Reported error follows. 09:53:59,724 ERROR [STDERR] java.lang.ClassCastException: org.jboss.logging.appender.DailyRollingFil eAppender
My application .classpath is:
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="com.genuitec.eclipse.j2eedt.core.J2EE14_CONTAINER"/> <classpathentry kind="lib" path="/Applications/Java/jtds-1.2-dist/jtds-1.2.jar"/> <classpathentry kind="lib" path="/Applications/Java/javamail-1.4/mail.jar"/> <classpathentry kind="lib" path="/Applications/Java/jaf-1.1/activation.jar"/> <classpathentry kind="lib" path="/Applications/Java/quartz-1.5.2/quartz-1.5.2.jar"/> <classpathentry kind="lib" path="/Applications/Java/commons-lang-2.1/commons-lang-2.1.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/> <classpathentry kind="lib" path="/Applications/Java/logging-log4j-1.2.14/dist/lib/log4j-1.2.14.jar"/> <classpathentry kind="output" path="WebRoot/WEB-INF/classes"/> </classpath>
JBoss starts fine with no applications deployed. But when I deploy one - even a simple test - using log4j, the error shows up. The application will still run, but without logging.
There are several posts on the net about this exact issue, with a variety of responses, none of which work for me.
I have even tried several versions of Log4J, including the one in jboss, with no change in behavior.
I've been using JBoss and MyEclipseIDS for years, but with after the upgrade I'm having this problem with all of my applications.
Here's the index.jsp page for the simple test application:
<%@ page language="java" import="java.util.*" import="org.apache.log4j.Logger" pageEncoding="ISO-8859-1"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> Hello!<br /> <% System.out.println("hello from the page"); Logger log = Logger.getLogger(this.getClass().getName()); log.info("hello from the logger!"); %> </body> </html>
with it's classpath:
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="com.genuitec.eclipse.j2eedt.core.J2EE14_CONTAINER"/> <classpathentry kind="lib" path="/Applications/Java/jboss-4.0.5.GA/server/default/lib/log4j.jar"/> <classpathentry kind="output" path="WebRoot/WEB-INF/classes"/> </classpath>
With the Logger stuff commented out, and without Log4j in the classpath, it works fine. Add Log4J, and you get the errors.
I've tried everything I can think of.
Running:
MacOSX 10.4.8ppc
Java 1.5_06
MyEclipseIDE 5.1.0GA
Eclipse 3.2.1
Anyone have any thoughts about how to proceed?
Larry