Not able to debug webservice code in IntelliJ - java

I have a window service that I have installed.I have the source code of the application opened in Intelli J.
I made configuration IntelliJ as following
I checked the PID of the service and port it is using.
While running Remote config in Intelli J it is giving following error
4:09:18 PM Error running Remote: Unable to open debugger port : java.net.ConnectException "Connection refused: connect"
Can someone please shed some light on how to debug window service in IntelliJ. It is a job schedule application.
The installService.cmd is as follows
set HOME_DIR=%~dp0
set SERVICE="Service_Name"
SET JAVA_OPTIONS=-Xms256m -Xmx256m
#echo Service name is Service_Name
"pathname\Service_Name.exe" -install %SERVICE% %JVM% %JAVA_OPTIONS% -Djava.class.path="pathname\Service_Name.jar" -Dorg.quartz.properties="pathname/Service_NameScheduler.properties" -start com.org.st.Service_Name -stop com.org.st.Service_Name -out "D:/core_log\Service_Name_service_out.log" -err "D:/core_log\Service_Name_service_error.log" -current "pathname\apps"
set JVM="C:/Program Files/Java/jdk1.6.0_29/jre/bin/server/jvm.dll"

Check the port number. It should be same as in JAVA_OPTIONS & Intellij Idea Debugger remote configuration under port no.

Please append the command line arguments from the IntelliJ debug configuration to the SET JAVA_OPTIONS line, it will be something like
SET JAVA_OPTIONS=-Xms256m -Xmx256m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=51211
And reinstall the service.

Make sure whatever port you're listening on isn't blocked by a firewall.

Related

Problems with heroku remote debugging in IntelliJ

I started the command "heroku ps:forward 9090 --app [app-name]". I added a "Remote" debug configuration in IntelliJ, and set host to "localhost" and port to "9090". I start the debugger, and after a while I get this message:
"Error running '[configuration name]': Unable to open debugger port (localhost:9090): java.io.IOException "handshake failed - connection prematurely closed".
I checked with netstat that port 9090 is actually listening for a connection.
So it turns out that in order to enable debugging with heroku, you need a "Procfile". It is possible to run an instance without this file, but then the default parameters are used (and that's obviously what we were doing).
After adding this "Procfile", debugging finally works:
web: java -Dserver.port=$PORT $JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,address=9090,suspend=n -jar target/<.jar file>

How to remote debug an enterprise application running on web logic server in eclipse IDE(same machine)

I am new to weblogic application server and remote debugging & have gone through several post to set up remote debugging. Some post suggest to edit setDomainEnv.cmd file while others suggest to edit startWeblogic.cmd file in my WEBLOGIC_HOME\user_projects\domains\my_domain\bin.
But neither of the solutions worked for me. Listed below are solutions which I tried :
1) Edit setDomainEnv.cmd file
set JAVA_DEBUG=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=%DEBUG_PORT%,server=y,suspend=n -Djava.compiler=NONE
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -ea -da:com.bea... -da:javelin... -da:weblogic... -ea:com.bea.wli... -ea:com.bea.broker... -ea:com.bea.sbconsole...
The port number is set to 8543 in the file
if "%DEBUG_PORT%"=="" (
set DEBUG_PORT=8453
)
2)Edit startWeblogic.cmd file
I added the following line at the top of the file
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8543,server=y,suspend=n
Then in eclipse,when i run debug configuration(port number : 8543), I get Failed to connect to remote VM. Connection refused.
Connection refused: connect
Please let me know
1) How remote debugging works?
2) How to set up remote debugging in eclipse with weblogic server ?
3) What is the difference between above 2 methods ?
4) Where do I need to add the debug command(-Xdebug....) in the startWeblogic.cmd file(at the top)?
5) What is the purpose of setDomainEnv.cmd file in weblogic server ?
Thanks in advance
I think it should be sufficient to just set environment variable before starting Weblogic. Start cmd and before starting weblogic set debugFlag=true. This should make weblogic open debug port which should be set to some default like 8453. You can also set DEBUG_PORT=8888 or any other free port, if you want to change it.
Start Weblogic and verify that the port has been opened. You can use tools like cports or ProcessExplorer for that (or event netstat).
In case debug port isn't open, check if you run Weblogic in development mode, because debugFlag can be ignored in production mode.
In Eclipse create a remote debug configuration (and remember that this option is not available in Run configuration that is next to it on the toolbar):
In point 3 on the screenshot select the project you deploy to weblogic that you want to debug.
It that does not work post the problems you have.

