0

I am trying to set up a break point in my controller so that I can debug my spring boot web application within spacemacs. Can someone walk me through the steps on doing this.

The steps I have done so far are

  1. start up the spring boot application in debug mode with the 8000 port as the debug port. I did this by adding to my pom the following.
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000</jvmArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>

  1. execute the mvn spring-boot:run command. I have added the entire command run below with the logs. It does show 8000 port listening
  2. M-x dap-debug
  3. I select Java-Attach
  4. I enter 8000 as the debug port

I have added an image of my controller that has breakpoints. One thing I notice is that in the bottom bar it shows localhost(8000) - pending. So it seems that dap does not attach to the debug port.

I am not sure if this is relevant to this issue, but I am currently spacemacs develop branch.

~/P/b/backup02-after-hello-world-path-param λ mvn spring-boot:run
[INFO] Scanning for projects...
[INFO] 
[INFO] -------< com.in28minutes.rest.webservices:restful-web-services >--------
[INFO] Building restful-web-services 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) > test-compile @ restful-web-services >>>
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ restful-web-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ restful-web-services ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ restful-web-services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory c:\Users\dmsil\Projects\backup02-after-hello-world-path-param\backup02-after-hello-world-path-param\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ restful-web-services ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) < test-compile @ restful-web-services <<<
[INFO] 
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) @ restful-web-services ---
[INFO] Attaching agents: []
Listening for transport dt_socket at address: 8000
10:19:35.252 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
10:19:35.254 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
10:19:35.256 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/C:/Users/dmsil/Projects/backup02-after-hello-world-path-param/backup02-after-hello-world-path-param/target/classes/]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.0.RELEASE)

2020-03-21 10:19:35.590  INFO 10852 --- [  restartedMain] c.i.r.w.r.RestfulWebServicesApplication  : Starting RestfulWebServicesApplication on DESKTOP-CQC5H52 with PID 10852 (C:\Users\dmsil\Projects\backup02-after-hello-world-path-param\backup02-after-hello-world-path-param\target\classes started by dmsil in c:\Users\dmsil\Projects\backup02-after-hello-world-path-param\backup02-after-hello-world-path-param)
2020-03-21 10:19:35.591  INFO 10852 --- [  restartedMain] c.i.r.w.r.RestfulWebServicesApplication  : No active profile set, falling back to default profiles: default
2020-03-21 10:19:35.642  INFO 10852 --- [  restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2e66ae0c: startup date [Sat Mar 21 10:19:35 EDT 2020]; root of context hierarchy
2020-03-21 10:19:37.086  INFO 10852 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$f29ac588] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-21 10:19:38.020  INFO 10852 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-03-21 10:19:38.045  INFO 10852 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-03-21 10:19:38.045  INFO 10852 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.28
2020-03-21 10:19:38.054  INFO 10852 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_241\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;c:\Windows\system32;c:\Windows;c:\Windows\System32\Wbem;c:\Windows\System32\WindowsPowerShell\v1.0;c:\Windows\System32\OpenSSH;c:\apache-maven-3.6.3\bin;c:\Program Files\Git\cmd;c:\Program Files\Java\jdk1.8.0_241\bin;c:\Program Files (x86)\Common Files\Oracle\Java\javapath;c:\Users\dmsil\AppData\Local\Microsoft\WindowsApps;.;c:\emacs-26.3-x86_64\libexec\emacs\26.3\x86_64-w64-mingw32;;.]
2020-03-21 10:19:38.158  INFO 10852 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-03-21 10:19:38.158  INFO 10852 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2518 ms
2020-03-21 10:19:38.339  INFO 10852 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2020-03-21 10:19:38.340  INFO 10852 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet webServlet mapped to [/h2-console/*]
2020-03-21 10:19:38.340  INFO 10852 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2020-03-21 10:19:38.344  INFO 10852 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2020-03-21 10:19:38.344  INFO 10852 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2020-03-21 10:19:38.344  INFO 10852 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2020-03-21 10:19:38.506  INFO 10852 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-03-21 10:19:38.687  INFO 10852 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-03-21 10:19:38.738  INFO 10852 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2020-03-21 10:19:38.760  INFO 10852 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2020-03-21 10:19:38.832  INFO 10852 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.14.Final}
2020-03-21 10:19:38.836  INFO 10852 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2020-03-21 10:19:38.881  INFO 10852 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2020-03-21 10:19:39.005  INFO 10852 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-03-21 10:19:39.265  INFO 10852 --- [  restartedMain] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@27ee34'
2020-03-21 10:19:39.269  INFO 10852 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-03-21 10:19:39.737  INFO 10852 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2e66ae0c: startup date [Sat Mar 21 10:19:35 EDT 2020]; root of context hierarchy
2020-03-21 10:19:39.813  WARN 10852 --- [  restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-03-21 10:19:39.867  INFO 10852 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello-world/path-variable/{name}],methods=[GET]}" onto public com.in28minutes.rest.webservices.restfulwebservices.HelloWorldBean com.in28minutes.rest.webservices.restfulwebservices.HelloWorldController.helloWorldPathVariable(java.lang.String)
2020-03-21 10:19:39.868  INFO 10852 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello-world],methods=[GET]}" onto public java.lang.String com.in28minutes.rest.webservices.restfulwebservices.HelloWorldController.helloWorld()
2020-03-21 10:19:39.868  INFO 10852 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello-world-bean],methods=[GET]}" onto public com.in28minutes.rest.webservices.restfulwebservices.HelloWorldBean com.in28minutes.rest.webservices.restfulwebservices.HelloWorldController.helloWorldBean()
2020-03-21 10:19:39.874  INFO 10852 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2020-03-21 10:19:39.875  INFO 10852 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2020-03-21 10:19:39.945  INFO 10852 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-03-21 10:19:39.945  INFO 10852 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-03-21 10:19:40.006  INFO 10852 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-03-21 10:19:40.305  INFO 10852 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2020-03-21 10:19:40.508  INFO 10852 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2020-03-21 10:19:40.508  INFO 10852 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
2020-03-21 10:19:40.513  INFO 10852 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2020-03-21 10:19:40.544  INFO 10852 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-03-21 10:19:40.548  INFO 10852 --- [  restartedMain] c.i.r.w.r.RestfulWebServicesApplication  : Started RestfulWebServicesApplication in 5.279 seconds (JVM running for 5.795)

Picture of my controller with breakpoints

1

There is currently a bug in the dap java package that is preventing dap from running on Windows operating system.

I was able to run it successfully in mac os. I also assume it should work on Linux too.

I found a git ticket on this issue https://github.com/emacs-lsp/dap-mode/issues/214

Hopefully someone will fix this bug in the future.

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.