1

I created maven project in Eclipse and added a few dependencies.

Here is a full list of dependencies:

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.caliper</groupId>
        <artifactId>caliper</artifactId>
        <version>0.5-rc1</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.7.1</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.7.1</version>
    </dependency>
</dependencies>

Then I ran Maven install and all nesssery libs were uploaded.

Next time I got the following message:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building mywebapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ mywebapp ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\WORK_SPASE\mywebapp\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ mywebapp ---
[INFO] Compiling 1 source file to D:\WORK_SPACE\mywebapp\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.785s
[INFO] Finished at: Thu Jan 31 04:13:10 VET 2013
[INFO] Final Memory: 4M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project mywebapp: Compilation failure
[ERROR] error: error reading C:\Users\User1\.m2\repository\com\google\guava\guava\11.0.1\guava-11.0.1.jar; invalid LOC header (bad signature)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

And when I tried to run my class I got : Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Splitter

Please give me a piece of advice.

Spontifixus
  • 6,570
  • 9
  • 45
  • 63
user341203
  • 29
  • 1
  • 7

1 Answers1

3

First I see that you have an error:

reading C:\Users\User1.m2\repository\com\google\guava\guava\11.0.1\guava-11.0.1.jar; invalid LOC header (bad signature)

which might be caused by a failure during the download of the lib. The solution is to delete the folder C:\Users\User1.m2\repository\com\google and retry the build.

Furthermore I see that you are using an extremely old version of the maven-compiler-plugin (2.0.2) which brings me to the conclusion that you didn't configured your maven-compiler-plugin which means you are using java 1.4 but you need at least 1.5. You have to configure your maven-compiler-plugin like this:

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

Maybe you have to change to 1.5.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • Hi Frank, thanks for you reply! I removed the google dir, ran "Maven Install" again, the dir and subdirs were recreated, all libs were downloaded as well http://prntscr.com/r1oco I use the latest version of maven plugin which is availible http://prntscr.com/r1nwc Maven settings - http://prntscr.com/r1noz JDK - 1.6.027 I have never used the Maven before and you are right that my version is older than yours. Could you please tell me how can I download the version 3.0? It's not availible via eclipse install, perhaps I write a wrong search text. Windows 7(x64) Thanks! – user341203 Jan 31 '13 at 09:47
  • I don't think it's that big of a problem if you use Maven 2.x instead of Maven 3. Frank was talking about the "Maven compiler plugin", which is too old. By adding his XML snippet to your pom.xml file, the right plugin will be used (without needing to install Maven 3). – Etienne Neveu Jan 31 '13 at 09:52
  • Ok thanks, the building process works fine:) The last issue that still I get is Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Splitter it's a part of google guava jar, maven downloaded it and this jar is availible in project build path.. I found another topic on stackoverflow with the same error, but can't understand the cause yet. – user341203 Jan 31 '13 at 10:29
  • If you are using Eclipse Plugin (m2e) you are already using Maven 3. The newest version of Maven is 3.0.4 which can be downloaded [here](http://maven.apache.org/download.cgi). – khmarbaise Jan 31 '13 at 10:29
  • Have you given a scope for guava? – khmarbaise Jan 31 '13 at 11:47
  • Yes: com.google.guava guava 11.0.1 runtime – user341203 Jan 31 '13 at 11:51
  • @user341203 Note that I _didn't_ write the answer, I just edited it at some point to add some formatting. – Frank Pavageau Jan 31 '13 at 12:30
  • @user341203 _How_ do you "run your class"? Is the guava jar in the classpath? – Frank Pavageau Jan 31 '13 at 12:32
  • Yes, it's in the classpath. [link](http://prntscr.com/r21qw). Run as simple java class - select class -> run as Java app – user341203 Jan 31 '13 at 12:44