0

I executed this command

mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=crawler.Crawler

and found this

An exception occured while executing the Java class. org/apache/log4j/Logger

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" si:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion>
<repositories>
  <repository>
    <id>clojars.org</id>
    <url>http://clojars.org/repo</url>
  </repository>
  <repository>
     <id>twitter4j.org</id>
     <name>twitter4j.org Repository</name>
     <url>http://twitter4j.org/maven2</url>
     <releases>
     <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
     </snapshots>
   </repository>
  </repositories>
  <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
     </dependency>

second part

       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-compiler-plugin</artifactId>
       <configuration>
           <source>1.6</source>
           <target>1.6</target>
       </configuration>
       </plugin>
      </plugins>

Error

java.lang.NoClassDefFoundError: org/apache/log4j/Logger

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

You need to add dependency on log4j

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>

to your pom.xml file (after dependency on junit).

You can read about this dependency in maven repo: http://mvnrepository.com/artifact/log4j/log4j/1.2.17

Vitaly
  • 2,552
  • 2
  • 18
  • 21
  • I got this after appending log4j. please initialize log4j system properly –  Jan 21 '15 at 23:02
  • I am glad, my answer helped you. And now you have new challenge. I think, this topic help you: [How to initialize log4j properly?](http://stackoverflow.com/questions/1140358/how-to-initialize-log4j-properly) I guess, we can close this discussion. I voted up your question. You can voteup and accept my answer. Good luck! – Vitaly Jan 22 '15 at 04:15