None of the transitive dependencies of spark are in the classpath. It
generally happens if the POM is "invalid".
What does "mvn dependency:tree" says? Is there any error/warning in IDEA?
 Le 23 oct. 2013 14:28, "Seenu" <gunrockse...@gmail.com> a écrit :

> I am using intellij and maven,
>
> I have used the following pom.xml :
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";
>   xsi:schemaLocation="
> http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd
> ">
>   <modelVersion>4.0.0</modelVersion>
>
>   <groupId>com.tengen</groupId>
>   <artifactId>M101J</artifactId>
>   <version>1.0-SNAPSHOT</version>
>   <packaging>jar</packaging>
>
>   <name>M101J</name>
>   <url>http://maven.apache.org</url>
>
>   <properties>
>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>
>   </properties>
>
>   <dependencies>
>       <dependency>
>           <groupId>org.mongodb</groupId>
>           <artifactId>mongo-java-driver</artifactId>
>           <version>2.11.3</version>
>       </dependency>
>
>
>
>       <dependency>
>           <groupId>com.sparkjava</groupId>
>           <artifactId>spark-core</artifactId>
>           <version>1.1</version>
>       </dependency>
>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>4.9</version>
>       <scope>test</scope>
>     </dependency>
>
>   </dependencies>
> </project>
>
> ------------------------------
>
> package com.tengen;
>
>
> import spark.Request;
> import spark.Response;
> import spark.Route;
> import spark.Spark;
>
> /**
>  * Created with IntelliJ IDEA.
>  * User: seenu
>  * Date: 10/19/13
>  * Time: 7:44 PM
>  * To change this template use File | Settings | File Templates.
>  */
> public class HelloWorldSparkStyle {
>   public static void main(String[] args){
>      Spark.get(new Route("/") {
>          @Override
>          public Object handle(Request request, Response response) {
>              return "Hello World from Spark!";  //To change body of
> implemented methods use File | Settings | File Templates.
>          }
>      });
>   }
> }
>
>
>
>
>
> ----------------------------------
>
>
> when I run, via intellij here is what I see,
>
> /usr/lib/jvm/jdk1.7.0_40/bin/java -Didea.launcher.port=7536
> -Didea.launcher.bin.path=/home/sree/IDEA/idea-IC-129.1359/bin
> -Dfile.encoding=UTF-8 -classpath
> /usr/lib/jvm/jdk1.7.0_40/jre/lib/jfr.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/jsse.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/deploy.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/javaws.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/charsets.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/jce.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/plugin.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/resources.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/rt.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/home/sree/M101J/out/production/main:/home/sree/.m2/repository/org/mongodb/mongo-java-driver/2.11.3/mongo-java-driver-2.11.3.jar:/home/sree/.m2/repository/com/sparkjava/spark-core/1.1/spark-core-1.1.jar:/home/sree/IDEA/idea-IC-129.1359/lib/idea_rt.jar
> com.intellij.rt.execution.application.AppMain
> com.tengen.HelloWorldSparkStyle
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/slf4j/LoggerFactory
>     at
> spark.route.RouteMatcherFactory.<clinit>(RouteMatcherFactory.java:27)
>     at spark.Spark.init(Spark.java:299)
>     at spark.Spark.addRoute(Spark.java:282)
>     at spark.Spark.get(Spark.java:168)
>     at com.tengen.HelloWorldSparkStyle.main(HelloWorldSparkStyle.java:18)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:606)
>     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>     ... 10 more
>
> Process finished with exit code 1
>
>
> -----------------------------
>
>
> what could be wrong here? can someone please point me whre to look? I was
> hoping maven would put the slf4j-api into the classpath when I add
> dependency but it is not.
>
> Sent from my iPhone

Reply via email to