Debug with IntelliJ

Hi,

I haven’t worked with Vaadin for 3 years now because I changed job, but I need to do a small POC and I am trying to use Vaadin again.

I have a vaadin-spring-boot-starter 12.0.5 up and running. I have even done some small development and everything is good.
My only problem is that I am not capable to debug the java code. I run the spring-boot:run in debug mode but it doesn’t stop in the breakpoints. I also tried to start a remote debugger on port 8000 but it doesn’t work either.

Can somebody advise on how to debug? I’m sure I’m missing something stupid, because I remember being able to debug the code without problems when I worked with it some years ago.

I have experienced the same as you. Adding this configuration to the plugin definition in the .pom solved it for me:

<plugins>
	<plugin>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-maven-plugin</artifactId>
		<!-- my edits start -->
		<configuration>
			<jvmArguments>
				-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
			</jvmArguments>
		</configuration>
		<!-- my edits end -->
	</plugin>
</plugins>

With this (inperfect) addition, it will now wait for your remote debugger on port 5005.
However this will make all spring boot runs run in debug mode. I know too little about maven to be able to provide you with a solution that only applies when you run in debug mode. Maybe others can provide better information.

Until then, you can paste this in when you need to debug and comment it out when you want to run it without debugger.

Hi,

Thank you very much for your reply. Unfortunately it didn’t work for me :frowning:
Aren’t these jvmArguments supposed to run when I run the remote debug also?

I am quite bad with these things and I don’t know where the problem could possible be:

  • Are the debug settings configuration in IntelliJ relevant?
  • Do I need to change something in the Tomcat? (it’s local)
  • What port should the debugger be listening to and where is this configured?
  • Should I have something like -Dvaadin.productionMode=false ?

I forgot to say that when I try to run the remote debug it either says “Connection refused” or “handshake failed” in case the port is the same as the one in the IntelliJ debug configuration.

Are you certain that your remote debugger used the port 5005 when you tried my semi-solution?
After you start spring-boot:run (in debug mode or not does not matter with my solution) you click Run -> Debug -> Edit Configurations.. and create a new Configuration of type Remote. Here is a screenshot of my remote debugger configuration for this spring boot debug: [https://imgur.com/P71J2Gb]
(https://imgur.com/P71J2Gb)

I fear that for the other questions of yours I have no answer to. But I hope it works now for you too :slight_smile:

Hi Kaspar,
I can’t see your picture, but I think I did everything correct. I copied your solution into my pom, I run the spring-boot:run, and then I run a Remote debug for port 5005.

That’s why I was a little bit concerned that the problem might be somewhere else…

yes I had problems adding the image using markdown. I changed it to a hyperlink, it should work now.
Something important about my screenshot are the command line arguments for remote JVM: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005. If it still doesn’t work, I can’t help you further, sorry.

Edit: but does the spring-boot:run now at least wait for a remote debugger?

Hi, I don’t know how to tell if spring-boot:run is waiting for the remote dubugger, but I guess not, since I don’t see anything in the logs. And it is not that it doesn’t want to debug, it’s that I can’t even start the debugger, I get “Connection refused: connect”.
I have exactly the same as you in the remote debugger.

I don’t really know where my problem is, but I suppose that it is not Vaadin related, and if I get to make the remote debugger work, it will be ok.
Thank you for your help :slight_smile:

Good and bad news. I could start the debugger by removing the jvmarguments in the pom and putting them in the VM Options in the Runner tab of my Run configuration.
Now I get the “Listening for transport dt_socket at address: 5005” and the debugger starts.
Unfortunately, it still doesn’t stop at the breakpoints :frowning:

I found out why did I have so many problems and it is something somewhat weird. I hope this helps somebody.

I don’t need the remote debugger or to add additional jvm parameters to be able to debug, my problem was a dependency in the pom: spring-boot-devtools. Once I removed this dependency I can debug by just by normally debugging my run configuration on IntelliJ.