You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Seenu <gu...@gmail.com> on 2013/10/23 14:28:23 UTC

Maven - slf4j noclassdeffound error

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

Re: Maven - slf4j noclassdeffound error

Posted by gunrock seenu <gu...@gmail.com>.
Also here is the source I see for RouteMatchFactory

/*
 * Copyright 2011- Per Wendel
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package spark.route;


/**
 * RouteMatcherFactory
 *
 * @author Per Wendel
 */
public final class RouteMatcherFactory {
    /** The logger. */
    private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(RouteMatcherFactory.class);

    private static RouteMatcher routeMatcher = null;

    private RouteMatcherFactory() {}

    public static synchronized RouteMatcher get() {
        if (routeMatcher == null) {
            LOG.debug("creates RouteMatcher");
            routeMatcher = new SimpleRouteMatcher();
        }
        return routeMatcher;
    }

}





On Wed, Oct 23, 2013 at 11:35 PM, gunrock seenu <gu...@gmail.com>wrote:

> I tried this pom.xml, that did not help either its just seems to be
> missing something .
>
> <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.0
> http://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>org.slf4j</groupId>
>           <artifactId>slf4j-api</artifactId>
>           <version>1.7.5</version>
>
>       </dependency>
>
>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>4.9</version>
>       <scope>test</scope>
>     </dependency>
>
>   </dependencies>
> </project>
>
>
>
>
> On Wed, Oct 23, 2013 at 11:27 PM, Seenu <gu...@gmail.com> wrote:
>
>> It is referenced by spark core
>>
>> I can see slf4j-API getting pulled by the project in IntelliJ
>>
>> I also tried including the dependency in the Pom.xml.
>>
>> The noclassdeffound is still showing.
>>
>> Sent from my iPhone
>>
>> On Oct 23, 2013, at 10:22 AM, Kevin Krumwiede <kj...@gmail.com> wrote:
>>
>> > I don't see any reference to slf4j in your pom or your code.  Are you
>> > sure you posted the right thing?
>> >
>> > On 10/23/13, Seenu <gu...@gmail.com> wrote:
>> >> 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
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> > For additional commands, e-mail: users-help@maven.apache.org
>> >
>>
>
>

Re: Maven - slf4j noclassdeffound error

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi all,

> 5. consider if you really want the API or an implementation package
> for runtime use

The typical pattern with SLF4J is to depend only on org.slf4j:slf4j-api at
compile time, and then add an implementation binding at runtime. For SLF4J
1.6+, you don't even need an implementation at runtime; it will default to
no-op with only a single one-line warning. You have to be careful though:
it's best to add the implementation binding only for end-user application
components (i.e., components not intended for reuse), and/or add the
dependency non-transitively using test or optional scope; see:

    http://slf4j.org/faq.html#maven2

Anyway, I know that's a tangent from the original topic. It seems the OP
doesn't care about SLF4J; it's just a transitive dependency which should
get pulled in.

> Exception in thread "main" java.lang.NoClassDefFoundError:
org/slf4j/LoggerFactory

Personally, I cannot reproduce this problem on my OS X 10.9 system. The
exact POM and Java source posted works for me from both the command line
and using IntelliJ IDEA 12.1.6 downloaded today.

So I agree with Wayne to start double-checking your assumptions. See if
"mvn" works on the command line, "mvn dependency:tree" or "dependency:list"
as suggested by others, maybe try in NetBeans and/or Eclipse... and if your
IntelliJ is old try upgrading it and reimporting the project from scratch.

Regards,
Curtis


On Thu, Oct 24, 2013 at 8:33 AM, Wayne Fay <wa...@gmail.com> wrote:

