I cant able to run Servlets and fix this error
I created a Maven web project and tried everything, but this error is not going away. However, when I created JSP files, everything worked fine. But when I tried to create a servlet and imported from Jakarta, I got a 404 Not Found error. I also tried importing from javax, but the same error occurred.
I checked the Targeted Runtime, and it's set to Apache Tomcat 10.1 with Jakarta 6.1. In Project Facets, I changed the Dynamic Web Module from 2.3 to 5.0. My JDK version is 23, but after these changes, the situation got even worse. Now, I'm getting a Catalina Lifecycle Exception and an Illegal Argument Exception.

29 Replies
ā
This post has been reserved for your question.
Hey @Mohd Waqar! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
It seems like you are mixing Java EE and Jakarta EE.
Maje sure your web.xml is configured for Jakarta EE
How can i configured this in my web xml
Can you show your web.xml?
I think you have old Java EE references there
Ok wait

yes, line 2 and 3
Okayy
I need to change them
that means
Stack Overflow
Updating "web.xml" when transitioning from Java Servlet 4 to Jakart...
I am transitioning a simple Servlet from using Java Servlet 4 to Jakarta Servlet 5.
I noticed my web.xml file has references to the 4 spec.
<?xml version="1.0" encoding="UTF-8&quo...
essentially start with
or possibly
since you said you are actually using 6.1 I think
Yess
Though I think you should use Jakarta Servlet 6.0 with Tomcat 10.1 and Jakarta Servlet 6.1 with Tomcat 11
Okayy i changed the jakarta version and the web xml file the red marks from my files are gone
but its showing again error

Can you show your new web.xml and also the full output shown in the console tab?
btw please don't use screenshots for text but instead use code blocks
Okay
The servlets named [SaveNoteServlet] and [com.servlets.SaveNoteServlet] are both mapped to the url-pattern [/SaveNoteServlet] which is not permittedDo you use annotations for SaveNoteServlet?
Yess
you should only declare these things once
either with annotations or in the web.xml
so you can just remove the <servlet> and <servlet-mapping> elements from your web.xml
Okayy
Broo You are geniuss
Its totally running fineee
I have just seen these things before
Okayy
daniel loves when people call him 'your sudoness'
you should say it to show how grateful you are
for solving the problem
š±
purely optional though
I don't
Well i am new to this community so i need to learn things š
no worries you can learn along the way
Post Closed
This post has been closed by <@1077604975741505716>.