Remote debug Jetty (no mvn, no plugins) - eclipse

Past scenario
- Work with Tomcat and start in debug mode and Remote Debug with Eclipse.
- Define a port and connect with eclipse in this debug/remote port.
- Use to debug servers in other hosts/servers
Today scenario
Now, I'm using Jetty and I've try to do the same, but with no success, could anyone help-me with that?
I did not use Maven, and did not want to start Jetty inside from my Eclipse.
Environment:
Windows XP
Java V. 5
Jetty V. 6.1.15
Links:
http:// docs.codehaus.org/display/JETTY/Debugging
This did not help me!
http:// docs.codehaus.org/display/JETTY/Debugging+Jetty+with+Eclipse
http:// neelzone.wordpress.com/2007/06/18/jetty-and-eclipse-integration
These are to start inside Eclipse

This is what we are adding to our JBoss command line while development:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
Then we launch the eclipse remote debugging and connection to this port.
Update:
To run from jar (standalone) do the following
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8585,server=y,suspend=n -jar start.jar

For remote debugging you should use JPDA. There's a sort of tutorialish article about it available here.
In short, start your JVM with the argument:
-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n
and you are able to connect to the underlying JVM listening on port 8000 via the standard Eclipse debugger.

If you will use mvn jetty:run one day, you have to
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
appending -Xdebug ... doesn't works

Using the JVM "agentlib" command-line parameter before "start.jar" did not work for me, but this does:
How to allow Eclipse to remotely debug #Jetty (#JPDA #agentlib:jdwp) on port 8000
You have to create a file, $JETTY_BASE/start.ini (do not change $JETTY_HOME/start.ini) and put the following two lines in it:
--exec
-agentlib:jdwp=transport=dt_socket,address=localhost:8000,server=y,suspend=n

Related

Debug Eclipse Wildfly from IntelliJ

I have a local application running in local Wildfly that is configured using eclipse. I also have IntelliJ running in local. Now I want to run the application in Eclipse and connect remote debugger to it from my IntelliJ which is also running in the same machine. How do I do that?
In eclipse, I can see that the checkbox of Attach remote debugger is ticked and the port is 8787.
I try remote configuration in IntelliJ with Host as localhost and Port as 8787, I get error Error running 'Eclipse': Unable to open debugger port (localhost:8787): java.net.ConnectException "Connection refused: connect"
Can some one help me with this?
Why I need this setup:
I have this application that is been setup on Eclipse since ages. As I am used to IntelliJ, I don't want to use eclipse. It will take some time for me to identify how to migrate it to intellij, so for now going with this work around.
Ah, never mind. I added -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787 to launch configuration and it worked. I thought it appends these arguments automatically. But that is only when we use the bat file to start. Doesn't seem to be the way with eclipse.
PN: I am not deleting this post as there may be others who would have similar requirement.

How to debug on remote AEM server?

While reading online AEM documents, I came across how to run the AEM on debug mode. But How to debug on remote AEM server ?
To use remote debugging, you must start CQ5 with this JVM parameter:
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
You can add the parameter by doing the following;
Start your server like this: crx-quickstart/bin/start -d --debug-port 8000. The -d parameter adds the jvm parameter to the CQ5 java process.
Add it to your crx-quickstart/bin/start script CQ_JVM_OPTS environment variable (so your server always starts in debug mode).
Include it as a parameter when starting CQ5 with java -jar directly. For example, java -Xmx512m -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -jar cq-author-4502.jar
Just as you would debug any Java application. Open the AEM in debug mode (i.e. add -debug <your port> to the startup parameters) and connect to it using your favorite IDE. I don't remember how you do it in Eclipse, but in IntelliJ you just create a new "Remote" run configuration specifying the debugging port.
i am using Intellij, there you can create remote connection for debugging as shown in below screen shot.
1. use the remote server
2. port on which you are running your AEM instance on Debug mode
Done!

run tomcatRun task with debug mode