> >       <dependency>
> >           <groupId>org.slf4j</groupId>
> >           <artifactId>slf4j-api</artifactId>
> >           <version>1.7.5</version>
>
> >> >> Exception in thread "main" java.lang.NoClassDefFoundError:
> >> >> org/slf4j/LoggerFactory
>
> At this point (with the dependency specifically declared in the pom),
> you have to start questioning everything:
> 1. are you sure that's the right dependency declaration and version?
> sometimes projects "move" and start producing new versions under a
> different groupId.
> 2. are you sure org.slf4j.LoggerFactory is supposed to be in that jar
> with that version?
> 3. go into .m2 and find the slf4j-api-1.7.5.jar file, open it up with
> a zip tool, confirm it is a real jar (zip) and not HTML error message
> 4. also confirm it has org.slf4j.LoggerFactory inside
> 5. consider if you really want the API or an implementation package
> for runtime use
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven - slf4j noclassdeffound error

Posted by Wayne Fay <wa...@gmail.com>.
>       <dependency>
>           <groupId>org.slf4j</groupId>
>           <artifactId>slf4j-api</artifactId>
>           <version>1.7.5</version>

>> >> Exception in thread "main" java.lang.NoClassDefFoundError:
>> >> org/slf4j/LoggerFactory

At this point (with the dependency specifically declared in the pom),
you have to start questioning everything:
1. are you sure that's the right dependency declaration and version?
sometimes projects "move" and start producing new versions under a
different groupId.
2. are you sure org.slf4j.LoggerFactory is supposed to be in that jar
with that version?
3. go into .m2 and find the slf4j-api-1.7.5.jar file, open it up with
a zip tool, confirm it is a real jar (zip) and not HTML error message
4. also confirm it has org.slf4j.LoggerFactory inside
5. consider if you really want the API or an implementation package
for runtime use

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven - slf4j noclassdeffound error

Posted by gunrock seenu <gu...@gmail.com>.
I tried this pom.xml, that did not help either its just seems to be missing
something .

<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.0
http://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>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
          <version>1.7.5</version>
      </dependency>


    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.9</version>
      <scope>test</scope>
    </dependency>

  </dependencies>
</project>




On Wed, Oct 23, 2013 at 11:27 PM, Seenu <gu...@gmail.com> wrote:

> It is referenced by spark core
>
> I can see slf4j-API getting pulled by the project in IntelliJ
>
> I also tried including the dependency in the Pom.xml.
>
> The noclassdeffound is still showing.
>
> Sent from my iPhone
>
> On Oct 23, 2013, at 10:22 AM, Kevin Krumwiede <kj...@gmail.com> wrote:
>
> > I don't see any reference to slf4j in your pom or your code.  Are you
> > sure you posted the right thing?
> >
> > On 10/23/13, Seenu <gu...@gmail.com> wrote:
> >> 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
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
>

Re: Maven - slf4j noclassdeffound error

Posted by Seenu <gu...@gmail.com>.
It is referenced by spark core

I can see slf4j-API getting pulled by the project in IntelliJ 

I also tried including the dependency in the Pom.xml. 

The noclassdeffound is still showing. 

Sent from my iPhone

On Oct 23, 2013, at 10:22 AM, Kevin Krumwiede <kj...@gmail.com> wrote:

> I don't see any reference to slf4j in your pom or your code.  Are you
> sure you posted the right thing?
> 
> On 10/23/13, Seenu <gu...@gmail.com> wrote:
>> 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
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven - slf4j noclassdeffound error

Posted by Kevin Krumwiede <kj...@gmail.com>.
I don't see any reference to slf4j in your pom or your code.  Are you
sure you posted the right thing?

On 10/23/13, Seenu <gu...@gmail.com> wrote:
> 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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven - slf4j noclassdeffound error

Posted by Wayne Fay <wa...@gmail.com>.
> Did you by any chance install using apt-get? I've seen a number of cases where
> doing so leads to errors like this. Try installing manually from the website.

To be clear, Russell is asking if you "installed Maven using apt-get
rather than downloading the tarball from the Maven website and
manually installing it."

It is true that we see "odd" problems on this list from time to time
from people who have installed a package OTHER than the one hosted on
maven.apache.org.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven - slf4j noclassdeffound error

