javax.servlet.Servletexception: Error instantiating Servlet class

Asked

Viewed 12 times

-2

In trying to access the doPost method, I get a 500 error. Can anyone help me?

  • I created a project with the Maven archetype webapp. -Tomcat 9

Estrutura

inserir a descrição da imagem aqui

Servlet InserirCategoria

web.xml

POM

1 answer

-1

This error usually happens when there is something wrong with the database connection. However, the Tomcat server is only giving you the message that it is not able to initialize the class and right at the bottom line gives you the connection error.

I noticed something in your code that you stated in your Servlet the @Webservelet notation and you have a web.xml file. This may be perhaps the reason for the error, try to clear the web.xml file, you have already mapped it, leave only @Webservelet, and do the test.

If it doesn’t work, your server is not running properly, try reinstalling your Tomcat, and it will probably work. But from what I saw it can still show you another error that is with persistence, however, try to do these other 2 first steps I told you, these 500 errors and something always happens by server errors.

  • Now I left my web.xml file in the original form, without modifications. After modifications~I get error: 404 The requested Resource [/crud-Servlet-jsp/Inserircategoria] is not available

  • So the @Webservelet notation is not doing what it should be doing. Make a new Servlet and use that notation and try to access it from the URL. If it doesn’t work, it is the server that is corrupted. You should reinstall as you mentioned.

  • If it works you already know what to do, pass the methods all to this new Save and delete the old one. Of course, use another similar name, never the same.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.