cancel
Showing results for 
Search instead for 
Did you mean: 

attach debug not work for Java based CAP project on local PC

kevin_zhang01
Employee
Employee

Hi Colleagues,

i am new for Java CAP development. Now i face an issue how to attach debug for Java CAP project.

my environment:

windows 11, VS code, SAP Machine JDK 17.

have set for maven_opts in win 11 system advanced environment

in VS code, launch.json

Project structure:

Steps:

1. in VS code terminal, run command mvn spring-boot:run

2. in VS code RUN and DEBUG, run attach command, seem that in debug mode, we can see debug button

3. set break point in java custom handler method, click a button on APP UI, (trigger post http method)

expect: break point at the own code

actual: nothing happened.

So can some one give me some hint?

i check cap wiki https://cap.cloud.sap/ , seems no chapter mentioned how to debug CAP project.

Best Wishes.

Kevin

View Entire Topic
robinjayasinghe
Advisor
Advisor
0 Kudos

In case you have attached the debugger correctly to the Maven process but your break point is not triggered it might be that the handler code has not been called. You can make sure by adding some debug logging to the handler code and see if the debug log (log with level INFO) is printer on the console. If it's not printed the code is not called. If it is printed something else is wrong.

As a CAP Java application is just a normal Spring Boot application it can be debugged very easily by just running the Application class from th... You only need an initial Maven build to trigger the CDS build. Afterwards a Maven build for each CDS model change is needed, too. Or you can watch this video (shameless plug) that shows efficient development turnaround for CAP Java applications. There is also some documentation for that on Capire.

HTH!

marcbecker
Contributor
0 Kudos

Another problem might be that you are actually debugging the Maven process and not the Spring Boot process launched by the Maven process. However I'd as Robin suggested also highly suggest simply launching the Application class directly from your IDE, in that case debugging simply works out of the box.