IDEA Intellij:Execute System Command in Java code, get java.rmi.server.ExportException

Answered

Start/Stop Tomcat Server normaly,but when execute system command in java code,result is : "java rmi server ExportException:Port already in use: 1099, nested exception is:java .net.BindException",after i kill the process which used the jmx port,the Idea was killed.

I believe that the IDEA jmx port and the java execute system command process  use the same port, how to solve this problem?

0
19 comments

Could you please clarify the problem? How do you execute the command and when? What steps would reproduce the problem?

0
Avatar
Permanently deleted user

This problem produced in this situation:

I start my tomcat server, send a get request from html,which caused a servlet execute a system command and return some data.100% occured.

Execute system command like below:

Runtime run = Runtime.getRuntime;

Process pr = run.exec(cmdString);

pr.waitFor();

 

This project works well in Eclipse,so i think it's IDEA caused this problem

 

0

I'm not sure how system command execution affects RMI and Tomcat JMX usage on port 1099.

0
Avatar
Permanently deleted user

In fact,the trouble is JMX usage on 1099 affects system command execution.My workmates got in trouble with the same problem with IDEA,but eclipse works well.

0

Try using some other port.

0
Avatar
Permanently deleted user

JMX use other port not work.

0

What do you mean? Did you try to change the port? What error do you get?

0
Avatar
Permanently deleted user

I changed the JMX port of tomcat to some other port like 12345 in Edit Configuration,then i got the error like :

java rmi server ExportException:Port already in use: 12345, nested exception is:java .net.BindException

0

Please upload a sample web application project that will reproduce the problem: https://intellij-support.jetbrains.com/hc/articles/206869619.

0

I have the same situation.

When I call this: "Runtime.getRuntime().exec("some sh in which call a .jar");

I get the same error:

"java.rmi.server.ExportException: Port already in use: 6000; nested exception is: "

Note that I've also changed my port to "6000".

0

Please provide the full stacktrace.

1

Whenexecuting in debug mode:

ERROR: transport error 202: connect failed: Conexão recusada
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]
22:34:05.247 [http-bio-8080-exec-7] ERROR br.jus.stm.migrant.core.ServicoMigracao - O comando "/dspace/bin/dspace import -a -c 123456789/2 -e marcio.rga@gmail.com -s /work/dspace/migrate/atas/351 -m /work/dspace/migrate/atas/351/contents" retornou erro: "ERROR: transport error 202: connect failed: Conexão recusadaERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]"
java.lang.Exception: O comando "/dspace/bin/dspace import -a -c 123456789/2 -e marcio.rga@gmail.com -s /work/dspace/migrate/atas/351 -m /work/dspace/migrate/atas/351/contents" retornou erro: "ERROR: transport error 202: connect failed: Conexão recusadaERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]"
at br.jus.stm.migrant.utils.CommandLineUtils.executaComandoNativo(CommandLineUtils.java:28) ~[dspace-migrant-core-1.0-SNAPSHOT.jar:?]
at br.jus.stm.migrant.core.ImportadorDSpaceBin.efetuaImportacao(ImportadorDSpaceBin.java:36) ~[dspace-migrant-core-1.0-SNAPSHOT.jar:?]
at br.jus.stm.migrant.core.ServicoMigracao.efetuaMigracaoDoItem(ServicoMigracao.java:97) [dspace-migrant-core-1.0-SNAPSHOT.jar:?]
at br.jus.stm.migrant.core.ServicoMigracao.iniciaMigracao(ServicoMigracao.java:77) [dspace-migrant-core-1.0-SNAPSHOT.jar:?]
at br.jus.stm.migrant.importacao.servlet.ImportacaoServlet.doGet(ImportacaoServlet.java:23) [classes/:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) [servlet-api.jar:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) [servlet-api.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [catalina.jar:7.0.82]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.82]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat7-websocket.jar:7.0.82]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.82]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.82]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) [catalina.jar:7.0.82]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) [catalina.jar:7.0.82]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) [catalina.jar:7.0.82]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) [catalina.jar:7.0.82]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.82]
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) [catalina.jar:7.0.82]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.82]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) [catalina.jar:7.0.82]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) [tomcat-coyote.jar:7.0.82]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) [tomcat-coyote.jar:7.0.82]
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) [tomcat-coyote.jar:7.0.82]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.82]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

 