Posted by Russell Gold <ru...@gold-family.us>.
Did you by any chance install using apt-get? I've seen a number of cases where doing so leads to errors like this. Try installing manually from the website.

On Oct 24, 2013, at 12:31 AM, gunrock seenu <gu...@gmail.com> wrote:

> ~/M101J$ mvn --version
> Apache Maven 3.0.4
> Maven home: /usr/share/maven
> Java version: 1.7.0_40, vendor: Oracle Corporation
> Java home: /usr/lib/jvm/jdk1.7.0_40/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "linux", version: "3.8.0-31-generic", arch: "amd64", family: "unix"
> 
> 
> strange thing I observed is when I went on the command line and invoke mvn
> compile , it failed with
> 
> ~/M101J/src/main/java/com/tengen/HelloWorldSparkStyle.java:[19,10] error:
> annotations are not supported in -source 1.3
> 
> made me think what if I generated the project from intellij - this time it
> worked. I had previously generated the project directly on command line and
> imported it into intelliJ and that seem to be the reason why it was not
> working well.
> 
> thank you all for your pointers. this one stumps me.

-----------------
Author, Getting Started with Apache Maven <http://www.packtpub.com/getting-started-with-apache-maven/video>

Come read my webnovel, Take a Lemon <http://www.takealemon.com>, 
and listen to the Misfile radio play <http://www.fuzzyfacetheater.com/misfile/>!








Re: Maven - slf4j noclassdeffound error

Posted by gunrock seenu <gu...@gmail.com>.
~/M101J$ mvn --version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_40, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.7.0_40/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.0-31-generic", arch: "amd64", family: "unix"


strange thing I observed is when I went on the command line and invoke mvn
compile , it failed with

~/M101J/src/main/java/com/tengen/HelloWorldSparkStyle.java:[19,10] error:
annotations are not supported in -source 1.3

made me think what if I generated the project from intellij - this time it
worked. I had previously generated the project directly on command line and
imported it into intelliJ and that seem to be the reason why it was not
working well.

thank you all for your pointers. this one stumps me.

Re: Maven - slf4j noclassdeffound error

Posted by gunrock seenu <gu...@gmail.com>.
~/M101J$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]

[INFO]
------------------------------------------------------------------------
[INFO] Building M101J 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ M101J ---
[INFO] com.tengen:M101J:jar:1.0-SNAPSHOT
[INFO] +- org.mongodb:mongo-java-driver:jar:2.11.3:compile
[INFO] +- com.sparkjava:spark-core:jar:1.1:compile
[INFO] |  +- org.eclipse.jetty:jetty-server:jar:9.0.2.v20130417:compile
[INFO] |  |  +-
org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016:compile
[INFO] |  |  +- org.eclipse.jetty:jetty-http:jar:9.0.2.v20130417:compile
[INFO] |  |  |  \- org.eclipse.jetty:jetty-util:jar:9.0.2.v20130417:compile
[INFO] |  |  \- org.eclipse.jetty:jetty-io:jar:9.0.2.v20130417:compile
[INFO] |  \- org.eclipse.jetty:jetty-webapp:jar:9.0.2.v20130417:compile
[INFO] |     +- org.eclipse.jetty:jetty-xml:jar:9.0.2.v20130417:compile
[INFO] |     \- org.eclipse.jetty:jetty-servlet:jar:9.0.2.v20130417:compile
[INFO] |        \-
org.eclipse.jetty:jetty-security:jar:9.0.2.v20130417:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] \- junit:junit:jar:4.9:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 9.925s
[INFO] Finished at: Wed Oct 23 23:42:09 EDT 2013
[INFO] Final Memory: 8M/30M
[INFO] ----------------------------------------------------


On Wed, Oct 23, 2013 at 11:04 AM, Thomas Broyer <t....@gmail.com> wrote:

> 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" <gu...@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
>

Re: Maven - slf4j noclassdeffound error

Posted by Thomas Broyer <t....@gmail.com>.
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" <gu...@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