Play! Framework Eclipse Debug Source Not Found - java

I have been trying to debug and look through the internals of Play! Frameworks Controller class. If I place break points on the Controller.class, the debugger stops at the break point but throws a "Source Not Found"
I have added play.jar and the project is in path. Even added a Java Classpath called "Play_Home" which points to the Play framework.
Update
I been able to always debug my code (your solutions don't help me). When I plan a breakpoint on Play's internal classes like Controller, the debugger stops and says "Source not found"

(This answer is almost a straight copy of my own answer to another question that touches the same topic. I assume the problem in your case will be solved by running the eclipsify command, as another user has already mentioned.)
Create the configuration files for Eclipse by running play eclipsify YourProject command. (See Play framework documentation for more information.)
You should now have a folder named eclipse in your project. In it, you should see commands Connect JDPA to YourProject.launch, YourProject.launch and Test YourProject.launch.
Right-click on the YourProject.launch and choose Run As --> YourProject from the pop-up menu. That will start your application. When the application is running, right-click on the Connect JDPA to YourProject.launch, and choose Debug As --> Connect JDPA to YourProject.launch from the pop-up menu. That will start a debug session on your application.

Related

How to debug WAR inside eclipse, NOT remote debug?

My originally question has been marked as duplicate as this question and asked to ask a new one. So here I repeat, I am not looking for a remote debug solution. What I am asking is how to debug WAR inside eclipse just as a JAVA application. Following is my original question.
I have seen many online tutorial explaining how to use eclipse to do remote debug of WAR file.
But what I want to know is how to do the debug inside eclipse just as debugging a JAVA application? I have Tomcat 7 configured in my eclipse as a server. And I have tested it with a sample servlet program successfully meaning I can set breakpoint in the source code and run into it.
My WAR application is built by gradle. I have imported the gradle project into my eclipse and build it ok inside eclipse by running gradle task inside "gradle tasks view". I added the project into the server. However, when I try to use "Debug as > Debug on Server", it fails and the breakpoint is not get hit. Anyone could share the experience to debug WAR inside eclipse?

Eclipse Debug not opening window

I have decided to start learning Java. And i have downloaded and is using Eclipse as my code editor. I am also following a tutorial on Youtube and on various sites, and on all of those sites it says that clicking Debug will run your application with live code editing. However, When i press debug my application doesn't launch (i think) but when i click Run, the window shows up and the application is functioning.
So basically what happens when i press Debug is it gives me a list of all currently active Applications, but my application won't open up.
I am on a Mac if it helps
Try right-clicking on an executable file and select Debug As → Java Application. After you have started the application once via the context menu, you can use the created launch configuration again via the Debug button in the Eclipse toolbar.
A complete Debugging tutorial can be found here, will be useful to you.
Eclipse Debugging

How to prevent Eclipse+Tomcat from running current class instead of project (Vaadin)

This may well prove to be a simple config change, but I can't seem to find an obvious setting to solve the following problem:
I have a Vaadin project in Eclipse, which is configured to be debugged with Tomcat v6. If I select the top of the project in the project explorer and hit debug, the eclipse browser launches and my web app opens with the following url:
http://localhost:8080/MyVaadinProject/ THIS WORKS
However, if I'm currently looking at a java file (say Myproject.java), Eclipse tries to open the java file at this url:
http://localhost:8080/MyVaadinProject/WEB-INF/classes/com/example/myproject/Myproject.java
Of course, that produces a 404.
Having to deselect/close my java files every time I want to debug is quite tedious. Is there some way to prevent this behaviour in eclipse?
I am on OSX Lion, Eclipse version 3.7.2.
Thanks!
When running the project, instead of highlighting the class file in the Project Explorer, highlight the very base of the project before running.
This is what we want to run anyway, not the class file itself.
Go to
Windows -> Preferences -> Run/Debug -> Launching
There, at the bottom, select "Always launch the previously launched application".
Now you just have to click your project name in the package explorer and do a Run As -> Run on Server once.
After that launch, you will just need to hit the Run Button and your application should always start the way it should be.

How can I launch more than one debug session in Eclipse from a single click?

I'm currently writing a GWT application through Eclipse. Eclipse is used for development but I use the m2eclipse plugin and a Maven pom.xml with the GWT plugin to build & run it.
When I need to debug the app I must:
Invoke "Run As ..." on a Maven project (via m2eclipse) "war:exploded gwt:debug". This launches GWT's app server and waits for a remote debug connection on port 3408. The need to wait for the WAR to be exploded means it could be a minute for this to happen.
Invoke "Debug As..." a Remote Java Application to connect to the server.
I've already added both targets to favourites to lock them into the drop down but it's still a pain.
I'd like to launch them both in sequence from a single click rather than two discrete actions.
Is there any way in Eclipse to achieve this?
Try this plugin. http://marketplace.eclipse.org/content/escripts
You can define scripts of Eclipse actions easily. You create a script of starting the 2 debug session, then run with one click or shortcut.
EDIT:
The plugin was moved and is now called EASE.
https://eclipse.org/ease/
"Launch Groups" are part of the CDT. Officially supported, easy to install.
See https://stackoverflow.com/a/11905444/518491
Why are you launching like this? Can't you just launch it by GWT plugin? Go to Run Configurations -> Web Application (the blue circle with "g" inside) and create new Run Configuration.
In it, in Main tab, enter (or select) your project, and enter com.google.gwt.dev.DevMode in Main class.
In Arguments enter -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -port 8888 -war path_to_your_dir_with_WEB-INF_directory com.package.your.Module

Preferred way of developing web applications with m2eclipse

When developing Maven web applications I usually resort the the jetty-maven-plugin to quickly launch my application for local testing and debugging. Using the launch with m2eclipse has the drawback of not properly including all sources for debugging, even though they are downloaded by Maven ( see Source lookup does not seem to work ).
What is the preferred way to debug Maven web applications in Eclipse? I'd especially appreciate configurations which work with the gwt-maven-plugin.
My preferred way to develop web applications with m2eclipse is to... not use it. Instead, I use the approach described in Debugging with the Maven Jetty Plugin in Eclipse that I'm quoting below:
Step 1
Go to the Run/External Tools/External
Tools ..." menu item on the "Run" menu
bar. Select "Program" and click the
"New" button. On the "Main" tab, fill
in the "Location:" as the full path to
your "mvn" executable. For the
"Working Directory:" select the
workspace that matches your webapp.
For "Arguments:" add jetty:run.
Move to the "Environment" tab and
click the "New" button to add a new
variable named MAVEN_OPTS with the
value:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y
If you supply suspend=n instead of
suspend=y you can start immediately
without running the debugger and
launch the debugger at anytime you
really wish to debug.
Step 2
Then, pull up the "Run/Debug/Debug
..." menu item and select "Remote Java
Application" and click the "New"
button. Fill in the dialog by
selecting your webapp project for the
"Project:" field, and ensure you are
using the same port number as you
specified in the address= property
above.
Now all you need to do is to
Run/External Tools and select the name
of the maven tool setup you created in
step 1 to start the plugin and then
Run/Debug and select the name of the
debug setup you setup in step2.
From instructions provided by
Rolf Strijdhorst on the Maven mailing
list
Stopping Jetty
In order to stop the jetty server the
"Allow termination of remote VM"
should be checked in debug dialog in
Step 2. When you have the jetty server
running and the debugger connected you
can switch to the debug perspective.
In the debug view, right click on the
Java HotSpot(TM) Client
VM[localhost:4000] and chose
terminate. This will stop the debugger
and the jetty server.
Try to avoid writing code which needs a container of some kind to debug. Always write code that can run independently and wrap it in a very thin layer for deployment (thin layer -> few lines of code -> few bugs).
If you really must, try MockRunner to emulate the app server.
Other than that, you can manually add the sources in the project properties.

Categories

Resources