Debugging help with ScalaIDE

瀏覽次數:58 次
跳到第一則未讀訊息

Henrik Härkönen

未讀,
2016年6月21日 下午1:56:052016/6/21
收件者:Lift
Hello everyone!

In my work I've been recently doing web dev with C# / .NET and while I'm not that happy about it's web aspects, especially when compared to Lift, I am quite impressed with the debugging capabilities in that environment. Thus, I wanted to try out how that works with ScalaIDE (Eclipse) and Lift! :)

So, I took this recent template project:

Lift v3.0 Template Application with Bootstrap v3

and run sbt, and with command "eclipse with-source=true" I generated the eclipse project for the lift project.
Loaded that with ScalaIDE, and tried to run the RunWebApp.scala with Scala Application run profile, but I get this error:

"Error: Could not find or load main class RunWebApp" (actually the first error pop-up said something like "there is compilation errors, should I still run?")

The Problems tab show two errors, both are similar:

"error while loading Action, class file 'C:\Users\hehar\.ivy2\cache\org.specs2\specs2_2.11\jars\specs2_2.11-2.3.12.jar(org/specs2/specification/Action.class)' is broken (class java.lang.RuntimeException/error reading Scala signature of Action.class: scala.reflect.internal.Symbols$NoSymbol cannot be cast to scala.reflect.internal.Symbols$ClassSymbol)"

Can anyone see what am I doing wrong? :) From shell & sbt cli the project compiles and runs ok with "container:start" command.


Thanks,
Henrik.

Diego Medina

未讀,
2016年6月21日 下午2:00:482016/6/21
收件者:Lift
Everyone has their preference on IDE, but I most of the time heard negative comments about ScalaIDE (some really like, it, etc), but I always have good experiences with Intellij.

A while ago I wrote this article
that describes how to use intellij 11 to debug a Lift app
While the latest Intellij version is 15 or something like that, the menus haven't changed much so it is still relevant.

P.S. You start the app from sbt, not inside the IDE for intellij (you may be able to, but I know for sure you can debug it if you start from sbt)

Hope that helps.

Diego






--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
http://blog.fmpwizard.com/

Peter Petersson

未讀,
2016年6月21日 下午3:37:472016/6/21
收件者:lif...@googlegroups.com
Hi

You are on the right track but I think you have found a bug, my guess is that this is a binary incomparability issue with the specs2 version and java 8. If no one else
When this issue is resolved you can take a look at [1] below for instructions.


I just tried it out and I get the following error when i run 'sbt test' in the console (see trace bellow)
Note: running 'sbt test' will enable debugging in Eclipse (or it should) as it will compile the RunWebApp.scala file as instructed from here [1]

[1] https://app.assembla.com/spaces/liftweb/wiki/sbt_0_12_and_Eclipse_Indigo

>sbt test
[info] Loading project definition from /usr/local/proj/private/lift_30_sbt/lift_advanced_bs3/project
[info] Set current project to Lift v3.0 Template Application with Bootstrap v3 (in build file:/usr/local/proj/private/lift_30_sbt/lift_advanced_bs3/)
[info] Compiling 2 Scala sources to /usr/local/proj/private/lift_30_sbt/lift_advanced_bs3/target/scala-2.11/test-classes...
java.lang.ClassCastException: scala.reflect.internal.Symbols$NoSymbol cannot be cast to scala.reflect.internal.Symbols$ClassSymbol
    at scala.reflect.internal.Symbols$Symbol.newLinkedModule(Symbols.scala:300)
    at scala.reflect.internal.pickling.UnPickler$Scan.readSymbol(UnPickler.scala:362)
    at scala.reflect.internal.pickling.UnPickler$Scan.run(UnPickler.scala:87)
  :
[error] error while loading Action, class file '/home/peter/.ivy2/cache/org.specs2/specs2_2.11/jars/specs2_2.11-2.3.12.jar(org/specs2/specification/Action.class)' is broken
[error] (class java.lang.RuntimeException/error reading Scala signature of Action.class: scala.reflect.internal.Symbols$NoSymbol cannot be cast to scala.reflect.internal.Symbols$ClassSymbol)

Switching to use
"org.specs2"        %% "specs2"             % "3.7"           % "test",

compiles as it should but unfortunately running this from inside Eclipse creates a security exception when trying to "Debug As" selecting the RunWebApp file, I am not sure how to resolve this, any suggestions?

Exception in thread "main" java.lang.SecurityException: class "javax.servlet.HttpConstraintElement"'s signer information does not match signer information of other classes in the same package

best regards Peter Petersson

Peter Petersson

未讀,
2016年6月21日 下午3:47:462016/6/21
收件者:lif...@googlegroups.com
Here is more information on the security issue
http://stackoverflow.com/questions/2877262/java-securityexception-signer-information-does-not-match

There is a explanation but also a fix suggestions, as follows:
"A simple way around it is just try changing the order of your imported jar files which can be done from (Eclipse). Right click on your package -> Build Path -> Configure build path -> References and Libraries -> Order and Export. Try changing the order of jars which contain signature files."

best regards Peter Petersson

Henrik Härkönen

未讀,
2016年6月21日 下午3:59:552016/6/21
收件者:Lift

Hi!

Whoa, thanks for your quick replies!!

Peter: you are right, it must be some version compatibility issue, since now I tried with my older Lift project, which was based on 2.6 template, and the debug run worked _just fine_! I can stick with the 2.6 for now, no problem. :) The 2.6 project seems to include only the "specs2-core", version 3.6.4, and the 3.0RC project had "specs2" version 2.3.12 and "specs2-core" 3.6.4.

Diego: That IntelliJ looks good, I should take it out for a spin some time, thanks for the tip!

-Henrik

Peter Petersson

未讀,
2016年6月21日 下午5:32:342016/6/21
收件者:lif...@googlegroups.com
Hi
I "solved" the problem and got Eclipse debugging working.
I will update the project with a proper fix as soon as I get time for it (hopefully this weekend) but in the mean time the quick fix is as follows.

In build.sbt
remove
    "org.specs2"        %% "specs2"             % "2.3.12"           % "test",
    "org.specs2"        %% "specs2-core"        % "3.6.4"            % "test",
add
    "org.specs2"        %% "specs2"             % "3.7"           % "test",

then run
>sbt eclipse
to recreate the Eclipse project.

Then to remove the problematic dependency (on javax.servlet v2.5) from Eclipse present in "Referenced Libraries" by
Opening the "Properties dialog"
then selecting   
"Java Build Path"
then opening "Libraries tab"
then selecting the
"javax.servlet v2.5" list entry
and then finally remove it by pressing the remove button on the right side of the library list.

Now to build tests (and compile the RunWebApp.scala file) in console run
>sbt test
Now the project should be ready for Eclipse debug so ...
In Eclipse right click on RunWebApp.scala and chose "Run As" => "Scala Application" and you will get debug running in Eclipse.

best regards Peter Petersson

Henrik Härkönen

未讀,
2016年6月23日 凌晨1:13:302016/6/23
收件者:lif...@googlegroups.com
Thanks, that will do the trick, yes. :)

Now that I got that under the way, I picked up the tip to try out the IntelliJ IDEA, and that is just nice! Haven't tried debugging there yet, but otherwise, I really enjoy coding scala with that one. :)

-H
回覆所有人
回覆作者
轉寄
0 則新訊息