I've got multiple project which are using tomcat on different ports.
I usually run tomcatRun task simply using gradle tR.
But I need to debug one application - it runs on localhost:9080 port so I created debug configuration in eclipse to use localhost and 9000 port.
But how to run tomcatRun task with debug properties? As a solution I found to use some variable
GRADLE_OPTS="-Xmx2048m -Xms2048m -XX:PermSize=512m -XX:MaxPermSize=1024m -Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n"
However I don't get how to set it for my current application - because I've got multiple application which are using tomcat and I want to run only one application in debug mode?
You can use setenv.bat/setenv.sh in tomcat/bin directory and write
set CATALINA_OPTS=-Xmx512m -XX:MaxPermSize=256m ...

Running a Tika server from eclipse to be accessed from hosts other than localhost

I have the following question: I have imported in eclipse the tika-server subdirectory of the tika-trunk main repository and managed to import it to eclipse and I am able to start the "Apache Tika 1.7-SNAPSHOT server" on the machine I run eclipse (localhost). My problem is that I can only access Tika from this machine (localhost).
I know how to solve this problem when I start the Tika server from my command line (see post Stopping a Tika server properly ), but I do not know how I can pass "-host 0.0.0.0" in order to instruct eclipse to do the same. I know that this might be solved through the "Run Configurations" eclipse menu but it is not intuitive to me how I can accomplish that. Thank you in advance !
First up, you need to open the Tika Server Cli class in eclipse. Then, do Run As followed by Run Configuration, as shown here:
Now, in the configuration for the Tika Server CLI, in the program arguments box, enter the arguments you want to give to Tika, eg --port 9876 as shown here
Finally, hit Run and the Tika Server will start with the alternate port you've givne
I think the only solution so far I found is to edit "TikaServerCli.java" and switch "public static final String DEFAULT_HOST" from "localhost" to "0.0.0.0". Then you can start the server in a way that can be accessed by everyone and not only by localhost.

Eclipse: Glassfish and Tomcat don't work

I have reinstalled java JDK 6.0.25,(after some problems installing java, finally succeeded). I have set paths (JAVA_HOME points to C:\Program Files\Java\jdk1.6.0_25 and in Path also added C:\Program Files\Java\jdk1.6.0_25\bin).
In eclipse I have pointed everything to this new JDK, also in servers. When I have installed Glassfish 3.1, after installation the domain wasn't created. So when I add this server in Eclipse, the domain wasn't found.
So I did extract an ZIP version of Glassfish and in Eclipse configure the server to this ZIPPED Glassfish. Also I have installed tomcat 7.0.14 again and add to eclipse but both did not work.
Main problem: When I start Tomcat or Glassfish in Eclipse they don't start. Tomcat is starting but after 45 seconds it says, that the time is run out. I have read the forums to increase starting time, I have putted it to 240 sec, but it does not work, because it pop out error in which sazs, that the port is already used by a different server.
By Glassfish, when I start it, its starting, but after few minutes gives me error: Failed to start. It looks like some ports or something is blocking this servers. I have turned off firewall also and antivirus but nothing.
I have looked all the forum about "not starting Glassfish or Tomcat" but didn't found the solution. I don't want to reinstall windows for this.
So if anyone know anything about this problem, please HELP.
Update:
I've tried to change the ports in domain.xml and checked with netstat -b (everything was established), but the server (Glassfish) didn't start. It shows an error "Server GlassFish Server Open Source Edition 3 (Java EE 6) at localhost failed to start.". I've also tried install "built in Eclipse" Glassfish from marketspace and from "Install new software" from eclipse, but it comes out with the same error. Currently, for needs I'm using XP Mode in Windows 7, there servers work, without any problems.
It seems your installation odyssey messed up your system.
But you should get it working without reinstalling Windows. Maybe the fragment of an old server installation blocks the ports Glassfish and Tomcat need for operation.
Try the following:
Check which ports your "new" servers try to access (should be something like 8080 and should be written in server logs during startup)
Use netstat -b (from cmd started with admin rights) to check which application blocks this / these ports (could be java.exe if there is an old installation still hanging)
Remove the old installation (uninstall or disable service)
Try again to start your new server(s).
Try tell to GF or TC to bind the default web listener other port than 8080, because this is a root of problem.
I doesn't know well TC, but in GF case, this is very easy. Simply edit $GLASSFISH_HOME/domains/domain1/config/domain.xml and find something similar:
<network-listener port="8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
And replace 8080 with other port (but not same with TC). In your case I could choose 8888 which is easy to remember but you can pretty sure this is differs from TC's port.
Note: Edit this file before you start GF!