Remote debugging in eclipse issue - java

echo "LSE Parser v1.0"
javac -d ../build -classpath ../build:${MY_CLASSPATH} *.java
cd ../build
jar -cf ../lib/lse.jar .
cd ../src
The above is my build script for a java application. there is a serperate run file which has all the CLASSPATH defined and runs the application.
I am trying to remote debug the application on eclipse but facing issues. The code is sitting on unix server host. i've closely followed instructions about debug configurations... for eclipse.
This is what I'm doing:
I locate my build (above) in putty terminal and execute with . ./build
I type java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999
On eclipse debug config... I enter a random name, project is lse, gave correct host and gave port number as 9999. checked termination of remote VM. When I click debug, it does not stop on the breakpoint.
NOTE: in the project "lse" are 3 .java source that the application uses. the "lse" project has only src content, however in the Unix host it has all the lib, scripts, config folder.
Please can someone tell me what I'm doing wrong. after step 2, I managed to get
Listening for transport dt_socket at address: 9999
then after step 3, I get some messages on putty
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is server,
because you are running on a server-class machine.
....
and see on eclipse a terminated status on debug mode. java hotspot server [host bla bla]

I imagine you solved this by now...but looks like you forgot to provide the name of the class for java to run. If your main method was in a source file like foo/Bar.java, then you would need to add foo.Bar to your java line. Something like:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999 foo.Bar
You might also consider adding -g to your javac to generate debug info.
You could avoid all (or most) of this pain if your source was in the IDE that you're trying to debug with...

Related

How to using Jetty source code start web app

I have the following problem after executing the Main class directly
ERROR : No enabled jetty modules found!
INFO : ${jetty.home} = /Users/zhangsan/git_repo/servlet-container/jetty.project
INFO : ${jetty.base} = /Users/zhangsan/git_repo/servlet-container/jetty.project
ERROR : Please create and/or configure a ${jetty.base} directory.
Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
java -jar $JETTY_HOME/start.jar --help # for more information
I do not want to start with the start.jar file. What do I do
You can generate the full JVM command line used to start jetty with the dry-run command:
java -jar $JETTY_HOME/start.jar --dry-run
This will give you all the options and classpath that is required to run Jetty with your current configuration in your jetty-base directory.
With this you can enter the configuration into your intellij run configurations options for Main.java. But this is not recommended, if any configuration changes in the jetty-base then the JVM command line options required will change as well.
Perhaps you should look into running with remote JVM debug as described in https://github.com/eclipse/jetty.project/issues/8114, or even switching to using embedded Jetty.

How to debug a .jar file remotely using Intellij Idea

I am currently using intellij idea to code my project that I am working on, after creating of .jar file using OneJar command i deploy the .jar file on my linux server who address is something like 192.164.1.125.there I run the command sudo nohup java -jar fileName.jar & on server to start the jar file in the background and use the rest-client app to send rest calls to my .jar file.Whenever something goes wrong I can only see error message in nohup.out file and what I actually wanted is to debug my jar file using intellij idea i.e how can I debug my .jar running on 192.164.1.125 using intellijIdea running on my client machine.I know I have to use that EditConfigurations option in run menu of intellij and provide IP and Port, but how to do it exactly.
You can do the remote debugging on IntelliJ IDEA 2019.2 version very easily!
Click on "Run" -> "Edit Configurations"
Click on "+" and select "Remote"
Enter your remote IP and select source code folder path
Optional : change the name and port of your wish
Run your remote server jar with the command which is mentioned in the Command line arguments for remote JVM box .
something like this,
sudo nohup java "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8911" -jar fileName.jar &
You are all set. add the breakpoints and click on Debug symbol to debug your remote jar from local
You must run the remote "java -jar .." command in debug mode by adding the additional magic flags. You can then tell your local IntelliJ to create a new debug configuration targeting a remote application - IntelliJ provides the magic flags you need.
The help page for this feature is at https://www.jetbrains.com/idea/help/run-debug-configuration-remote.html

Remote debugging java - Could not find or load main class

