1

I am deploying my application as a JAR on JBoss EAP 6.2 and trying to implement apache log4j 1.2.17.

In my program i have:

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
...
Logger newLogger = Logger.getLogger(name);
PropertyConfigurator.configure("log4j.properties path");
return  newLogger;

However, every time I try to run through this I always get a stack trace with this caused by:

java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at "the program I am in"...

The log4j.jar file is defined within my classpath of my project.

Any help would be greatly appreciated.

Matt

Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
cain4355
  • 1,094
  • 1
  • 10
  • 22
  • Please describe the structure of your ear. – Robert Panzer Jul 25 '14 at 20:10
  • I am not using an EAR I am using a JAR to deploy my application. I have the root project which contains the src. The src contains the program that I have my logging code in as well as a META-INF folder which contains my jboss-deployment-structure.xml and MANIFEST.MF The .classpath is within the root project and contains the log4j.jar. – cain4355 Jul 25 '14 at 20:14
  • Then how do you put log4j into the class path? Did you define the dependency in the MANIFEST.MF? – Robert Panzer Jul 25 '14 at 20:17
  • Yes I did. My MANIFEST.MF looks like this: Manifest-Version: 1.0 Dependencies: org.apache.log4j – cain4355 Jul 25 '14 at 20:18
  • This link may help you http://stackoverflow.com/questions/8897528/problems-to-put-log4-properties-classpath – Wundwin Born Jul 25 '14 at 20:47
  • Tried this. Got the same result. – cain4355 Jul 25 '14 at 21:00

1 Answers1

0

In my jboss-deployment-structure.xml I had added the

<exclusions>
        <module name="org.apache.log4j"/>

like it said to in the migration manual however this seemed to be my problem. Removing this allowed my program to find the jar file.

cain4355
  • 1,094
  • 1
  • 10
  • 22