Launching Eclipse as a debugger - java

What’s the equivalent of
System.Diagnostics.Debugger.Break();
in the Java world?
Purpose: I have a tomcat based webapp launched by a custom build tool and need to debug the application in eclipse. In the .net world the above statement when encountered will prompt the OS to attach a debugger and I can attach Visual Studio to debug. I am trying to achieve the equivalent in java with eclipse

Here's an excellent article on remote debugging using Eclipse. They even have a section discussing Tomcat.

Here's a link that I used to debug web apps on Tomcat. It goes through installing Eclipse, Tomcat and Java and then setting up Tomcat to run in Eclipse. Towards the bottom explains how to debug a servlet in Eclipse.
http://www.windofkeltia.com/j2ee/wtp-tutorial.html

In general the Java program cannot tell if the JVM runs in debug mode or not, and there is no way to from your program to say that you always want to start a debugger HERE.
You can, however, tell the DEBUGGER that you want to have a breakpoint at a given location, and you will then enter the debugger when the program reaches that spot.
EDIT: You will need to investigate your launcher to see how you can trick it to contain the options needed to enable debugging in the JVM. You may also see if jvisualvm can give you the information you need as it can attach to an unprepared Sun JVM.

Related

How can i debug a simple java file in AWS Cloud9?

I have to debug a simple java file, i set the breakpoint, tap the bug icon and run but it doesn’t stop on breakpoint and only run the file.
Cloud9 doesn't support debug for all languages. Java debugging is not supported. Here is a full list with languages support level in Cloud9:
https://docs.aws.amazon.com/cloud9/latest/user-guide/language-support.html

Eclipse debug mode not opening

I am building a web application with Google Web Toolkit (GWT ) framework.
When i try to run the project in debug mode , it runs normally as in "run" mode itself. I dont get the debug perspective also.
To see if it was problem with my eclipse , i created a simple HelloWorld java application and the debug mode works perfectly .
In a seperate thread with similar issue it was advised to update JDK version. Which i did , but still didnt help
Why when starting GWT in debug mode, my break points don't break
Please help
Try Changing the perspective to Debug.
Windows -> Perspective ->Open Perspective ->Debug
I was able to make the breakpoints work. Basically i was trying to put breakpoints in the onmoduleload method which is in the client side packages. Looks like debug for client side is not provided in eclipse.
I was able to put breakpoints in Serverside classes and the breakpoints were hit.
For client side apparently we can use chrome and view source and see the breakpoints.I am yet to try it

Debugger not stopping at breakpoints: Websphere in Eclipse

I've recently had my app moved from Websphere Application Server 6.1 to WAS 7.5, due to end-of-life for 6.1. Consequently, I needed to update my debugging server. I found this to be an opportune time to move my application from an IBM RAD IDE to Eclipse (already had Indigo installed). Or so I thought.
Anyway, the powers that be, here, have recommended taking my debugger all the way to WAS 8.5, since I'm only using it to debug.
But the issue that I'm encountering is that I cannot get the debugger to stop on my breakpoints. I've got approx. 10 breakpoints in my opening page, all in JSP/Java code.
I'm running Java 1.6.0_32 and Java SE Runtime Environment build 1.6.0_32-b05. I really don't know how to check which JDK I've got loaded. I've seen recommendations to "go back" to JDK 1.5, but I can't be certain that's not what I'm running.
And to cover a few other bases, I have JUST started my system for the day, opened the IDE, started the server in debug (says "Debugging, Synchronized"), put focus on the opening page of the application and clicked "Debug on server". The front page opens without stopping at any of the breakpoints.
Does anyone have ideas or suggestions?
If you use eclipse's debugger and running the application outside eclipse environment , we have to configure it as remote java application.
Also check if the code deployed in server is in sync with the one present in workspace.
anything wrong of the ecplise's site.
Run->Skip all breakpoints
Well, I had recently faced this problem, where the code did not use to stop at breakpoints while I was in debugging mode and was sure that the particular piece of code is executing. In order to solve the problem, I did a clean-build-republish but it did not work, recreated the profile and readded the server with new profile, still did not work then finally re-installed RAD and web-sphere but It still did not work. Then I found the below article
https://www-304.ibm.com/support/docview.wss?uid=swg21240896
and realized it could be a problem due to some other OS process interfering with debug process/port so I performed a system restore. After restore when I deployed the application, debugger started working properly.
I'd like to say I found the answer to this, but I never did. I ended up dropping RAD and moving to debugging on Jetty. My local testing isn't EXACTLY as it would be on the test server, but it works. Not sure if this should be flagged as "answered" or not.
UPDATE: I have left this project but before I did, the entire development platform was moved to IDEA and debugging was no longer an issue. I don't know if I should find a way to mark this question as inactive or closed or whatever so that it's not just sitting out here getting views and responses when it's no longer an issue for me.

