i have tried the webservice example mentioned in the below link.
https://codezone4.wordpress.com/2012/11/08/restful-web-services-java-mysql-and-json/.
i build the application with maven deployed in tomcat then clicked on the webservice link in the chrome , not able to access my code.
Now i tried to debug with postman .
I clicked on my webservice class -> then debug -> debug configiuration
then i selected remote application
there values of host and port are
Host : localhost
Port : 8080
then it is showing establishing connection for long time and after that it is showing Failed to connect to remote vm .connection timedout
Can you please guide me how to make deugger working in eclipse to debug the rest api call.
I can find quick solution (In Windows Environment with local host):
1) Download tomcat in your favorite drive (E.g. d: drive)
2) Open startup.bat file under tomcat/bin folder in notepad
3) Replace following line (Which appear at the end of file)
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
with
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
4) Restart your tomcat as it will start with listening port 8000
5) Open Eclipse->"Run"->"Debug configuration"-> Create "Remote Java Application" and provide following information:
Name: sample-name
Project: your project folder
6) Click on Debug button
Note: Make sure Connection properties will have
Host: localhost
Port: 8000
7) Put debug point in your code
8) Open Postman and Hit sample REST API call as you will see the debug point will appear in your code
That's It!
Quoting from your query,
clicked on my webservice class -> then debug -> debug
The project you created requires the restApplication to be deployed on a running server.
Prior To Testing -> check http://localhost:8080 is up or not, and then publish the war into the server.
choose Debug As-> Debug on Server
Related
I have a java application running on an openshift remote cluster and I want to debug the app from my local machine with Intellij-Idea. The app is built by a Jenkinsfile on another remote jenkins server (gradle build, docker build and pushed to openshift, where it is automatically deployed).
The Dockerfile exposes port 9009 and therefore my Intellij Remote Debug Config looks like this:
Debug Config
With the localhost in the Debug Config I need openshift port-forwarding:
oc port-forward my-pod 9009
Forwarding from 127.0.0.1:9009 -> 9009
When I start the Debugger I get the following error in Intellij:
Error running 'DTC Remote Debug':
Unable to open debugger port (localhost:9009): java.net.ConnectException "Connection refused: connect"
At the same time the terminal with the port forwarding shows:
Handling connection for 9009
E0927 09:52:33.711817 5996 portforward.go:331] an error occurred forwarding 9009 -> 9009: error forwarding port 9009 to pod ad370...c010, uid : exit status 1: 2019/09/27 03:52:33 socat[129691] E connect(5, AF=2 127.0.0.1:9009, 16): Connection refused
Doing an Nmap scan against the url where I get the index.html of my application I got the following:
nmap -sS my-openshift-url
Starting Nmap 7.80 ( https://nmap.org ) at 2019-09-27 15:01 Mitteleuropõische Sommerzeit
Nmap scan report for my-openshift-url (IP-Address)
Host is up (0.0043s latency).
rDNS record for IP-Address: dispatch-my-domain
Not shown: 997 filtered ports
PORT STATE SERVICE
80/tcp open http
443/tcp open https
9009/tcp closed pichat
Nmap done: 1 IP address (1 host up) scanned in 6.10 seconds
I guess the problem is the closed 9009 port, but I have no clue how I can open that port on my openshift cluster. I already set several environment variables in the openshift web UI (just to be sure):
DEBUG TRUE
DEBUG true
DEBUGGING TRUE
DEBUGGING true
JAVA_DEBUG TRUE
JAVA_DEBUG true
JAVA_DEBUG_PORT 9009
But I can't get it to work. If I switch the port-forwarding to 8080 I can access the index.html via localhost:8080 from my browser. I don't know if I need to change something in the project code (gradle, docker, jenkins, etc.) or if I can just open the port on the deployed service in openshift somehow...
If anything isn't clear or if I missed something just tell me. I'm happy for every piece of advice.
Regards,
Christoph
Adding the following environment variable in openshift did the trick:
JAVA_TOOL_OPTIONS -agentlib:jdwp=transport=dt_socket,address=9009,server=y,suspend=n
All the other environment variables from above are absolete...
I know that this answer was asked before, but I couldn't find a clear solution from the given answers.
I want to debug a maven project that implements a web service on tomEE using IntelliJ or any other IDE.
I know that instead of calling the goal tomee:run I must call tomee:debug. And that's what I did:
In IntelliJ, I click on Run / Edit Configurations then +, I chosen Maven, I located the project directory and I set tomee:debugas command line. I started the debug and it says:
Started server process on port: 8080
Listening for transport dt_socket at address: 5005
I think this first step is correct. The second step as I understood is to create a remote configuration, and this is what I failed to do.
What I did is the following:
Run / Edit Configurationsthen +, then TomEE Server. Here I choose local or remote? In my case I think local because the project is local on the device and I call it using localhost:8080.
After that, how to configure this page? What will be the port number 5005 or 8080? And when I finish configuring this page what I do? Run or debug?
I would appreciate a detailed answer because I was not able to understand the short answers given on other questions.
Here's the solution:
Step 1:
In IntelliJ, I click on Run / Edit Configurations then + to add a new configuration, I chosen Maven, I located the project directory and I set tomee:debugas command line. I started the debug and it says:
Started server process on port: 8080
Listening for transport dt_socket at address: 5005
An alternative solution can be by locating the project directory in terminal and running the command: mvn tomee:debug
Step 2: In IntelliJ, I click on Run / Edit Configurations then + to add a new configuration, I chosen Remote, and I specify localhost with port 5005.
Now I click OK, and I debug this configuration.
Breakpoints are detectable and debugging works perfect.
I am new to jboss and myeclipse.
I want to debug my web app using jboss 4.0.4
I am using MyEclipse.
I gone through various links and found we need to uncomment following line in run.bat file
set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
then after starting run.bat console shows
Listening for transport dt_socket at address: 8787
Then next how do I tell MyEclipse to attach to port 8787 and run my application in debug mode.
You need to define a Remote Java Application in the Eclipse debug configurations:
Open the debug configurations (select project, then open from menu run/debug configurations)
Select Remote Java Application in the left tree and press "New" button
On the right panel select your web app project and enter 8787 in the port field.
Here is a link to a detailed description of this process.
When you start the remote debug configuration Eclipse will attach to the JBoss process. If successful the debug view will show the JBoss threads. There is also a disconnect icon in the toolbar/menu to stop remote debugging.
Define a new server/runtime in MyEclipse, for your JBoss 4 installation. Deploy your project to the defined server and start it in debugging mode.
For more information, go to the MyEclipse learning center, also here.
For earlier releases, check in the inbuilt help.
I setup my remote WebLogic server to debug, using these options:
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=${DEBUG_PORT},server=y,suspend=n -Djava.compiler=NONE"
I started WebLogic on the server and saw that it was listening on 8453 for dt_socket. I added the remote server on my local Eclipse and tested the connection. I also see that the server is STARTED and I can view the details. However, I'm unable to restart in DEBUG. I also stopped WebLogic on the server and now in Eclipse I see that it is stopped, but I'm not able to start it (the icons for debug and start are greyed out). When I set up my Remote Java Application in Eclipse I did check "Allow termination of remote VM".
Before stopping the server, the debug icon wasn't disabled and when I clicked it I got this message:
Cannot attach to remote server.
Please make sure the server myserver.com is running and listening for transport dt_socket at address: 8453
Failed to connect to remote VM. Connection refused.
Connection refused: connect
Instead of using java startup options, modify the following scripts:
setDomainEnv.sh -> make sure DEBUG_PORT is set ie. 8453
startWebLogic.sh -> set PRODUCTION_MODE=false and set debugFlag=true
Restart server, remote debug should work on port 8453.
I'm trying to initiate a remote debugging session on my PC with Eclipse & Tomcat.
I managed to run tomcat (not through eclipse) with the following params:
set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=5050
cataline jpda start
The server starts ok, this is the outcome:
Using CATALINA_BASE: "C:\Java\Tomcat"
Using CATALINA_HOME: "C:\Java\Tomcat"
Using CATALINA_TMPDIR: "C:\Java\Tomcat\temp"
Using JRE_HOME: "C:\Java\jdk1.6.0_27"
Using CLASSPATH: ...
Listening for transport dt_socket at address: 5050
...
...
INFO: Server startup in 12502 ms
Now, I opened eclipse, and loaded the relevant project.
I set a new debugging configuration using Remote Java Application with localhost and the right port. however when I run it, I get this error message:
Failed to connect to remote VM. Connection refused.
Connection refused: connect
Can't really understand where is the problem. this is all local inside the PC, so there shouldn't be any firewalls involved, can someone think of something ?
Found the solution. apparently the connection was made, but Eclipse & Tomcat don'tt show any notification or status regarding it.
Then, when you initiate the connection again, you get the error because you're already connected.
I think that a small notice, either from Eclipse, or from Tomcat would be nice.
Try adding the following debug options directly to the JVM startup by directly modifying the catalina startup script
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5050
There could be problems when there are code mismatches between eclipse and tomcat. So when it matches the error will disappear
You can configure it in remote java application section in debug configuration.
For more details you can refer this link