Issue
I am trying to filter incoming HTTP requests using a OncePerRequestFilter
implementation. The bean for this is instantiated successfully, however, when running the project using mvn jetty:run
, I am getting a java.lang.NoSuchMethodException
with the following stack trace:
javax.servlet.ServletException: java.lang.NoSuchMethodException: com.nextscm.proxy.config.InboundLoggingFilter.<init>()
at org.eclipse.jetty.servlet.ServletContextHandler$Context.createFilter (ServletContextHandler.java:1362)
at org.eclipse.jetty.servlet.FilterHolder.initialize (FilterHolder.java:122)
at org.eclipse.jetty.servlet.ServletHandler.initialize (ServletHandler.java:741)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:374)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp (WebAppContext.java:1497)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp (JettyWebAppContext.java:360)
at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1459)
at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:847)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart (ServletContextHandler.java:287)
at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:545)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:428)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:138)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:113)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart (ContextHandlerCollection.java:168)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:138)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:113)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start (Server.java:416)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart (Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty (AbstractJettyMojo.java:477)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute (AbstractJettyMojo.java:343)
at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:169)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NoSuchMethodException: com.nextscm.proxy.config.InboundLoggingFilter.<init>()
at java.lang.Class.getConstructor0 (Class.java:3082)
at java.lang.Class.getDeclaredConstructor (Class.java:2178)
at org.eclipse.jetty.server.handler.ContextHandler$Context.createInstance (ContextHandler.java:2655)
at org.eclipse.jetty.servlet.ServletContextHandler$Context.createFilter (ServletContextHandler.java:1356)
at org.eclipse.jetty.servlet.FilterHolder.initialize (FilterHolder.java:122)
at org.eclipse.jetty.servlet.ServletHandler.initialize (ServletHandler.java:741)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:374)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp (WebAppContext.java:1497)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp (JettyWebAppContext.java:360)
at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1459)
at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:847)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart (ServletContextHandler.java:287)
at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:545)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:428)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:138)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:113)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart (ContextHandlerCollection.java:168)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:138)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:113)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start (Server.java:416)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart (Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty (AbstractJettyMojo.java:477)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute (AbstractJettyMojo.java:343)
at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:169)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
I am usure what method is being referenced in this Exception as I have tried the same filter in a different project, without any additional methods, and it worked fine. What could be causing this?
Solution
java.lang.NoSuchMethodException: com.nextscm.proxy.config.InboundLoggingFilter.<init>()
This tells me, that the class InboundLoggingFilter doesn't have an empty constructor. Maybe check your implementation of the object and the documentation. Without the code however, it will be hard to help you.
Answered By - koleon03
Answer Checked By - Mildred Charles (JavaFixing Admin)