When executing in run mode:

Erro: Exceção gerada pelo agente : java.rmi.server.ExportException: Port already in use: 6000; nested exception is:
java.net.BindException: Endereço já em uso (Bind failed)
22:36:03.882 [http-bio-8080-exec-1] ERROR br.jus.stm.migrant.core.ServicoMigracao - O comando "/dspace/bin/dspace import -a -c 123456789/2 -e marcio.rga@gmail.com -s /work/dspace/migrate/atas/351 -m /work/dspace/migrate/atas/351/contents" retornou erro: "Erro: Exceção gerada pelo agente : java.rmi.server.ExportException: Port already in use: 6000; nested exception is: java.net.BindException: Endereço já em uso (Bind failed)"
java.lang.Exception: O comando "/dspace/bin/dspace import -a -c 123456789/2 -e marcio.rga@gmail.com -s /work/dspace/migrate/atas/351 -m /work/dspace/migrate/atas/351/contents" retornou erro: "Erro: Exceção gerada pelo agente : java.rmi.server.ExportException: Port already in use: 6000; nested exception is: java.net.BindException: Endereço já em uso (Bind failed)"
at br.jus.stm.migrant.utils.CommandLineUtils.executaComandoNativo(CommandLineUtils.java:28) ~[dspace-migrant-core-1.0-SNAPSHOT.jar:?]
at br.jus.stm.migrant.core.ImportadorDSpaceBin.efetuaImportacao(ImportadorDSpaceBin.java:36) ~[dspace-migrant-core-1.0-SNAPSHOT.jar:?]
at br.jus.stm.migrant.core.ServicoMigracao.efetuaMigracaoDoItem(ServicoMigracao.java:97) [dspace-migrant-core-1.0-SNAPSHOT.jar:?]
at br.jus.stm.migrant.core.ServicoMigracao.iniciaMigracao(ServicoMigracao.java:77) [dspace-migrant-core-1.0-SNAPSHOT.jar:?]
at br.jus.stm.migrant.importacao.servlet.ImportacaoServlet.doGet(ImportacaoServlet.java:23) [classes/:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) [servlet-api.jar:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) [servlet-api.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [catalina.jar:7.0.82]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.82]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat7-websocket.jar:7.0.82]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.82]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.82]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) [catalina.jar:7.0.82]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) [catalina.jar:7.0.82]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) [catalina.jar:7.0.82]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) [catalina.jar:7.0.82]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.82]
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) [catalina.jar:7.0.82]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.82]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) [catalina.jar:7.0.82]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) [tomcat-coyote.jar:7.0.82]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) [tomcat-coyote.jar:7.0.82]
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) [tomcat-coyote.jar:7.0.82]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.82]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

 

PS:

Some messages are in Portuguese

0
Avatar
Permanently deleted user

Have you solved this problem?I got the same error again。That's really a big trouble。

0

Huangqichao,

Unfortunately the problem persists.

This is truly a headache.

 

Serge, if you need more input, just let me know.

0

Please report at https://youtrack.jetbrains.com/issues/IDEA with the sample project to reproduce attached and with idea.log (https://intellij-support.jetbrains.com/hc/articles/207241085), run console log.

0

Hello there,

I reported the situation in: https://youtrack.jetbrains.com/issue/IDEA-191453

I noticed that my problem occurs when the script uses $JAVA_HOME, just like the following:

java $JAVA_OPTS -jar hello-world-jar-1.0.jar

If I use the above command like this:

java -jar hello-world-jar-1.0.jar

The script executes correctly.

This can be considered, at least for me, a temporary work around.

0
Avatar
Permanently deleted user

Thank you Márcio Gurgel!

In my project,i run a command which called a gradle process or a android avd process,the command string like:

“/home/user/gradle4.1/bin/gradle aDebug”,this command will run a script with $JAVA_OPTS,then the problem occured.

1

Six years on, is there a solution to this problem? (Except instead of using $JAVA_HOME)

0

Sorry, no workaround or solution so far. I asked developers to check the issue as soon as possible.

0

Please sign in to leave a comment.