How to get Scala debugging to work in Eclipse

2,977 views
Skip to first unread message

chungonn

unread,
Nov 15, 2010, 9:58:22 AM11/15/10
to Scala IDE User
Hi,

I am trying to debug a Scala application developed using Play
framework but failed. It seems the eclipse debugger is not able to
find the Scala source, is there anything I need to prep the Scala
plugin to correctly pick up the scala source code? I am using Eclipse
JEE Galileo R2, and 2 versions of Scala Plugin - 2.8.1 Final & 2.8.1
Nightly build.

Any help is greatly appreciated

Alex Black

unread,
Nov 15, 2010, 10:10:51 PM11/15/10
to Scala IDE User
Are you able to debug any scala code? Say a hello world application
you made?

I've had no trouble doing basic debugging with fairly large projects
of ours, I just set break points, and fire it up (launching with debug
as).

- Alex

chungonn

unread,
Nov 16, 2010, 12:41:14 AM11/16/10
to Scala IDE User
I just tested, it works with HelloWorld.

To debug Play, we need to start the Play server first and attach a
remote debugger. The debugger seems working except it can't view the
source code. I am doing now is looking at the debugger line number and
manually jump to the relevant line in the source code.

chungonn

unread,
Nov 16, 2010, 3:10:22 AM11/16/10
to Scala IDE User
I think I figure where's the problem. I am debugging it as a remote
Java application instead of a Scala application and hence it can't
find the source. The question now is how do I setup a Remote Scala
debugging environment. Any advice?

David Bernard

unread,
Nov 16, 2010, 3:22:31 AM11/16/10
to scala-i...@googlegroups.com
naïves questions :
* your remote application configuration point to the right project,
and source tab list the right folder ?
* your directory layout match you package layout ? (else eclipse can't
find source)

/davidB

David Bernard

unread,
Nov 16, 2010, 3:33:57 AM11/16/10
to scala-i...@googlegroups.com
I just did a remote debugging (Java Application Remote Debug) on a
lift app, launch with

MAVEN_OPTS='-Xdebug
-Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y' mvn
jetty:run

I set the breakpoint on a method, and the process suspend at right
place, and display the right source. I also cick on an other place
(other class of the project) in the stacktrace, and the source jump to
the right.

/davidB

chungonn

unread,
Nov 16, 2010, 7:08:34 AM11/16/10
to Scala IDE User
Hi David,

Thanks for giving me all the tips, I checked the debug configurations,
everything is in place. This is the same setting I used to debug
Play's java classes. I am not using mvn:jetty, i just need to run the
Play server. That's very much it.

Any other suggestions?

On Nov 16, 4:33 pm, David Bernard <david.bernard...@gmail.com> wrote:
> I just did a remote debugging (Java Application Remote Debug) on a
> lift app, launch with
>
> MAVEN_OPTS='-Xdebug
> -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y' mvn
> jetty:run
>
> I set the breakpoint on a method, and the process suspend at right
> place, and display the right source. I also cick on an other place
> (other class of the project) in the stacktrace, and the source jump to
> the right.
>
> /davidB
>
> On Tue, Nov 16, 2010 at 09:22, David Bernard <david.bernard...@gmail.com> wrote:
> > naïves questions :
> > * your remote application configuration point to the right project,
> > and source tab list the right folder ?
> > * your directory layout match you package layout ? (else eclipse can't
> > find source)
>
> > /davidB
>

David Bernard

unread,
Nov 16, 2010, 7:28:09 AM11/16/10
to scala-i...@googlegroups.com
If you could share a sample play+scala project, I could give a try.
(archive, github)

and the instruction you use to run play in debug mode.

/davidB

chungonn

unread,
Nov 16, 2010, 8:21:52 AM11/16/10
to Scala IDE User
Hi David,

I really appreciate your offer to help. Thanks in advance.

I have create a simple HelloWorld app in Play that uses the Scala
module which I have push to GitHub.
https://github.com/chungonn/PlayScalaHelloWorld/commits/master

Once you have pulled the repo, then you need to do the following

1. Install Play -
http://download.playframework.org/releases/play-1.1.zip

2. Checkout the HelloWorld project (above) and install Play's Scala
module. After you have downloaded the code, 'cd' to the project and
inside the project run the following command. You may need to rename
the folder from ScalaHelloWorld to HelloWorld
play install scala

3. Setup eclipse environment, this would setup all the eclipse
artefacts
play ec

4. Import this project into Eclipse

5. Run Test-cases (This is to run all the test cases)
play test

6. Do the remote debugging, go to eclipse, look for the HelloWorld
project, there is a sub-folder "eclipse". In this sub-folder select
the "Connect JPDA to HelloWorld.launch" and use the context menu
"Debug As" to run remote debug.

7. Set your breakpoints in the following testcases - BasicTest.java
and TestScala.scala

8. Prepare to initiate tests - use any browser and point to following
url - http://localhost:9000/@tests

9. Initiate the test in browser by selecting the above 2 testcases

You would notice that the debugger works nicely for the java code but
not the scala code


Please let me know if you need any clarifications. Thanks once again.


On Nov 16, 8:28 pm, David Bernard <david.bernard...@gmail.com> wrote:
> If you could share a sample play+scala project, I could give a try.
> (archive, github)
>
> and the instruction you use to run play in debug mode.
>
> /davidB
>

David Bernard

