Pat Seneker
Pat Seneker

Reputation: 21

Seeing NoSuchMethodExceptions with spring annotations

I have an application that I support, and when I took a JFR of it running I noticed it was throwing hundreds of exceptions per second, but otherwise working fine. I'd like to know the reasons for these exceptions.

I have the following code (I'm not a developer, just a server admin):

 sidebar.java contains:
@Controller
public class sidebarController

 vfolder.java contains:
@Controller
public class vfolderController extends sidebarController

 claim.java: contains:
@Controller
public class claimController extends sidebarController

The exceptions I'm seeing thrown and captured at runtime are from AnnotationUtils.findAnnotation, and are all for methods that are in vfolder and claim, but the exception message says it's looking for methods in the sidebar class i.e. com.company.sidebarController.randomVFolderFunction(java.lang.String) instead of looking in com.company.vfolder. How should I proceed? Is this by design? I can't imagine it's supposed to be throwing this many exceptions. Example stack trace:

Exception java.lang.NoSuchMethodException "com.company.sidebarController.randomVFolderFunction(java.lang.String)"
java.lang.Throwable.<init>(String)
java.lang.Exception.<init>(String)
java.lang.ReflectiveOperationException.<init>(String)
java.lang.NoSuchMethodException.<init>(String)
java.lang.Class.getDeclaredMethod.<init>(String, Class[])
org.springframework.core.annotation.AnnotationUtils.findAnnotation(Method, Class)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.getModelAndView(Method, Class, Object, ExtendedModelMap, ServletWebRequest)
...

Is this because of the vfolder and claim classes extending sidebar? I'm just wondering what direction I could point a developer in regarding this.

Upvotes: 2

Views: 207

Answers (1)

Naami
Naami

Reputation: 358

try to remove @Controller from vfolderController and claimController

sidebar.java contains:

@Controller
public class sidebarController

vfolder.java contains:

public class vfolderController extends sidebarController

claim.java: contains:

 public class claimController extends sidebarController

or Abstract Controller

Upvotes: 1

Related Questions