Exception while executing java class









up vote
0
down vote

favorite












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











share|improve this question























  • Presumably log4j is in 'test' scope, not 'compile' scope.
    – bmargulies
    Jan 18 '15 at 22:42






  • 1




    There clearly is a problem with your dependencies. Log4J is missing from the classpath. Are you sure you setup the <scope> correctly?
    – Alessandro Santini
    Jan 18 '15 at 22:42











  • Execuse me i'm new in java and maven how can i check <scope> and where can i find it ?
    – user3188912
    Jan 18 '15 at 22:46










  • Is there a pom.xml you can show us?
    – Dawood ibn Kareem
    Jan 18 '15 at 23:00










  • What even is the error?
    – Dave Newton
    Jan 18 '15 at 23:21














up vote
0
down vote

favorite












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











share|improve this question























  • Presumably log4j is in 'test' scope, not 'compile' scope.
    – bmargulies
    Jan 18 '15 at 22:42






  • 1




    There clearly is a problem with your dependencies. Log4J is missing from the classpath. Are you sure you setup the <scope> correctly?
    – Alessandro Santini
    Jan 18 '15 at 22:42











  • Execuse me i'm new in java and maven how can i check <scope> and where can i find it ?
    – user3188912
    Jan 18 '15 at 22:46










  • Is there a pom.xml you can show us?
    – Dawood ibn Kareem
    Jan 18 '15 at 23:00










  • What even is the error?
    – Dave Newton
    Jan 18 '15 at 23:21












up vote
0
down vote

favorite









up vote
0
down vote

favorite











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











share|improve this question















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








java maven






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 16:09









Cœur

17.2k9102141




17.2k9102141










asked Jan 18 '15 at 22:39







user3188912


















  • Presumably log4j is in 'test' scope, not 'compile' scope.
    – bmargulies
    Jan 18 '15 at 22:42






  • 1




    There clearly is a problem with your dependencies. Log4J is missing from the classpath. Are you sure you setup the <scope> correctly?
    – Alessandro Santini
    Jan 18 '15 at 22:42











  • Execuse me i'm new in java and maven how can i check <scope> and where can i find it ?
    – user3188912
    Jan 18 '15 at 22:46










  • Is there a pom.xml you can show us?
    – Dawood ibn Kareem
    Jan 18 '15 at 23:00










  • What even is the error?
    – Dave Newton
    Jan 18 '15 at 23:21
















  • Presumably log4j is in 'test' scope, not 'compile' scope.
    – bmargulies
    Jan 18 '15 at 22:42






  • 1




    There clearly is a problem with your dependencies. Log4J is missing from the classpath. Are you sure you setup the <scope> correctly?
    – Alessandro Santini
    Jan 18 '15 at 22:42











  • Execuse me i'm new in java and maven how can i check <scope> and where can i find it ?
    – user3188912
    Jan 18 '15 at 22:46










  • Is there a pom.xml you can show us?
    – Dawood ibn Kareem
    Jan 18 '15 at 23:00










  • What even is the error?
    – Dave Newton
    Jan 18 '15 at 23:21















Presumably log4j is in 'test' scope, not 'compile' scope.
– bmargulies
Jan 18 '15 at 22:42




Presumably log4j is in 'test' scope, not 'compile' scope.
– bmargulies
Jan 18 '15 at 22:42




1




1




There clearly is a problem with your dependencies. Log4J is missing from the classpath. Are you sure you setup the <scope> correctly?
– Alessandro Santini
Jan 18 '15 at 22:42





There clearly is a problem with your dependencies. Log4J is missing from the classpath. Are you sure you setup the <scope> correctly?
– Alessandro Santini
Jan 18 '15 at 22:42













Execuse me i'm new in java and maven how can i check <scope> and where can i find it ?
– user3188912
Jan 18 '15 at 22:46




Execuse me i'm new in java and maven how can i check <scope> and where can i find it ?
– user3188912
Jan 18 '15 at 22:46












Is there a pom.xml you can show us?
– Dawood ibn Kareem
Jan 18 '15 at 23:00




Is there a pom.xml you can show us?
– Dawood ibn Kareem
Jan 18 '15 at 23:00












What even is the error?
– Dave Newton
Jan 18 '15 at 23:21




What even is the error?
– Dave Newton
Jan 18 '15 at 23:21












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










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






share|improve this answer




















  • I got this after appending <dependency>log4j. please initialize log4j system properly
    – user3188912
    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? 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 4:15











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28015655%2fexception-while-executing-java-class%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown
























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










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






share|improve this answer




















  • I got this after appending <dependency>log4j. please initialize log4j system properly
    – user3188912
    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? 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 4:15















up vote
0
down vote



accepted










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






share|improve this answer




















  • I got this after appending <dependency>log4j. please initialize log4j system properly
    – user3188912
    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? 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 4:15













up vote
0
down vote



accepted







up vote
0
down vote



accepted






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






share|improve this answer












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







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 19 '15 at 18:03









Vitaly

1,3821917




1,3821917











  • I got this after appending <dependency>log4j. please initialize log4j system properly
    – user3188912
    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? 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 4:15

















  • I got this after appending <dependency>log4j. please initialize log4j system properly
    – user3188912
    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? 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 4:15
















I got this after appending <dependency>log4j. please initialize log4j system properly
– user3188912
Jan 21 '15 at 23:02




I got this after appending <dependency>log4j. please initialize log4j system properly
– user3188912
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? 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 4:15





I am glad, my answer helped you. And now you have new challenge. I think, this topic help you: 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 4:15


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28015655%2fexception-while-executing-java-class%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3