clsbartek
clsbartek

Reputation: 206

Maven, Eclipse, Spring, Tomcat and ClassNotFoundException SpringServletContainerInitializer

my Maven Eclipse Project use Spring 4.1.6.RELEASE, java 8, and Tomcat 8 server for deploy. When i built project using console "mvn package" and deploy .war file by /manager it works fine. But when i want ot use Eclipse and its "Run on Server" option it throws sth like this:

ava.io.IOException: java.lang.ClassNotFoundException: org.springframework.web.SpringServletContainerInitializer...

At the end in console i can see

May 15, 2015 10:39:08 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1424 ms

but i am not able to open tomcat's manager or my website (HTTP Status 404)

I'm pretty sure that there is problem with Eclipse Build path or Assembly Dependency but i have no idea what to do.

pom.xml(dependencies):

<properties>
  <spring.version>4.1.6.RELEASE</spring.version>
</properties>
<build>
  <sourceDirectory>src</sourceDirectory>
  <plugins>
    <plugin>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.4</version>
      <configuration>
        <warSourceDirectory>WebContent</warSourceDirectory>
        <failOnMissingWebXml>false</failOnMissingWebXml>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.1</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
      </configuration>
    </plugin>
  </plugins>
</build>
<dependencies>
  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
  </dependency>
<!-- Spring dependencies -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring.version}</version>
  </dependency>

  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${spring.version}</version>
  </dependency>

  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${spring.version}</version>
  </dependency>
</dependencies>

Edit

Before error message there are two lines:

May 15, 2015 11:38:19 AM org.apache.catalina.startup.ContextConfig processServletContainerInitializers
SEVERE: Failed to process JAR found at URL [/aaaa] for ServletContainerInitializers for context with name [{1}]

Upvotes: 0

Views: 1592

Answers (3)

clsbartek
clsbartek

Reputation: 206

Ok, thank's for all of answers. Converting to Maven Project removed EAR Library and Webapp Libraries from project. The solution was to add them again.

Upvotes: 0

breakline
breakline

Reputation: 6093

The tomcat manager issue is because Eclipse doesn't copy the ROOT and manager directories from Tomcat's webapps to wtpwebapps. Wtpwebapps is a separate folder for Eclipse's own webbapp deployments i.e. when you deploy a webapp directly via eclipse. Make sure you copy everything inside webapps to wtpwebapps manually.

Upvotes: 0

Sunil
Sunil

Reputation: 492

Possible solution

  1. Open the project's properties (e.g., right-click on the project's name in the project explorer and select "Properties").
  2. Select "Deployment Assembly".
  3. Click the "Add..." button on the right margin.
  4. Select "Java Build Path Entries" from the menu of Directive Type and click "Next".
  5. Select "Maven Dependencies" from the Java Build Path Entries menu and click "Finish".

Upvotes: 1

Related Questions