Glass fish server not starting

Hi am creating a web application using NetBeans 6.9.1 IDE and am trying to deploy GlassFuish server without success.
I know this sounds silly, but are you sure Glassfish won't start? It is under Start/Programs/Sun/Start Default Server.
If that is what you are doing, I want you to know that I have had a problem with GlassFish not starting. You may want to check your log to see what kind of error you are getting Sun/AppServer/domains/domain1/log/server
Review that and see what that says. It may be giving you a bunch of different errors. In general, though - if she won't start she needs to be uninstalled.
So, uninstall both applications.
Before you install anything make sure that you have the correct jdk installed. For instance, if you are installing NetBeans 6.9.1 IDE, go back and check to make sure you are installing the correct JDK first. I am sorry I don't know what JDK goes with this, but if you check the page/documentation for NetBeans 6.9.1, it should tell you.
Hello, try a custom deployment after, when you do the custom install, since this is a bundle, uncheck the following:
Prelude (Sun GlassFish Enterprise Server v3 prelude) -- if you see that, if not, just keep going.
Also, do you have any system or environment variables that need to be set? What os are you working on?

How do you debug a Rails application?

Is it possible to debug a Rails application in a similar way to a Java application - setting breakpoints and stepping into the code?
What are the best tools for this?
I have a hybrid Java/Ruby on Rails application which I can run in Eclipse or Netbeans.
I would like to step into some code in this app and try to figure out the cause of a problem I'm having.
In Eclipse if I set a breakpoint in my blog_controller and then choose the 'Debug' button, it seems to use the ruby-debug-ide gem to execute the code but I get this unhelpful output and no option to step into any source:
Fast Debugger (ruby-debug-ide 0.4.5) listens on localhost:56726
./war/WEB-INF/app/controllers/blog_controller.rb:1
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/lib/ruby-debug.rb:101:in `debug_load'
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/lib/ruby-debug.rb:101:in `debug_program'
C:/Ruby18/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.5/bin/rdebug-ide:82
C:/Ruby18/bin/rdebug-ide:19:in `load'
C:/Ruby18/bin/rdebug-ide:19
Uncaught exception: uninitialized constant ApplicationController
I'm not sure if I'm doing something wrong or if this is all I can expect.
The debugger I use the most is the ruby-debug gem, which is a gdb-esque command line debugger. Once you learn a few commands it is very quick and effective, and provides you with some handy features like being able to fire up irb in the context of your program and make on-the-fly changes.
And being command line based it comes in handy when you need to debug a on a remote server.
You can expect more. I have used Aptana's RadRails version of Eclipse to debug a Rails app as you describe--setting breakpoints and stepping through the code.
You may be doing something wrong. It looks as if it is trying to debug an individual controller file, rather than debugging the Rails app. When I try to execute a controller file from the command line, I get a similar message:
C:\workspace\myapp\app\controllers>ruby users_controller.rb
users_controller.rb:1: uninitialized constant ApplicationController (NameError)
In Aptana RadRails, I choose Run > Debug As > Ruby Application to debug the app.
For the vim users I strongly recomend looking into the vim-ruby-debugger, which fits in great with Tim Pope's rails.vim scripts.
It gives you a handy :Rdebugger command, allows you to set breakpoints and open a split window to display variable values.
maybe not relevant, but I wanted to post somewhere: got the error: "undefined method `run_init_script' for Debugger:Module" running the debugger in rails 2.3.2. Did a sudo gem install ruby-debug and the problem went away.
I'd recommend just setting up breakpoints (I actually just puts to console) for 99% of debugging with RoR - this method is simple and usable across any IDE, so you never need to learn how a new debugger works.
Actually, I had the same problem with Aptana. Run > Debug As > Ruby Application just doesn't work. I finally made the debugger work by going to the Servers tab, and then start the server in debug mode. After that, set some breakpoints and trigger the corresponding action. Hope this helps.
Debugging? That's just knowing where to look in the case of Ruby (and by extension, Rails) most of the time.
The problem in this case is that you probably still have your ApplicationController called application.rb where it should be renamed to application_controller.rb.
Debuggin in rails is simple if you know how to read the error stacktrace!! But if you need to explicitly watch out the values during the runtime then u can use the rails breakpointer.Below is the link to how-to on breakpointer ..hope this helps!!!
http://destiney.com/blog/rails-breakpointer
I can't speak for Eclipse (never worked well for me) or Aptana (not tried) but from experience I can say that both NetBeans and RubyMine will do what you want. I both cases you should probably make sure that the ruby-debug-base and ruby-debug-ide gems are up-to-date: RubyMine in particular didn't work for me until that was done.

Categories