Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug Lift applications in Eclipse?

I come from a background in C++, Python, and Django and I'm trying to expand my horizons and learn Scala and Lift. However, I'm having a really hard time figuring out how to debug Lift applications using eclipse.

I can create projects using some of the lift sbt templates and run them no problem. However, I haven't been able to start the application from within Eclipse because it can't find Jetty, and as a result, I'm not able to use the debugger to step through the Lift code. Weeks of googling haven't helped much.

Could someone share their methods or suggestions? I'm also new to the jvm, so feel free to share best practices or point out important differences that I may be missing.

like image 481
Blake Avatar asked Feb 22 '23 00:02

Blake


1 Answers

Ok, I've gotten this figured out.

So I'm not actually launching the application from the Eclipse debugger. I'm starting the application through sbt, and then connecting the Eclipse remote debugger to the sbt vm that's running the webapp.

Here's what I did:

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

Create the file /bin/sbt_debug with permission to execute 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 is doing is starting sbt and instructing the jvm to allow debugging on port 5005

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

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

On the left column, click "Remote Java Application" and create a new debug configuration. Set the Port to 5005.

Hit the Debug button and the Eclipse debugger should now be debugging the sbt process you started earlier

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

like image 124
Blake Avatar answered Mar 04 '23 00:03

Blake