Error in servlet mapping and/or Tomcat server local host not running -


i need help.the code shows error.i think web.xml file wrong. created servlet system uses quartz cron scheduler create job. in case, job wake user after user-defined no. of hours.the code pretty straightforward , part error free. except servlet mapping part. have faced difficulty when comes mapping , have tried level best rectify errors seems there problem says "server tomcat v7.0 server @ localhost failed start."

here code- 1. html file

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>enter after how many hours you'd woken up-</title> </head> <body> <form name="form" action="alarmsystem" method="post"> hours  :<input type="text" name="hr"><br> minutes:<input type="text" name="min"><br> seconds:<input type="text" name="sec"><br><br> <input type="submit" value="submit"> </form> </body> </html> 

2. oldjob(basically job execution)

package mayur;  import org.quartz.job; import org.quartz.jobexecutioncontext; import org.quartz.jobexecutionexception;  public class oldjob implements job  {     public void execute(jobexecutioncontext context)         throws jobexecutionexception          {           system.out.println("wake-up!!");         } } 

3. servlet (alarmsystem.java file)

package mayur;  import java.io.ioexception; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import mayur.oldjob; import org.quartz.cronschedulebuilder; import org.quartz.jobbuilder; import org.quartz.jobdetail; import org.quartz.scheduler; import org.quartz.schedulerexception; import org.quartz.trigger; import org.quartz.triggerbuilder; import org.quartz.impl.stdschedulerfactory;  /**  * servlet implementation class newtrigger  */ @webservlet("/alarmsystem") public class alarmsystem extends httpservlet {     private static final long serialversionuid = 1l;      /**      * default constructor.       */     public alarmsystem() {         // todo auto-generated constructor stub     }      /**      * @see httpservlet#doget(httpservletrequest request, httpservletresponse response)      */     protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception     {         string sec=request.getparameter("sec");         string min=request.getparameter("min");         string hr=request.getparameter("hr");         passingmethod(sec,min,hr);      }      /**      * @see httpservlet#dopost(httpservletrequest request, httpservletresponse response)      */     protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         // todo auto-generated method stub     }      public void passingmethod(string sec,string hr, string min)     {             //connect real job execution             jobdetail job=jobbuilder.newjob(oldjob.class).withidentity("firstjob","group").build();             //create trigger             trigger trigger= triggerbuilder.newtrigger().withidentity("firstjob","group").withschedule             (cronschedulebuilder.cronschedule("0/"+sec+" 0/"+min+" 0/"+hr+" * * ?")).build();             //schedule             scheduler scheduler;             try {                 scheduler = new stdschedulerfactory().getscheduler();                  scheduler.start();                    scheduler.schedulejob(job, trigger);             } catch (schedulerexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }       } } 

4.the web.xml page

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version="3.0">   <display-name>frog</display-name>   <servlet>         <servlet-name>frog</servlet-name>         <servlet-class>mayur.alarmsystem</servlet-class>     </servlet>     <servlet-mapping>         <servlet-name>frog</servlet-name>         <url-pattern>/alarmsystem</url-pattern>     </servlet-mapping>    <welcome-file-list>     <welcome-file>index.html</welcome-file>     <welcome-file>index.htm</welcome-file>     <welcome-file>index.jsp</welcome-file>     <welcome-file>default.html</welcome-file>     <welcome-file>default.htm</welcome-file>     <welcome-file>default.jsp</welcome-file>   </welcome-file-list> </web-app> 

and here stacktrace

caused by: java.lang.illegalargumentexception: servlets named [frog] , [mayur.alarmsystem] both mapped url-pattern [/alarmsystem] not permitted     @ org.apache.catalina.deploy.webxml.addservletmapping(webxml.java:335) severe: child container failed during start java.util.concurrent.executionexception: org.apache.catalina.lifecycleexception: failed start component [standardengine[catalina].standardhost[localhost].standardcontext[/frogg]]     @ java.util.concurrent.futuretask.report(unknown source)     @ java.util.concurrent.futuretask.get(unknown source) 

if annotations define web servlet have done @webservlet("/alarmsystem") have configured servlet answering @ context root /alarmsystem.

then defining servlet (the 1 call frog) in web.xml context root url configuration of <url-pattern>/alarmsystem</url-pattern>. in effect have done define 2 servlets mappings, both have same context root.

in order fix should define servlet in code annotations or in web.xml not in both. if keep @webservlet("/alarmsystem") definition, can remove <servlet> , <servlet-mapping> tags in web.xml.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -