I had a problem similar to this (java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener), the difference in my case is that the common fix (addi
This kind of problem is solved by:
m2e
and m2e-wtp
plugins. This is done by going to "Help > Install New Software...", setting this URL for m2e
and this URL for m2e-wtp
and then installing every proposed software (don't forget to reboot Eclipse after that).war
through the "Add and Remove..." screen.I recommend you do all these steps on a fresh Eclipse install to avoid general caching issues.
As a side note, there are several problems with your POM as-is:
javax.servlet:javax.servlet-api
dependency needs to have the provided
scope since this dependency is always provided by the web-server at run-time.javax.servlet:jstl
dependency probably doesn't need to have the compile
scope and runtime
will suffice.spring-aop
, spring-beans
, spring-context
, spring-expression
, spring-tx
and spring-web
.test
scope (testng
, mockito-all
...)<inherited>true</inherited>
is unnecessary in your maven-compiler-plugin
declaration as this is the default.Final POM would be:
<?xml version="1.0" encoding="UTF-8"?>
<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>ctc.web.proyect</groupId>
<artifactId>front.web</artifactId>
<packaging>war</packaging>
<version>0.2.5</version>
<name>front.web</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javax.servlet.version>3.1.0</javax.servlet.version>
<javax.servlet.jstl>1.2</javax.servlet.jstl>
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
<jackson.version>2.5.3</jackson.version>
<mysql.version>5.1.30</mysql.version>
<c3p0.version>0.9.1.2</c3p0.version>
<logback.version>1.1.1</logback.version>
<slf4j.version>1.7.7</slf4j.version>
<testng.version>6.8.8</testng.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<mockito.version>1.9.5</mockito.version>
<cglib.version>2.2.2</cglib.version>
<guava.version>18.0</guava.version>
<commons-validator.version>1.4.1</commons-validator.version>
<javax.mail.version>1.4.7</javax.mail.version>
<org.aspectj.version>1.8.6</org.aspectj.version>
<apache.lucene.version>5.3.0</apache.lucene.version>
</properties>
<dependencies>
<!-- JAVAX SERVLET LIB DEPENDENCY -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${javax.servlet.jstl}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- SPRING DEPENDENCIES -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>${thymeleaf.version}</version>
</dependency>
<!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context,
spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<!-- JACKSON LIB DEPENDENCY FOR JSON SER/DES -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- MYSQL DB LIB -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- LogBack dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>${c3p0.version}</version>
</dependency>
<!-- COMMONS LIB DEPENDCY -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons-validator.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- GUAVA. We still use it in java 8 for immutable collections -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- TESTING DEPENDENCY -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${org.aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${apache.lucene.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.compass-project</groupId> -->
<!-- <artifactId>compass</artifactId> -->
<!-- <version>2.2.0</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.20.0</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
The other consideration you might want to fix is that your groupId
and artifactId
do not follow Maven conventions: prefer using -
as separator instead of .
.
your Pom.xml
seems to be just fine. However, If you right-click on your project, there should be an option under "maven" to "enable dependency management". That's it.
PS: avoid using the maven-eclipse-plugin
for the same if you are using m2eclipse. There is absolutely no need for it, it will be confusing, it will generate some mess. Don't use it unless you really know what you are doing.
Hope this helps.
Its pretty long list to follow - for me without installing m2e and m2e-wtp, "cleaning the project in Eclipse by selecting it and going to "Project > Clean"." runs maven build with default profile selected.