Issue
I'm using Netbeans 12.3 as IDE and I was used to manage different webapplication projects serviced by tomcat.
From a day to another I cannot run any web project anymore.
I even tested with a new empty project and an empty ServletContextListener implementation
package stica;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class NewServletListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {}
@Override
public void contextDestroyed(ServletContextEvent sce) {}
}
The results are the same for all my web applications:
30-Jun-2021 21:37:00.981 GRAVE [http-nio-8080-exec-28] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [stica.NewServletListener]
java.lang.RuntimeException:
at stica.NewServletListener.<init>(NewServletListener.java:1)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4640)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5172)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:692)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:689)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:537)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1683)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:288)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1592)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:1021)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:356)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:667)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:378)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:56)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
30-Jun-2021 21:37:00.981 GRAVE [http-nio-8080-exec-28] org.apache.catalina.core.StandardContext.listenerStart Skipped installing application listeners due to previous error(s)
The listener is loaded using web.xml:
<listener>
<description>ServletContextListener</description>
<listener-class>stica.NewServletListener</listener-class>
</listener>
RuntimeException at line 1 with no other meaningful (at least not to me) explanations.
I tryed different versions of Tomcat (8.5.50, 9.0.44, 9.0.46) and different combination of jdk for sources, libraries etcetera (8 and 14, the base for the IDE). I even tryed with two netbeans versions: 12 and 12.3.
The projects doesn't run, no matter what I do.
I am desperate.
Solution
Ok, I found out the cause... very stupid. I post it hoping it would be of any help for whoever else might fall in this trap.
My Netbeans uses java 14 as default jdk (that I wrongly thought was built-in - and this is why I didn't tested before as suggested by @skomisa)
In order to use it you must install nb-javac plugin which is normally always present because netbeans itself prompts you to add it at the first run on a fresh new install. Don't know why on mine it wasn't...
Answered By - Azathoth
Answer Checked By - Clifford M. (JavaFixing Volunteer)