IDEA failed to start a local glassfish server

I'm trying to start Glassfish 4.1 in Intellij IDEA 13.1.4. I've set basic settings in Run/debug configurations window - selected application server, jvm, put 2 artifacts to deploy, left startup/connection configurations default. When I try to start it the exception is thrown. Here is full stack trace:
/home/glassfish/glassfish/bin/asadmin start-domain domain1
Detected server admin port: 4848
Detected server http port: 8080
[2014-11-14 03:09:49,839] Artifact ss-ear:ear: Server is no connected.Deploy is not available.
[2014-11-14 03:09:49,839] Artifact ss-ear:ear exploded: Server is not connected. Deploy is not available.
java.nio.file.AccessDeniedException: /home/glassfish/glassfish/domains/domain1/logs/server.log.lck
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:177)
at java.nio.channels.FileChannel.open(FileChannel.java:287)
at java.nio.channels.FileChannel.open(FileChannel.java:335)
at java.util.logging.FileHandler.openFiles(FileHandler.java:438)
at java.util.logging.FileHandler.<init>(FileHandler.java:318)
at com.sun.enterprise.admin.launcher.GFLauncherLogger.addLogFileHandler(GFLauncherLogger.java:99)
at com.sun.enterprise.admin.launcher.GFLauncher.setup(GFLauncher.java:192)
at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.createLauncher(StartDomainCommand.java:228)
at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.executeCommand(StartDomainCommand.java:124)
at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:322)
at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:366)
at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:300)
at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:56)
Waiting for domain1 to start .Error starting domain domain1.
The server exited prematurely with exit code 1.
Command start-domain failed.
Before it died, it produced the following output:
Listening for transport dt_socket at address: 9009
Launching GlassFish on Felix platform
Exception in thread "main" java.lang.RuntimeException: the domain directory is not writable.
at com.sun.enterprise.glassfish.bootstrap.MainHelper.verifyDomainRoot(MainHelper.java:246)
at com.sun.enterprise.glassfish.bootstrap.MainHelper.findInstanceRoot(MainHelper.java:349)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:78)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
I'm using Ubuntu OS 14.04 LTS, java-1.7.0-openjdk-amd64.
Glassfish installed in /home/glassfish, asadmin script have 777 permissions.
Server starts when i run it from terminal, but not from IDE.
Please help, it makes me mad!
See this "java.nio.file.AccessDeniedException" it says all. Give permissions to the gassfish folder.
sudo chmod -R 777 /wherever-the-folder-is/glassfish-folder
Have you tried to start IntelliJ with sudo permission and start the server within the ide?
open CMD as Run as Administrator and then start the glassfish domain. so that the domain will start.

Not able to start hybris in debug mode

When tying to start Hybris in debug mode using Eclipse Kepler showing error
“Failed to connect to remote VM. Connection refused.
Connection refused: connect”
Even I tried by changing the default port also
tomcat.debugjavaoptions=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
but showing the same error. Any help/suggestion will be appreciated.
Please change first debug port using below property
tomcat.debug.port=<please provide port which is free>
in local.properties file then start server using
hybrisserver.bat debug
Place tomcat.debug.port= into local.properties.
Place tomcat.debugjavaoptions=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=port_number>,suspend=n -Xverify:none -DforceANSI=true into local.properties
Go to eclipse Debug Configuration, set port same as in local.properties.
In commons tab check Debug option
Place tomcat.enable.debug=true into catalina.properties
Then start server hybrisserver.bat debug (For Windows OS).
tomcat.debugjavaoptions=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=50021,suspend=n -Xverify:none -DforceANSI=true
Close Eclipse/intelliJ
Change port
ant all & hybrisserverstart.bat debug
Step 1: Go to local.properties in config folder and add the following lines:
tomcat.debug.port=8001
tomcat.debugjavaoptions=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8001,suspend=n -Xverify:none -DforceANSI=true
Make sure the port you use (here 8001) is free.
Step 2: Go to \hybris\bin\platform\tomcat\conf\catalina.properties and add:
tomcat.enable.debug=true
Step 3: ant all
Step 4: hybrisserver.bat debug
Personally tried and tested, works fine!
which version of hybris are you using?
How do you currently start hybris? Is hybris and eclipse on the same machine? do you have admin privileges?
i am using hybris 3.1 with eclipse-helios.
First i start hybris without eclipse in debugmode: using ...\platform\tomcat-6\bin\debug.bat at commandline.
After that i start debugging by attaching the eclipse-debugger to that debugmode-running hybris instance using a eclipse debug configuration "remote java application" with connection Properties: host=localhost, port=8000.
you should run your hybris server with -debug option in console and by default connect debugger to port 9000 . that worked with me
Go to ...\hybris\bin\platform and run hybrisserver.bat debug in windows
or hybrisserver.sh in unix
This will start the hybris server in debug mode
During server start up, you can see a line that says hybris server starting in debug mode at the very start.
Running hybris\bin\platform\hybrisserver.bat debug should start your server ready to debug but all it actually does is use the configuration in hybris\bin\platform\tomcat\conf\wrapper-debug.conf. So you need to check that file and add the following lines if they are missing:
wrapper.java.additional.34=-Xdebug
wrapper.java.additional.35=-Xnoagent
wrapper.java.additional.36=-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
Note the numbers (e.g. 34, 35, 36) need to be adapted according to which additional lines you already have in your .conf file.
Start hybrisserver.bat debug and wait till it's fully started. Then you can connect on port 80 (set in IntellJ under Run -> Edit Configurations -> Remote...)
Open file hybris\bin\platform\tomcat\conf\wrapper-debug.conf and go to the following line:
wrapper.java.additional.36=-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
In that change port number 8000 to 8001.

