Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to debug JSPs in an AEM custom errorhandler?

Avatar

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

123 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

123 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile
jayv25585659
Level 4

11-08-2019

setup:

1. a local instance of author (running on 4502 and debugging port on 8000) and publisher (running on 4503 and debugging port on 8002)

2. used this guide (Debug an AEM app using eclipse ) to setup 2 debug configurations for my author and publisher local instances

3. Somebody (a person before me) created a custom version of /libs/sling/servlet/errorhandler and placed it in /apps/sling/servlet/errorhandler

My question is on how to do debug the custom JSP page. I placed a breakpoint in the JSP on IntelliJ and it's not stopping on the breakpoint. I know the debugging works as the custom JSP uses a Java class (consisting of 10 lines only) and if I placed a breakpoint somewhere in the class, it stops at that point.

I am looking at this page (Customizing Pages shown by the Error Handler ) and there are no tips on how to debug the custom code.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile
Gaurav-Behl
MVP

12-08-2019

You can write log statements or Sysouts or even add breakpoints like you'd in a normal java class

HTH

Answers (4)

Answers (4)

Avatar

Avatar
Give Back 5
Employee
Andrew_Khoury
Employee

Likes

75 likes

Total Posts

93 posts

Correct Reply

33 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile

Avatar
Give Back 5
Employee
Andrew_Khoury
Employee

Likes

75 likes

Total Posts

93 posts

Correct Reply

33 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile
Andrew_Khoury
Employee

12-08-2019

To find the complied JSP files for debugging you can do the following:

1. Go to http://host:port/system/console/bundles/org.apache.sling.commons.fsclassloader

2. Get the Id bundle

3. On the file system go to crx-quickstart/launchpad/felix/bundleX/data/classes where X is the Id value from step 2.

4. You can add that folder to the source code debug search path of your Eclipse or IntelliJ project for debugging of the jsp.java files. I am assuming here that we are debugging on a local AEM instance.  Otherwise you would have to download the files from that folder to your machine for debugging.

This isn't quite as easy as debugging the actual JSP file.  However, it is useful as you can figure out which line of the jsp.java file maps back to in the non-compiled jsp file.

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,345 likes

Total Posts

3,220 posts

Correct Reply

914 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,345 likes

Total Posts

3,220 posts

Correct Reply

914 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

12-08-2019

Avatar

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

123 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

123 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile
jayv25585659
Level 4

20-08-2019

I tried your suggestion of using log4j,

I modified the first 8 lines of my code to reflect the contents of the SO.com discussion

As you can see, I really didn't do anything other than importing a class and declaring a new variable. The code successfully compiled and when I reloaded my page, I now keep on getting:

Previously I was getting our custom 404 HTML page.

Avatar

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

123 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

123 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile
jayv25585659
Level 4

20-08-2019

using your instructions, I found the bundle ID to be 499. I then loaded the folder inside IntelliJ and then created a new debug configuration. I tried debugging the code and I keep on getting "Source code does not match byte code".