Maven doesn't compile webapp

2019-06-11 13:22发布

问题:

Before I made a simple dynamic web project with websockets and without maven, it works fine. Now I try to use maven. But when I'm compiling my project with mvn compile jetty:run it doesn't build with javax.servlet.UnavailableException: Servlet class com.example.testbattle.ServerSide is not a javax.servlet.Servlet exception. It requires to implement Servlet interface. Why didn't I need it with simple dynamic web project. How could I avoid this problem?

UPDATE: I have found out the problem it was wrong web.xml Now I can't launch serverside. What should I put into web.xml?

回答1:

Such an error reports that you are trying to register pass an non servlet class as a servlet one, meaning here that obviousely com.example.testbattle.ServerSide does not implement javax.servlet.Servlet or extend a subclass of it.

If com.example.testbattle.ServerSide is intended to be your Servlet application entry point then go ahead an implement the mentioned interface and all its derived methods (onService...).