0

I have set up my maven project using the m2e plugin in eclipse indigo, and transformed it to an eclipse dynamic web project using mvn eclipse:eclipse -Dwtpversion=1.5. I have managed to get the project up and running in tomcat7, except for my servlets, for which I cannot create the servlet mappings.

I have tried modifying the web.xml file but it throws a ClassNotFoundException. Directory Structure and web.xml :

(ROOT)
    +src
       +main
          +resources
              +DrawInitialMap.java
          +webapp
               (WebContent here)


<web-app>
   <servlet>
      <servlet-name>DrawInitialMap</servlet-name>
      <servlet-class>(groupId).(artifactId).src.main.resources.DrawInitialMap</servlet-class>
   </servlet>
   <servlet-mapping>
      <servlet-name>DrawInitialMap</servlet-name>
      <url-pattern>/drawInitialMap.do</url-pattern>
   </servlet-mapping>
  (...)
</web-app>

While the @WebServlet annotation also fails to map the servlet :

@WebServlet(name="drawInitialMap", description="visualizes ttrp on html5 canvas", urlPatterns={"/drawInitialMap.do"})

Thank you in advance, and notify if you need any more of the code.

PS : Keep in mind that the servlet worked perfectly in Dynamic Web Project mode, without Maven

Spyros Mandekis
  • 984
  • 1
  • 14
  • 32

1 Answers1

0

There are several issues.

  1. You should stop using eclipse:eclipse. Instead, install WTP integration for M2E from Eclipse Marketplace
  2. In Maven project, your DrawInitialMap should be in /src/main/classes folder. So, it will be compiled as per default Maven project conventions
  3. The servlet-class element in web.xml requires full class name, i.e. no things like (groupId).(artifactId).src.main.resources.
Eugene Kuleshov
  • 31,461
  • 5
  • 66
  • 67