Unable to open debugger port in IntelliJ

Unable to open debugger port in intellij.
The port number 9009 matches the one which has been set in the configuration file for the application.
<java-config debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009" system-classpath="" native-library-path-prefix="D:\Project\lib\windows\64bit" classpath-suffix="">
<jvm-options>-XX:MaxPermSize=192m</jvm-options>
<jvm-options>-client</jvm-options>
<jvm-options>-XX:+UnlockDiagnosticVMOptions</jvm-options>
<jvm-options>-XX:+LogVMOutput</jvm-options>
<jvm-options>-XX:LogFile=${com.sun.aas.instanceRoot}/logs/jvm.log</jvm-options>
<jvm-options>-Djava.endorsed.dirs=${com.sun.aas.installRoot}/modules/endorsed${path.separator}${com.sun.aas.installRoot}/lib/endorsed</jvm-options>
<jvm-options>-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy</jvm-options>
<jvm-options>-Djava.security.auth.login.config=${com.sun.aas.instanceRoot}/config/login.conf</jvm-options>
<jvm-options>-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as</jvm-options>
<jvm-options>-Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/config/keystore.jks</jvm-options>
<jvm-options>-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/cacerts.jks</jvm-options>
<jvm-options>-Djava.ext.dirs=${com.sun.aas.javaRoot}/lib/ext${path.separator}${com.sun.aas.javaRoot}/jre/lib/ext${path.separator}${com.sun.aas.instanceRoot}/lib/ext</jvm-options>
<jvm-options>-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver</jvm-options>
<jvm-options>-DANTLR_USE_DIRECT_CLASS_LOADING=true</jvm-options>
<jvm-options>-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory</jvm-options>
<jvm-options>-Dosgi.shell.telnet.port=4766</jvm-options>
<jvm-options>-Dosgi.shell.telnet.maxconn=1</jvm-options>
<jvm-options>-Dosgi.shell.telnet.ip=127.0.0.1</jvm-options>
<jvm-options>-Dfelix.fileinstall.dir=${com.sun.aas.installRoot}/modules/autostart/</jvm-options>
<jvm-options>-Dfelix.fileinstall.poll=5000</jvm-options>
<jvm-options>-Dfelix.fileinstall.debug=1</jvm-options>
<jvm-options>-Dfelix.fileinstall.bundles.new.start=true</jvm-options>
<jvm-options>-Dorg.glassfish.web.rfc2109_cookie_names_enforced=false</jvm-options>
<jvm-options>-XX:NewRatio=2</jvm-options>
<jvm-options>-Xmx2048m</jvm-options>
</java-config>
Configuration in IntelliJ:
When I try and enable the remote debugging in for this application it comes up with the following error:
You may have to change the debugger port if your port is already used by another program. To do so:
Run
Edit Configurations
Startup/Connection tab
Debug
Change the port here
Or, maybe in other versions:
Run
Edit Configurations
Remote > Remote debug in the list on the left
Configuration tab, Settings section
Port: change the port here
Add the following parameter debug-enabled="true" to this line in the glassfish configuration.
Example:
<java-config debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009" debug-enabled="true"
system-classpath="" native-library-path-prefix="D:\Project\lib\windows\64bit" classpath-suffix="">
Start and stop the glassfish domain or service which was using this configuration.
I had the same problem and this solution also did the trick for me: Provide the IP 127.0.0.1 in the Intellij Debug configuration instead of the host name "localhost", in case you're using this hostname.
You must set CHMOD +x (execute for *.sh or *.bat files). For example, I am using macOS
cd /Users/donhuvy/Documents/tools/apache-tomcat-9.0.12/bin
sudo chmod +x *.sh
Then IntelliJ IDEA, and Apache Tomcat running or debugging just good.
In glassfish\domains\domain1\config\domain.xml set before start server
<java-config classpath-suffix="" debug-options="-agentlib:jdwp=transport=dt_socket,address=9009,server=y,suspend=n" java-home="C:\Program Files\Java\jdk1.8.0_162" debug-enabled="true" system-classpath="">
or set debug-enabled="true" server=y,suspend=n in http://localhost:4848/common/index.jsf
In current Idea 2018 - Server Run Configuration - Debug - Port - address
I'm hoping your problem has been solved by now. If not, try this... It looks like you have server=y for both your app and IDEA. IDEA should probably be server=n. Also, the (IDEA) client should have an address that includes both the host name and the port, e.g., address=127.0.0.1:9009.
This one worked for me--
If the issue still persists (in case you are not using a glassFish server), then close your JIdea and stop the server. This will disable the ports connectivity. Then start your server and JIdea, this will start fresh connectivity with the ports, resolving the issue.
For me, the problem was that catalina.sh didnt have execute permissions. The "Unable to open debugger port in intellij" message appeared in Intellij, but it sort of masked the 'could not execute catalina.sh' error that appeared in the logs immediately prior.
This error can happen Tomcat is already running. So make sure Tomcat isn't running in the background if you've asked Intellij to start it up ( default ).
Also, check the full output window for more errors. As a more useful error may have preceded this one ( as was the case with my configuration just now )
Answer is pretty simple,
I also faced the problem finally I got perfect solution.
Create Debug
Create Remote debug with following configuration
Firstly run by debug.
It gives you waitng for socket 5005
then run with remote debug
Try to connect with telnet , if it connects then it shows below:
$telnet 10.238.136.165 9999
Trying 10.238.136.165...
Connected to 10.238.136.165.
Escape character is '^]'.
Connection closed by foreign host.
If port is not available (either because someone else is already connected to it or the port is not open etc) then it shows something like it shows like below:
$telnet 10.238.136.165 9999
Trying 10.238.136.165...
telnet: connect to address 10.238.136.165: Connection refused
telnet: Unable to connect to remote host
So I think one needs to see whether:
the application is property listening to port or not
or someone else has already connected to it
Also try to connect on that m/c itself first like
$telnet localhost 9999
Set the MAVEN_OPTS. It should work !!
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
mvn spring-boot:run -Dserver.port=8090
Run your Spring Boot application with the given command to enable debugging on port 6006 while the server is up on port 8090:
mvn spring-boot:run -Drun.jvmArguments='-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=6006' -Dserver.port=8090
Your Service/ Application might already be running. In Search enter Services and you will get list of services. Stop yours and then try again.
I had the same issue, I just have to remove the HTTP protocol from the URL. That's it.
I hope it works for you.
I once have this problem too.
My solution is to work around this problem by kill the application which is using the port.
Here is a article to teach us how to check which application is using which port, find it and kill/close it.
In my case, I was not setting the debug port while starting the application.
I am using tomcat to deploy 3 war files, and I forgot to configure the debug port.
Tomcat allows us to configure this via setenv.sh.
Here are the commands to create setenv.sh file in the bin directory of my tomcat installation and provide the debug arguments/port.
tee /usr/share/tomcat9/bin/setenv.sh << EOF
export CATALINA_OPTS="$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
EOF
service tomcat9 restart
Merely hitting the debug icon again fixed my problem in a few seconds.
Make sure to specify an SDK and Project SDK for your app under File --> Project Structure (Project | SDKs)

Categories

Resources