Search code examples
springmavenm2eclipse

Deployment Assembly in Eclipse


  • Eclipse Indigo.
  • M2Eclipse plugin.
  • Tomcat 7.
  • Spring framework.

Trying to use the "Deployment Assembly" option, so that the Maven dependencies of my Eclipse project get automatically added to Tomcat.

This is part of my pom.xml file:

...
<packaging>war</packaging>
<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.1.9.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>3.2.1.RELEASE</version>
    </dependency>
</dependencies>
...

I do Project Properties -> Deployment Assembly -> Add -> Java Build Path Entries -> Maven Dependencies.

enter image description here

When I try to add my project to the Tomcat server in Eclipse, I get:

enter image description here

As you can see, only the spring-web dependency gets added to my project, and therefore I get the following deployment error.

SEVERE: Error configuring application listener of class  org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

Any ideas?


Solution

  • Try installing the Maven Integration for WTP, aka m2e-wtp https://www.eclipse.org/m2e-wtp/

    It will automatically add the Maven Classpath Library to the deployment assembly AND will respect the maven scopes for each individual classpath entry (i.e deploy compile, runtime dependencies, not test, provided)