How to debug Lift applications in Eclipse?

I come from the background in C ++, Python, and Django, and I'm trying to expand my horizons and learn about Scala and Lift. However, it is very difficult for me to understand how to debug Lift applications using eclipse.

I can create projects using some sbt elevator templates and not run them without problems. However, I could not start the application from Eclipse because it cannot find Jetty, and as a result, I cannot use the debugger to navigate through the Lift code. Weeks in search engines did not help.

Can anyone share their methods or suggestions? I'm also new to jvm, so feel free to share best practices or point out important differences that might be missing.

+4
source share
2 answers

Ok, I figured it out.

So, I actually do not start the application from the Eclipse debugger. I launch the application via sbt and then connect the Eclipse remote debugger to sbt vm, which launches webapp.

Here is what I did:

Assuming you have sbt-launch.jar in / bin:

Create the / bin / sbt _debug file with execute permission and containing this line:

java -Xmx512M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar /bin/sbt-launch.jar " $@ " 

What this script does is run sbt and tell jvm to enable debugging on port 5005

Go to your elevator project directory in your terminal and enter sbt_debug. Once you get to the sbt console, enter the container: start / container: update or ~ jetty: start / ~ jetty: update depending on which version of sbt you are using.

Next, go to Eclipse, click the debug icon, and select "Debug Configurations ..."

In the left column, click “Remote Java Application” and create a new debug configuration. Set the port to 5005.

Click the Debug button, and the Eclipse debugger should now debug the sbt process that you started earlier

Note. This is the first method that worked for me. If you have one that is better, please share

+7
source

I found the most useful Eclipse Plugin and RunJettyRun SBT tools for Eclipse. The first allows you to create Eclipse configuration files based on your SBT setup, and the second starts Jetty from Eclipse with an attached debugger. An added bonus is that creating your Eclipse configuration using "eclipse with-source = true" from the SBT prompt will load and attach src banks, and you can also go through Lifting and any other third-party libraries you depend on, and also your own code.

+1
source

Source: https://habr.com/ru/post/1387821/


All Articles