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.
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
I've found the most useful tools to be the SBT Eclipse Plugin and the RunJettyRun plugin for Eclipse. The former will allow you to generate Eclipse config files based on your SBT setup and the latter will launch Jetty from Eclipse with the debugger attached. An added bonus is that generating your Eclipse config using "eclipse with-source=true" from the SBT prompt will download and attach src jars as well so you can step through Lift and any other 3rd party libraries you depend on as well as your own code.
Related
I am currently working on eclipse plug-in that involves many modules, and I would like to debug and run this eclipse plug-in from IntelliJ.I open this project in IntelliJ to edit code but when I have to run/debug this project I have to open eclipse IDE and start it from there. How can I use IntelliJ to do this?
I haven't actually tried this ... but you could try launching the RCP application stand alone but with the remote debug parameters specified for in your application's .ini file.
Then just point IntelliJ to the appropriate source and attach it's debugger to the running app.
Why do you want to do that? Eclipse has multiple tools for the plugin development that you will miss in IntelliJ. Also you need to build your plugin as product headless and then attach a debugger to it.
In my opinion it doesn't worth the effort. I would install Eclipse and devolop with eclipse.
I am using Intellij IDEA Community Edition 14.0.3 for Scala development. I am having AspectJ in my application. I am using sbt-aspect v0.10.1.
I am able to run everything fine when I run the application from SBT console. However, when I use run from the intellij menu, it is not invoking the aspect.
Because of this, I am not able to run in Debug Mode. How can I make it work with intellij ?
I have the same issue.
My workaround is:
Open project Run/Debug configuration on IntelliJ IDEA
In the VM Options field type: -javaagent:path/to/aspectjweaver.jar
path/to/aspectjweaver.jar in my case is C:\Users\aelkin\.ivy2\cache\org.aspectj\aspectjweaver\jars\aspectjweaver-1.8.13.jar
Actually I do not use Scala in IntelliJ IDEA, but Java. Anyway, a quick web search led me to the SBT Community Plugins page which lists these links:
Plugins for IDEs
IntelliJ IDEA
sbt Plugin to generate IDEA project configuration: https://github.com/mpeltonen/sbt-idea
IDEA Plugin to embed an sbt Console into the IDE: https://github.com/orfjackal/idea-sbt-plugin
At the time of writing this GitHub is down for database maintenance, so I cannot check on the projects mentioned there, but in 15 minutes or you should be able to navigate there by yourself and see if the repos actually contain something useful for you.
I have followed the Play tutorial to create a simple application, made sure it started using the "play" command and then running play eclipse I generated the eclipse project files. I finally imported the project into the latest version of Scala IDE bundle for OSX.
I would like to know if there is a way to run my application from within eclipse without having to use the shell to start play each time.
There is a similar question here, and the accepted answer says that a run configuration will be created in eclipse. In my case I can't see any, so that may have changed from version to version.
The short answer is no. You need to start the play server from command line if you want to load your application on a browser.
The long answer is that we (I'm a contributor to the Scala IDE project) are starting to work on sbt integration, which is the required building block for not having to run the play console on a terminal (because we can to do it for you in the background, once we have sbt support). My suggestion is to star the project I linked, and follow developments.
Trying to get a lift project to run on windows, I've installed maven on my computer, then tried to use
mvn archetype:generate from cmd, then chose the lift basic one , but it always failed on the jetty:run part. Before that, I had to change a lot of the pom.xml file to even get a successful build (since the tutorial I was using was obsolete and it couldn't find the dependencies).
So I've decided to try with the eclipse plugin, thinking it should be easier.
I've installed the maven plugin for eclipse and created a project with the lift archetype.
The project was succesfully created, but I have all kinds of errors in the editor for missing ; and so on (I have scala ide installed on eclipse also and creating a normal scala project works and compiles/runs fine). I have also tried to include the scala-library.jar in the buildpath, with no change.
The odd part is that I can run the cmd and go to the project folder, then run mvn jetty:run and it will actually work (?!) Trying to run in eclipse with jetty:run as goal will give me ClassNotFoundException on the HelloWorld snippet.
So what might be wrong with my settings?
UPDATE: no luck whatsoever, after trying 3 different eclipse versions, installing the maven for scala plugin and following every tutorial I could find. It just simply feels all is outdated on the instructions:
this is how it looks after I include the scala libraries for eclipse on every project (after I create it from an archetype):
is this "mvn archetype:generate" up to date? I don't know if anybody guarantees it will work at all..
Anyway, the default way to at least try Lift and see it working is the following: https://github.com/lift/lift_25_sbt
It uses "Simple Build Tool" instead of maven, but maven should work, too. Also, you can easily read "build.sbt" to get all the dependencies.
Plugins for creating eclipse/intellij project definitions are included. (See the README of the demo project.)
The target to create eclipse project is "eclipse" or "eclipse with-sources=true".
The target to launch the app is "container:start".
This is my first attempt at creating an Eclipse plug-in. I've created one, along with a feature and update site. I set the target platform as my local Eclipse installation. When I run/debug the plugin from within the development environment everything works fine.
Now, my colleague installed the plug-in from the update site that I hosted. When he starts using any of the functionality exposed by my plugin he gets runtime exceptions.
He sees null pointer exceptions which didn't occur when I ran my plug-in project from my development environment.
I have a wizard that's part of my plug-in. When he close it he gets a "Unhandled event loop exception", and the wizard doesn't close. I didn't have this issue when I was running/debugging my plugin in my development environment.
Now I'm confused as to why the same plug-in is behaving differently in the production environment, as against the dev environment and when I was debugging it from my IDE. The target platform in both cases is the same Eclipse version. What could be the reasons?
And how do I debug the plug-in in a production environment? Is there a remote debugging capability for debugging the plug-ins on the production environment?
Any suggestions would be really useful!
To remote debug your plug-in, first add debug arguments to your target Eclipse .ini file
-vmargs
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
before launching it.
Then open another Eclipse instance with a workspace containing your plug-in project.
Open Run > Debug Configurations..., select Remote Java Application and create a new configuration.
As Project, browse and select your plug-in project.
Also fill in your connection properties (host of target Eclipse and port 1044).
Launching the newly created debug configuration allows you to debug your plug-in the same way you debug locally.
Now I'm confused as to why the same plug-in is behaving differently in
the production environment, as against the dev environment and when I
was debugging it from my IDE. The target platform in both cases is the
same eclipse version. What could be the reasons?
This is a classic: Eclipse plugins and RCP applications do indeed behave differently between PDT (the Eclipse IDE) and the exported product.
In your case, a NullPointerException thrown from the exported version but not from Eclipse is 9 times out of 10 an image or other resource files (properties, etc.) that is loaded by your code but is not listed in the build.properties of your plugin.
Anyway, you'll need to check the logs to retrieve the stacktrace and hunt down its cause. Such logs could be found in your friend's workspace under le .metadata/.log file
From your development workspace as it stands now, use the "Debug As -> Eclipse Application" menu item to startup a test workspace. When it starts up, you'll have two workspaces running: the original development workspace and the new test workspace. You can set breakpoints in your plugin code in the development workspace and run your plugin in the test workspace.
When your plugin execution in the test workspace gets to one of your breakpoints, execution will pause and you can use the Debug view in your development workspace to look at variables, set more breakpoints or anything else you want to do to debuf your plugin.
See the Apache Wiki for Developing with Eclipse.
Under Windows 10 with Tomcat running as a windows service I started:
tomcat8.5\bin\Tomcat8w.exe
& added in the Java tab as the first entry in Java Options to enable remote debugging:
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n