I came across an issue where I am not able to debug a maven sprint boot REST API application in IntelliJ. The application starts up but won't stop at any breakpoint.
Additionally when I stop the debugger I see below lines in the log, but I can see that the java process never terminates and when I start the app the 2nd time it fails because the server port 8080 is still in use.
Disconnected from the target VM, address: '127.0.0.1:53020', transport: 'socket'
Process finished with exit code -1
In the IntelliJ logs at C:\Users\Bernhard.IdeaIC2017.3\system\log I see the following error.
2017-12-15 07:22:30,761 [ 11899] INFO - .server.BuildMessageDispatcher - An existing connection was forcibly closed by the remote host
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1100)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:372)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
at java.lang.Thread.run(Thread.java:745)
You can probably wrap the value of that argument in quotations. The parser that reads the entire command line string is probably choking because of the -D arg within a -D arg.
clean package -Drun.profiles=dev-us-east-1 -Drun.jvmArguments="-Denvironment=dev" -DskipTests spring-boot:run
After some searching I found that the problem is with my Maven Run/Debug configuration in IntelliJ. The command line I use to start the spring boot rest api is
clean package -Drun.profiles=dev-us-east-1 -Drun.jvmArguments=-Denvironment=dev -DskipTests spring-boot:run
It appears that the -Drun.jvmArguments=-Denvironment=dev java command line property is the culprit. When I remove it the break points work again.
Related
I am trying to run integration tests on my java code from remote server, so whenever my tests hit my code server, jacoco records it.
I am new to jacoco, till now i have gather that there is tcp server method which doesnot require any restart.
I have added below line in my /etc/profile.
export JAVA_OPTS="-javaagent:/home/vansh/jacoco/lib/jacocoagent.jar=address=*,port=57026,destfile=/home/vansh/jacoco/jacoco.exec,output=tcpserver"
2)but when i am trying to take dump using below command -
java -jar jacococli.jar dump --address localhost --port 57026 --destfile /home/vansh/jacoco/jacoco-it.exec
ERROR:
[INFO] Connecting to localhost/127.0.0.1:57026.
[WARN] Connection refused (Connection refused).
[INFO] Connecting to localhost/127.0.0.1:57026.
Exception in thread "main" java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
I checked that there is nothing run on port 57026, is my first command javaagent one is correct?
I have done same thing a year ago, In my case I run a TCP_Client jar for collecting the dump with many ways(periodically/with and without resetting previous coverage).
I set JAVA_OPTS as follows,
-javaagent:<file_Path_for_jacoco_agent>/jacocoagent.jar=output=tcpserver,address=*,port=6300
Here is my repo link of tcp client - enter link description here
set fixed arguments to the code or create a jar with this repo
If you are running a jar from this code,
You can run this jar with passing "address" "port" "dump-folder-path" "periodic-time-for-dumping" "resetting-option-with-every-dump" arguments.
example : java -jar ExecutedDataDump.jar "127.0.0.1" "6300" "D:\\server-dumplog\\" "5" "noreset"
You will get get jacoco.exec files with time stamp in every 5 secs time and due to noreset every jacoco.exec is get cumulative report
Hope this will helpful for you.
I am using Spring Tool Suite. I check out demo projects in STS. It works fine without any problem before I installed updates in STS today or I installed Oracle SQL Developer recently.
The steps to reproduce my bug:
In STS, in "File" -> "New" -> "Import Spring Getting Started Content", then check out "Building a RESTful Web Service" this project.
https://spring.io/guides/gs/rest-service/ I go to my project folder, type 'mvnw spring-root:run' (I am using Windows). Then got following error.
I do not if this bug related to I installed two updated in STS today or I installed Oracle SQL Developer recently.
Here is the error:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE:run (default-cli) on project gs-rest-service: An exception occurred while running. null: InvocationTargetException: Connector configured to listen on port 8080 failed to start -> [Help 1]
Then, I checked out the solution in here:
https://stackoverflow.com/a/27416379/8229192
It works after I kill the task which uses the port 8080.
c:\>netstat -ano | find "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 3088
TCP [::]:8080 [::]:0 LISTENING 3088
c:\>taskkill /F /PID 3088
SUCCESS: The process with PID 1196 has been terminated.
My questions are:
Why will I have port conflict? Because I installed Oracle SQL Developer? How can I know exactly which software is using port 8080 also?
I want to know if I kill the task (A) which uses that port 8080, will it cause an issue when this task (A) run later?
I have checked out other projects (like: https://spring.io/guides/gs/scheduling-tasks/). I did not need to kill the task which is also using port 8080, I just directly run "mvnw spring-boot:run". It works and it does not have port number 8080 conflict. Why? Why some have port 8080 conflict, why some are not? This is very confused me. Thanks.
Oracle-XE, OracleXETNSListener service, uses port 8080 to serve its
Application Express.
You kill OracleXETNSListener service, it has no problem at all because you
use SQL Developer not Application Express. Or you can disable its auto start configuration.
Spring Boot's project, serves web server, uses port 8080 by default, you can run with different port Spring Boot - how to configure port, and https://spring.io/guides/gs/scheduling-tasks is not web serving project so it doesn't use any port.
hope this can help you
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.
I am trying to debug following maven project in Eclipse:
https://code.google.com/p/cloudscale/
I followed the instructions of RickHigh (found here https://stackoverflow.com/a/19986408/3014213) and when I write mvnDebug exec:exec in Terminal the lines
Preparing to Execute Maven in Debug Mode
Listening for transport dt_socket at address: 8000
appears and after starting the Remote Java Application in Eclipse, the project is started BUT it does not hold on breakpoints...
Any ideas, what could go wrong?
When you install m2e plugin in Eclipse, it will show you a link in Console view to automatically connect debugger (i.e. create remote debugger launch configuration) to your process when it spills "Listening for transport dt_socket at address: 8000" message to the console. So, your debugger is basically one click away.
The debugger may be connected to the wrong JVM - not the one created by exec:exec. Try remote debugging like here: https://stackoverflow.com/a/22367089/1878731
I want to be able to start my play application in test mode on Heroku is this possible?
I added this Procfile:
web: play test --http.port=$PORT $PLAY_OPTS
But when I start the server I can see this in the Hereoku logs.
←[32m2012-01-15T19:11:04+00:00 heroku[web.1]:←[0m State changed from crashed to created
←[32m2012-01-15T19:11:04+00:00 heroku[web.1]:←[0m State changed from created to starting
←[32m2012-01-15T19:11:16+00:00 heroku[web.1]:←[0m Starting process with command `play test --http.port=19429 --%prod -Dprecompiled=true
`
←[32m2012-01-15T19:11:17+00:00 app[web.1]:←[0m Listening for transport dt_socket at address: 8000
←[32m2012-01-15T19:11:18+00:00 app[web.1]:←[0m 19:11:18,040 INFO ~ Starting /app
←[32m2012-01-15T19:11:18+00:00 heroku[web.1]:←[0m Error R11 (Bad bind) -> Process bound to port 8000, should be 19429 (see environment
variable PORT)
←[32m2012-01-15T19:11:18+00:00 heroku[web.1]:←[0m Stopping process with SIGKILL
←[32m2012-01-15T19:11:18+00:00 app[web.1]:←[0m 19:11:18,048 INFO ~ Module scala is available (/app/modules/scala-0.9.1)
←[32m2012-01-15T19:11:19+00:00 heroku[web.1]:←[0m State changed from starting to crashed
←[32m2012-01-15T19:11:19+00:00 heroku[web.1]:←[0m Process exited
I guess it's because play uses jpda.port=8000 by default and Heroku crashes with default parameters. Their documentation does not comment on test mode at all what I have seen so have anyone successfully started play in test mode on Heroku? I think I would need something like --jpda.port=$PORT2 in the procfile
An application on Heroku can only open one port (The one provided in the $PORT variable). Unfortunately this means that Play! test mode can't open up the second port that it would need for remote debugging.