unread,
Nov 16, 2010, 8:53:50 AM11/16/10
to scala-i...@googlegroups.com
I stop at point 7
I don't have 7 BasicTest.java and TestScala.scala (nor test directory)
I had to modify the play script to use python2 (python3 is my default
and the play script is not a valid python3 script).

/davidB

chungonn

unread,
Nov 16, 2010, 9:16:25 AM11/16/10
to Scala IDE User
Hi David,

I have pushed the test cases up and you do a pull again. So sorry, i
unwittingly added the test folder in the .gitignore file

Please let me know if you have any problem. Thanks once again

On Nov 16, 9:53 pm, David Bernard <david.bernard...@gmail.com> wrote:
> I stop at point 7
> I don't have 7 BasicTest.java and TestScala.scala (nor test directory)
> I had to modify the play script to use python2 (python3 is my default
> and the play script is not a valid python3 script).
>
> /davidB
>
> > url -http://localhost:9000/@tests

David Bernard

unread,
Nov 16, 2010, 9:47:13 AM11/16/10
to scala-i...@googlegroups.com
I reproduce the issue, but currently I don't find solution :(

/davidB

David Bernard

unread,
Nov 16, 2010, 9:51:17 AM11/16/10
to scala-i...@googlegroups.com
path store in the .class compiled from .scala are wrong. May be a
issue in the Play scala plugin, not called with right parameters.

/davidB

chungonn

unread,
Nov 16, 2010, 9:52:11 AM11/16/10
to Scala IDE User
Thanks for helping to look into my problem. I am trying to get it
going in the last couple of days :( also I am combing as much
documentation about Scala + Play as possible and hoping to find the
solution...



On Nov 16, 10:47 pm, David Bernard <david.bernard...@gmail.com> wrote:
> I reproduce the issue, but currently I don't find solution :(
>
> /davidB
>

chungonn

unread,
Nov 16, 2010, 10:04:26 AM11/16/10
to Scala IDE User
I have raised an issue in Play-Scala module and hopefully it get
solved :)

https://github.com/guillaumebort/play-scala/issues/issue/38

David Bernard

unread,
Nov 16, 2010, 10:05:06 AM11/16/10
to scala-i...@googlegroups.com
IMO, it's a issue with the play-scala plugin : debug information in
bytecode are wrong :
// Compiled from test/TestScala.scala
instead of
// Compiled from TestScala.scala

print the stackTrace from TestScala, the path of scala files are wrong.

My impression seems to be confirm by an overlook to src of scala-plugin.

/davidB

chungonn

unread,
Nov 16, 2010, 7:36:35 PM11/16/10
to Scala IDE User
David,

THANK YOU for zooming into the matter and shedding light on it.

Have a good day ahead.

Cheers!

On Nov 16, 11:05 pm, David Bernard <david.bernard...@gmail.com> wrote:
> IMO, it's a issue with the play-scala plugin : debug information in
> bytecode are wrong :
> // Compiled from test/TestScala.scala
> instead of
> // Compiled from TestScala.scala
>
> print the stackTrace from TestScala, the path of scala files are wrong.
>
> My impression seems to be confirm by an overlook to src of scala-plugin.
>
> /davidB
>

chungonn

unread,
Nov 17, 2010, 3:29:20 AM11/17/10
to Scala IDE User
Hi David,

I spent practically the whole looking into the problem. And I found
that I can debug class compile by Play-Scala plugin in Eclipse IDE.
Here's what I have done.

1. Change the HelloWorld output folder to HelloWorld/tmp/classes
2. Compile Hi.scala class in the test folder myPackage using - play
test
3. Debug Hi.scala using context menu Debug As -> Scala Applicaton

To me, this exercise shows that Play-Scala compiler is compiling
correctly despite there is a comment stating that it was compile from
a 'test' folder i.e. "test/myPackage/Hi.scala"

I am at my wits end. I guess Play folks can get find a solution to
this.

Ike

unread,
Dec 3, 2010, 11:26:34 AM12/3/10
to Scala IDE User
David, do you know which parameters need to be tweaked on the compiler
to alter how the debugging information is generated?

David Bernard

unread,
Dec 3, 2010, 11:45:41 AM12/3/10
to scala-i...@googlegroups.com
No, but it seems that the source directory is set to root of the
project instead of real source directory.

Michael

unread,
Jan 13, 2011, 1:08:49 AM1/13/11
to Scala IDE User
Is there a progress with this bug?

I want to switch to a Play framework, but inability to debug is
a deal breaker for me.

I looked into compiled class and it has the absolute path for debug
info. Anyone knows how to change this?

On Nov 16 2010, 4:51 pm, David Bernard <david.bernard...@gmail.com>
wrote:

David Bernard

unread,
Jan 13, 2011, 3:38:46 AM1/13/11
to scala-i...@googlegroups.com
On Thu, Jan 13, 2011 at 07:08, Michael <mi...@mzlab.net> wrote:
Is there a progress with this bug?

No on scala-ide side
As I'm not a Play user , I'll not hack the Play's plugin for scalac (and I've no time for).


I want to switch to a Play framework, but inability to debug is
a deal breaker for me.

I looked into compiled class and it has the absolute path for debug
info. Anyone knows how to change this?

IIRC there is a workaround somewhere in the message thread.

/davidB
Reply all
Reply to author
Forward
0 new messages