0

I want the Jetty to run my spring app. In eclipse with run-jetty-run plugin everything seems fine. When I copy the war file (which I produce with maven) to the jetty webapps, and then enter the url, I get an error:

   org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/erastotenes-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/erastotenes-servlet.xml]

My web.xml:

<web-app id="walladverts" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<servlet>
    <servlet-name>erastotenes</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>erastotenes</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<filter>
<filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
 </filter>

 <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
 </filter-mapping>

EDIT Added context listener and still didn't help:

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/erastotenes-servlet.xml
    </param-value>
</context-param>
Filip Górny
  • 1,749
  • 16
  • 24

1 Answers1

0

This fixed the problem:

  <build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <webXml>src/webapp/WEB-INF/web.xml</webXml>
      <webResources>
        <resource>
          <!-- this is relative to the pom.xml directory -->
          <directory>src/webapp/</directory>
        </resource>
      </webResources>
    </configuration>
  </plugin>
</plugins>

Filip Górny
  • 1,749
  • 16
  • 24