Fox
Fox

Reputation: 9444

Servlets not being included in the maven project

Can some one help me with this problem. jetty is not able to find my servlet. :(

I am getting the following error-

enter image description here

This is my directory structure -

enter image description here

This is my Web.xml -

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
   <display-name>Archetype Created Web Application</display-name>
   <servlet>
   <servlet-name>loginSer</servlet-name>
   <display-name>loginSer</display-name>
   <description></description>
<servlet-class>launchpad.servlets.loginSer</servlet-class>
  </servlet>
  <servlet-mapping>
  <servlet-name>loginSer</servlet-name>
  <url-pattern>/loginSer</url-pattern>
  </servlet-mapping>
 </web-app>

Upvotes: 0

Views: 407

Answers (2)

Larry OBrien
Larry OBrien

Reputation: 8606

Your exception reads com.launchpad.servlets.LoginServlet but your class is launchpad.servlets.LoginSer Are you sure that you're showing the accurate exception and source-code hierarchy?

Upvotes: 0

Jigar Joshi
Jigar Joshi

Reputation: 240900

You kept it in wrong directory, it should go under

src/main/java

not in

src/main/resource

Maven takes into compilati

Update

when I add it to /src/main/java eclipse cannot import HttpServlet class.

It is because you don't have servlet-api in yoru classpath

add dependency to your POM, replace ${servlet-api-version} with the appropriate version matching your app environment

dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>${servlet-api-version}</version>
</dependency>

Upvotes: 3

Related Questions