I'm trying to debug a java program on my remote computer, which the following command:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y suspend=y -jar Test.jar
When I try remote debugging with eclipse on my local computer, I see this error on the remote computer:
Listening for transport dt_socket at address: 9999
Error: Could not find or load main class suspend=y
I don't understand since I do have a main class in the program.
P/S: I also have the same error when trying to run the jar file by
java Test.jar
The project is built with Eclipse IDE.
Can someone show me where I did wrong?
Thank you
java -Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y suspend=y -jar Test.jar
You're missing a , between server=y and suspend=y. Even the introduction of a space in the parameters can confuse the VM.
This is the right syntax.
java -Xdebug -Xrunjdwp:transport=dt_socket,address=9991,server=y,suspend=n -jar my.jar
If your jar has the right main class attribute it should work correctly.

Java IDL : servertool does not register and hangs

I am running CORBA Persistent Object implementation in Java IDL
as in Java IDL: The "Hello World" Example
I followed exact procedure in above article
I used servertool for registering Persistent server as shown in example .
but when i tried to register server using syntax as in that article :
servertool > register -server PersistentServer -applicationName s1
-classpath path_to_server_class_files
I hangs and doesnt do any thing , then i have to do ctrl+c to back to normal mode
what could be wrong with this ??
The problem is that your Java JDK installation path contains spaces.
If your JDK is installed to a path with spaces for example "C:\Program Files\Java\jdk1.7.0" then you have to start orbd and servertool using their absolute path (in Windows you have to use short hand notation i.e with ~ [tilda]):
C:\Progra~1\Java\jdk1.7.0\bin\orbd -ORBInitialPort 1050 -serverPollingTime 200
C:\Progra~1\Java\jdk1.7.0\bin\servertool -ORBInitialPort 1050
servertool> register -server PersistentServer -applicationName MyApp -classpath . (adjust the classpath as needed for the files generated by idlj)
In Windows you can find short name path using: dir *.* /x
In case your using an environment variable like %JAVA_HOME% equals to "C:\Program Files\Java\jdk1.7.0" and then you append it to PATH it will NOT work, you have to use short hand notation (with tilda) i.e. "C:\Progra~1\Java\jdk1.7.0"
HINT: If your JDK is installed in a path with no spaces, for example C:\Java\jdk1.7.0 then you can start orbd and servertool without using an absolute path and it will work.
please read Running CORBA Applications for full description
Create the Java stub and skeleton classes by compiling the IDL file with the ‘idlj’ command.
idlj -fall IDLfile.idl
Compile the source files
javac IDLserver.java
javac IDLclient.java
or
javac javac *.java IDLmodule/*.java
Start the Object Request Broker (ORB) daemon
unix: orbd -ORBInitialPort 4321 &
windows: start orbd -ORBInitialPort 4321
On unix, the command ‘ps -e’ shows the process number assigned to orbd. The kill command can be used to kill the process.
During its running, the daemon writes messages in the subdirectory orb.db.
Invoke the server
unix: java IDLserver -ORBInitialHost localhost -ORBInitialPort 4321 &
windows: start java IDLserver -ORBInitialHost localhost -ORBInitialPort 4321
Invoke the client
java IDLclient -ORBInitialHost localhost -ORBInitialPort 4321
The default ORB initial port is port 900 (only a root can start it on solaris).

CORBA: Java's servertool does not allow me to register a server class

Have been pulled down into the realm of CORBA...
I am trying to quickly learn (if not master...) CORBA along side its Java mappings. I have come upon some old tutorials:
Java IDL: The "Hello World" Example
Naming Service
orbd - The Object Request Broker Daemon
I have created a project with the source from the first link above (Java IDL...) and have run both HelloServer and HelloClient after running the following command:
start orbd -ORBInitialPort 1050
Not surprisingly, everything works :)
I then with to register the HelloServer in the as a persistent service and fail miserably!
I run the following command (launched from the "bin" folder (that which contains the .class files)):
%JAVA_HOME%\bin\servertool -ORBInitialPort 1050
I then run:
servertool > register -server HelloServer -classpath .
and the process simply hangs...
What might I be doing wrong
Well I am not sure why things have started to work but...
From the "bin" folder (that which contains the .class files) I have run:
%JAVA_HOME%\bin\orbd -ORBInitialPort 1050
Then opened a new cmd shell (from the same location) - since the previous one is running the orbd and have run:
%JAVA_HOME%\bin\servertool -ORBInitialPort 1050
Both:
register -server HelloServer -classpath . -applicationName HelloServerApName
and
register -server HelloServer -classpath .
work
Does HelloServer know where (port and machine name) to find the Naming Service?
If not, this link might help: orbd - The Object Request Broker Daemon (ORBD).

Categories

Resources