I am new to SpringBoot and java.I have build a SpringBoot2 app,I want to deploy it in a cloud server. I have specify that port in Application-online.properties like
server.port=9090 but when I use IDEA MAVEN clean and package command to build a jar then copy to cloud server.
I use
nohup java -jar -Dserver.port=9090 -Dspring.profiles.active=online ./mall-0.0.1-SNAPSHOT.jar > /root/imooc_mall/mall.log 2>&1
then quickly the program exit. the mall.log report :
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 9090 was already in use.
Action:
Identify and stop the process that's listening on port 9090 or configure this application to listen on another port.
[06:25 23:31:32.595] [INFO] [org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor] - Shutting down ExecutorService 'applicationTaskExecutor'
Noticably, 9090 is the second port I use, before that I use 8081 meet same error. Just like whatever I use any port,it always in use. And I have confirm that the 9090 and 8081 is not in use use netstat -tulpn and lsof -i :8081/9090 . I don't know what's the problem.Hope someone can give some ideals.Thanks advance!
The Environment are Centos7 and SpringBoot2.2.1, Java1.8,and Tomcat is SpringBoot in-build version
Another thing is that I have successed in starting the springboot app at first,But I use kill -9 to stop the program. After that the above errors occurs and never success .I wonder if that have any bad effect on the question.
But I am sure the port is not in use.
I still use SpringBoot 2.2.1.But not package it with built-in Tomcat.Instead, I install Tomcat server on the server. And Packaging SpringBoot application as war package. And I finally successed in running the application.
I'm running my Spring Boot application with debug mode enabled. Like:
mvn -P dev spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
I can debug the application after that without any problem. But, after stopped (ctrl + c) and try to start again, I receive this error:
[INFO] Attaching agents: []
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
So, every time that I need to start the application in debug mode after that, I need to kill the process using the port 5005.
I would like to know why the port 5005 is still opened after stop the application.
I'm using Cygwin64 on Windows 10, Maven 3.5.2, Java 8 and Spring Boot 1.5.9.RELEASE.
Thanks!
This is not a problem of Spring Boot, but a problem of non-cygwin applications running in cygwin. And your application is not only leaving port 5005 open, it just keeps running in the background, having port 8080 also opened, but as on a restart the debug port is first opened, this is what you see in the error message.
This was discussed in a SpringBoot issue back in 2014 https://github.com/spring-projects/spring-boot/issues/773. I cite from this issue (the link in the citation dates from 2006):
Anyone still following this bug, this isn't a Spring Boot bug at all. It's a known problem with non-Cygwin programs (Java in this case) running on pty-based terminals.
See this link for a full explanation why this can't be fixed: http://cygwin.com/ml/cygwin/2006-12/msg00151.html
So you can basically use one of the following approaches:
use the native windows terminal and setup your java and maven environment for that
run your maven command from within an IDE which can handle this - you might use this for debugging as well
add the Spring Actuator to your app and use the /shutdown endpoint to stop your application
I am trying to debug a simple Java application on my machine using Eclipse as an IDE. When I try to debug the application by entering the Debug Perspective, I set a breakpoint and start debug. Within a few seconds, the following pop-up window:
Launching unicodeRead has encountered a problem. Cannot connect to VM.
The message dumped on the console is as follows:
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:708]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
How do I correct this? Why does this happen?
I just had the same problem.
Yesterday everything worked fine, now nothing - same error as you gave. I found out that network admins made some changes in the meantime. Some firewall stuff. Problem is that Eclipse tries to establish connection to JVM at "localhost" (and some random port). When I tried pinging localhost (or 127.0.0.1) I got following:
C:\Windows\system32>ping 127.0.0.1
Pinging 127.0.0.1 with 32 bytes of data:
PING: transmit failed. General failure.
PING: transmit failed. General failure.
PING: transmit failed. General failure.
PING: transmit failed. General failure.
and
C:\Windows\system32>ping localhost
Ping request could not find host localhost. Please check the name and try again.
It seams that in some cases DNS is expected to resolve this, and if firewall prevents localhost requests to DNS - stuff breaks. I had to alter hosts file and remove comments in following lines, so I would not rely on DNS for this anymore:
# 127.0.0.1 localhost
# ::1 localhost
Although it is written that hosts file changes take effect immediately, I think that some processes locked this and restart was necessary in my case. After that, everything worked again.
Had same problem, but the solution was to run the application with -server=y option and not with -server=n.
Before:
java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:5005
After:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005
Looks like the same problem as here. A reboot of the pc fixed the problem there. I haven't found any other solutions.
I was seeing an error while using the -X format:
java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n myapp
The error went away when I switched to the newer format:
java -agentlib:jdwp=transport=dt_socket,server=y,address=4000,suspend=n myapp
Its Very Simple,Just do the Following Changes in eclipse.ini file.
-vm
binary\com.sun.java.jdk.win32.x86_1.6.0.u43\jre\bin\javaw.exe
I changed
-agentlib:jdwp=transport=dt_socket,address=9009,server=n,suspend=y
to
-agentlib:jdwp=transport=dt_socket,address=9009,server=y,suspend=n
and that did the trick!
My case is I have a bunch of domains refer to 127.0.0.1 in hosts file, like this:
127.0.0.1 localhost domian1.local domain2.local domain3.local
one day I added another new domain to refer to 127.0.0.1. By mistake, I put the domain in front of "localhost", like this:
127.0.0.1 domain4.local localhost domian1.local domain2.local domainx.local
After this, I always got an alert window in eclipse while debugging:
Cannot connect to VM
com.sun.jdi.connect.TransportTimeoutException
In console:
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP: Failed to initialize transport via localhost:50470, trying localhost via 127.0.0.1:50470
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
The solution is keep "localhost" at the first position all the time.
127.0.0.1 localhost domian1.local domain2.local domainx.local domain4.local
What solved for me was deleting the entire domain1 folder inside the domains folder on glassfish main folder.
Eclipse will ask you to recreate a domain and then everything works again.
In eclipse select Run tab -> Debug configuration -> Junit -> select your test name ->
Environment tab -> add variable server=y .
I was getting the same error on my ubuntu machine because of a mishap with the /etc/hosts file. I had commented out the mapping of localhost to 127.0.0.1, and to complicate matters further there was a swap file hanging around.
This was the first line of my /etc/hosts:
127.0.0.1 #localhost
Deleting the # fixed the problem, whereas rebooting understandably had not.
My cause & solution were completely different.
I think in my case it was due to the installation of JProfiler. I fixed it by uninstalling JProfiler and launching eclipse with the -clean option. I suspect that JProfiler was inserting itself in the debugger. The -clean option forces Eclipse to re-assess its plugins, so that alone might have been sufficient.
Continuing #gonadarian's answer, it seems Eclipse uses port 127.0.0.1 for debug purposes. This port is also called localhost. The way this error can be removed is by ensuring that there are no processes or services running on the above ports. The way to do this, on Linux is:
As root, enter the command:
netstat -tulpn | grep 127.0.0.1
If there are processes running on the above port, it will show up in the format:
process_id/process name.
Kill the above processes like so: kill -KILL process_id
Restart the computer for these changes to take effect. The error should no longer occur.
I have a server that is "named" and it seems to cause Grails to be unable to find localhost.
Running Grails application..
2011-01-12 20:45:14,046 [main] ERROR ehcache.Cache - Unable to set localhost. This prevents creation of a GUID. Cause was: zaftra: zaftra
java.net.UnknownHostException: zaftra: zaftra
at java.net.InetAddress.getLocalHost(InetAddress.java:1426)
at net.sf.ehcache.Cache.<clinit>(Cache.java:143)
at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:463)
at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:369)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:445)
at net.sf.ehcache.CacheManager.init(CacheManager.java:302)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:260)
at net.sf.ehcache.hibernate.EhCacheProvider.start(EhCacheProvider.java:128)
Contents of /etc/hosts (as shown):
127.0.0.1 localhost localhost.localdomain zaftra
::1 localhost localhost.localdomain zaftra
I'm going to assume that you're on some flavor of linux. If that's the case, you might have a look at your /etc/hosts file - is there an entry for localhost? I'd expect to see something like:
127.0.0.1 localhost zaftra
::1 localhost
I did some Googling - there's a similar question over on SuperUser - the suggestion there was to add the following to /etc/resolv.conf:
search (domainname) // in your case, search (zaftra)
You might also try:
search zaftra
// or
search zaftra.example.com // if there's a more fully-qualified domain name you can use
(That's based off of an entry I've got in resolv.conf on one of my Ubuntu machines).
I'm using AWS(running amazon linux) and ran into the exact same issue, my fix was to add this to /etc/hosts:
102.130.27.257 LAMP-LIVE01-N123 www.mydomain.com
where those values came from:
{internal IP} {instance name} {domain for grails app}
and then I restarted httpd and my grails app server(tomcat)
I am trying to deploy a simple WebService in Netbeans 6.7.1 and Glassfish v2.1.1 and am getting the following error. I am using GlassfishESBv2.2 and windows 7 machine. I have tried googling and implemented things as shown in
http://forums.netbeans.org/topic10055-0-asc-0.html . Still unable to deploy. Though the message says that application server is not started, from the Server tab , I am able to see a message which indicates Glassfish has started.Also , doing a netstat after trying to deploy returns this, which means that Glassfish is running.
C:>netstat -an | findstr "4848"
TCP 0.0.0.0:4848 0.0.0.0:0 LISTENING
I have been trying real hard to get this resolved. Any help is highly appreciated.
Error Message :
The Sun Java System Application Server could not start.
More information about the cause is in the Server log file.
Possible reasons include:
- IDE timeout: refresh the server node to see if it's running now.
- Port conflicts. (use netstat -a to detect possible port numbers already used by the operating system.)
- Incorrect server configuration (domain.xml to be corrected manually)
- Corrupted Deployed Applications preventing the server to start.(This can be seen in the server.log file. In this case, domain.xml needs to be modified).
- Invalid installation location.
C:\Users\xyz\Documents\NetBeansProjects\HWebService\nbproject\build-impl.xml:564: Deployment error:
The Sun Java System Application Server could not start.
More information about the cause is in the Server log file.
Possible reasons include:
- IDE timeout: refresh the server node to see if it's running now.
- Port conflicts. (use netstat -a to detect possible port numbers already used by the operating system.)
- Incorrect server configuration (domain.xml to be corrected manually)
- Corrupted Deployed Applications preventing the server to start.(This can be seen in the server.log file. In this case, domain.xml needs to be modified).
- Invalid installation location.
See the server log for details.
BUILD FAILED (total time: 29 seconds)
I've described the solution please visit here...
http://forums.netbeans.org/post-65058.html