By now, most web containers have an annotation variant of their xml configurations for Java EE. I'm guessing this is because it's better to keep things in Java where they can be managed, coded with and controlled. The problem, however, still remains that with annotations you cannot efficiently debug and diagnose an issue because when an exception is thrown it doesn't give you the full stack but instead, just the head.

The reason why this happens is because annotations use reflection and debugging will not work in reflection unless a coder places their own breakpoints which is not always possible.

Does anyone have a way around this or has anyone experienced the same problem when fixing issues on a Java EE web application?


Annotations by design, aren't meant to be debugged. They're just markers on your code, for instance in Hibernate, to say if a entity is related to another entity.

To put that into perspective, you wouldn't debug a table relationship or the actual

@OneToMany(fetch=FetchType.LAZY, mappedBy="person")

Just as if you were using Spring for MVC as you mention web applications, if you were debugging a web application, you wouldn't actually be debugging the @Controller annotation, you'd be debugging what the controller method actually did.

| improve this answer | |
  • 2
    Thank you for the above. Good thing you mentioned Spring MVC because that's the perfect scenario for this type of issue. I find that whenever I'm debugging an issue on a spring web application I have to use google to help me or just play around until it works - taking random shots in the dark. It would be so much easier if when debugging, when it got to the @Controller annotation it just went to the respective controller without me having to manually put breakpoints. – Noobcanon Oct 28 '14 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.