@WebServlet fails in Netbeans 11.0 with java.lang.RuntimeException: com.example.NewServlet.<init>(NewServlet.java:1)
Solution 1:
I encountered this problem in Netbeans 12.0 today using OpenJDK 14. It turns out the problem was resolved by installing the nb-javac plugin.
Solution 2:
The fault was in Apache NetBeans 11. In later version (still unofficial) 11.1 the Servlet annotations works as it should be, even without web.xml file. Tested with Apache Tomcat 9.0.22 and Glassfish 5.0.1 on Apache NetBeans IDE 11.1 (available for download from this web page).