Cannot assign requested address: JVM_Bind

I had a “adobe@9” server instance running on box about a week or so back. I didn’t rip out the JVM like docs say for CF9 since I’m not worried about the “official” support. I know CF9 runs on 1.8u102 which is in the jre folder for box.

Today I go to start the instance and get a “Cannot assign requested address: JVM_Bind”. This appears to be an error when the JVM can’t start on the requested port.

If I move to a new dir and start an instance with all default values it runs.

The error is in C:\Users\me.CommandBox\cfml\system\services\ServerService.cfc: line 1371

How can I resolve this?

CommandBox:www> type server.json
{
“app”:{
“cfengine”:“adobe@9”
},
“web”:{
“host”:“admin.rcs.local”
}
}

I need more info. If the HTTP port is in use, CommandBox will just pick a new one for you. Which port then was in use? Where did you see this message? Are you on the latest version of CommandBox?

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I did an “upgrade” command and it said it was the latest. Sorry - didn’t write down what version.

I saw this message after typing “start” [enter].

I did “start”, without a defined port, a few times thinking it was select another random port. That didn’t work. I also tried changing ports such as “start port=8080” and started working my way up like 8081 etc. That didn’t work either.

I ended up removing my .CommandBox directory and my box directory for a fresh start. Then reinstalled box. It’s working using port 50639 on version 3.8.0+00766.

I’m going to shut it down and reboot and see what happens.

Hmm, I’d need to see the full unabridged console output of what is happening when you start the server. “didn’t work” is a little hard to decipher :slight_smile: Also double check that your hostname actually exists. That can cause issues if you’re missing a host file entry. Also, older versions of CommandBox didn’t have as good support for detecting if the ports were in use, so it’s possible upgrading CommandBox helped you

Starting with the –debug flag will also give you more information.
https://ortus.gitbooks.io/commandbox-documentation/content/embedded_server/debugging-server-starts.html

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Ah-ha. I thought I ruled out the host name by removing it from server.json before I reinstalled. But apparently not.

I added back in the host name and it failed. The reason not being that it didn’t exist in the hosts file, but that the IP was no longer assigned to my machine.

Once I corrected the IP binding, it worked. Thanks for your help Brad!

On to figuring out how to keep DSN’s intact after instance start/stops on CF9.

Ah yes, that will do it. Unfortunately, Java does not give a way to test and see if a port is in use, so the only way we can check is to try to bind to it in a try/catch and see if it errors out. That means that sometimes a port will error for other reasons even when it’s not bound to. If you look at this code here, you can see that I already have checks for several specific error types in place to try and combat this:

https://github.com/Ortus-Solutions/commandbox/blob/development/src/cfml/system/services/ServerService.cfc#L1384-L1404

If you wouldn’t mind debugging a bit, I’d be interested in seeing exactly what exception was being thrown for you and why it didn’t trigger any of those checks in the catch blocks.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

CommandBox:www> start --debug
Looking for server JSON file by convention: D:\websites\resortclosingservices-admin\www/server.json
webroot defaulted to location of server’s JSON file: D:\websites\resortclosingservices-admin\www
ERROR (3.8.0+00766)

Cannot assign requested address: JVM_Bind

C:\Users\chris.CommandBox\cfml\system\services\ServerService.cfc: line 1371
1369: var nextAvail = java.ServerSocket.init( javaCast( “int”, 0 ),
1370: javaCast( “int”, 1 ),
1371: java.InetAddress.getByName( arguments.host ) );
1372: var portNumber = nextAvail.getLocalPort();
1373: nextAvail.close();
called from C:\Users\chris.CommandBox\cfml\system\services\ServerService.cfc: line 499
497: }
498:
499: serverInfo.stopsocket = serverProps.stopsocket ?: serverJSON.stopsocket ?: getRandomPort( serverInfo.host );
500:
501: // relative trayIcon in server.json is resolved relative to the server.json
called from C:\Users\chris.CommandBox\cfml\system\modules_app\server-commands\commands\server\start.cfc: line 146
144:
145: // startup the server
146: return serverService.start( serverProps = arguments );
147:
148: // endpointException exception type is used when the endpoint has an issue that needs displayed,
called from C:\Users\chris.CommandBox\cfml\system\services\CommandService.cfc: line 310
308: // Run the command
309: try {
310: var result = commandInfo.commandReference.CFC.run( argumentCollection = parameterInfo.namedParameters );
311: lastCommandErrored = commandInfo.commandReference.CFC.hasError();
312: } catch( any e ){
called from C:\Users\chris.CommandBox\cfml\system\services\CommandService.cfc: line 135
133: var commandChain = resolveCommand( line );
134:
135: return runCommand( commandChain, line );
136: }
137:
called from C:\Users\chris.CommandBox\cfml\system\Shell.cfc: line 460
458: }
459: } else {
460: var result = variables.commandService.runCommandLine( arguments.command );
461: }
462:
called from C:\Users\chris.CommandBox\cfml\system\Shell.cfc: line 409
407: // If there’s input, try to run it.
408: if( len( trim( line ) ) ) {
409: callCommand( command=line, initialCommand=true );
410: }
411:
called from C:\Users\chris.CommandBox\cfml\system\Bootstrap.cfm: line 113
111:
112: // Running the “reload” command will enter this while loop once
113: while( shell.run( silent=silent ) ){
114: clearScreen = shell.getDoClearScreen();
115:
Cannot assign requested address: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method):-2
at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106):106
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387):387
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190):190
at java.net.ServerSocket.bind(ServerSocket.java:375):375
at java.net.ServerSocket.(ServerSocket.java:237):237
at sun.reflect.GeneratedConstructorAccessor19.newInstance(Unknown Source):-1
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45):45
at java.lang.reflect.Constructor.newInstance(Constructor.java:423):423
at lucee.runtime.reflection.pairs.ConstructorInstance.invoke(ConstructorInstance.java:52):52
at lucee.runtime.reflection.Reflector.callConstructor(Reflector.java:809):809
at lucee.runtime.java.JavaObject.init(JavaObject.java:295):295
at lucee.runtime.java.JavaObject.call(JavaObject.java:222):222
at lucee.runtime.java.JavaObject.call(JavaObject.java:259):259
at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1599):1599
at system.services.serverservice_cfc$cf.udfCall2(/commandbox/system/services/ServerService.cfc:1371):1371
at system.services.serverservice_cfc$cf.udfCall(/commandbox/system/services/ServerService.cfc):-1
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:766):766
at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1599):1599
at system.services.serverservice_cfc$cf.udfCall1(/commandbox/system/services/ServerService.cfc:499):499
at system.services.serverservice_cfc$cf.udfCall(/commandbox/system/services/ServerService.cfc):-1
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:643):643
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1778):1778
at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
at system.modules_app.server_commands315.commands.server.start_cfc$cf.udfCall(/commandbox/system/modules_app/server-commands/commands/server/start.cfc:146):146
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:643):643
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1778):1778
at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
at system.services.commandservice_cfc$cf.udfCall1(/commandbox/system/services/CommandService.cfc:310):310
at system.services.commandservice_cfc$cf.udfCall(/commandbox/system/services/CommandService.cfc):-1
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:766):766
at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1599):1599
at system.services.commandservice_cfc$cf.udfCall1(/commandbox/system/services/CommandService.cfc:135):135
at system.services.commandservice_cfc$cf.udfCall(/commandbox/system/services/CommandService.cfc):-1
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1761):1761
at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1599):1599
at system.shell_cfc$cf.udfCall3(/commandbox/system/Shell.cfc:460):460
at system.shell_cfc$cf.udfCall(/commandbox/system/Shell.cfc):-1
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775
at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
at system.shell_cfc$cf.udfCall2(/commandbox/system/Shell.cfc:409):409
at system.shell_cfc$cf.udfCall(/commandbox/system/Shell.cfc):-1
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:643):643
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1778):1778
at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
at users.chris._commandbox46.cfml.system.bootstrap_cfm$cf.call(/Users/chris/.CommandBox/cfml/system/Bootstrap.cfm:113):113
at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:957):957
at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:909):909
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:225):225
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:37):37
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2271):2271
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2234):2234
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:456):456
at lucee.runtime.engine.CFMLEngineImpl.cli(CFMLEngineImpl.java:760):760
at lucee.loader.engine.CFMLEngineWrapper.cli(CFMLEngineWrapper.java:267):267
at luceecli.CLIMain.run(CLIMain.java:223):223
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method):-2
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62):62
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43):43
at java.lang.reflect.Method.invoke(Method.java:498):498
at cliloader.LoaderCLIMain.execute(LoaderCLIMain.java:205):205
at cliloader.LoaderCLIMain.main(LoaderCLIMain.java:705):705

Ahh, that full stack trace tells me a lot more information! The issue wasn’t in the code that detects whether or not the port is in use, but the code that tries to get the next random port available from the operating system. Since it needs to bind to the host/IP that get a port, it was erroring because the IP wasn’t assigned to a local network adapter. In theory, maybe we could incorporate some of the checks that I linked to below into that method to try and produce a better error message. Unfortunately, the exceptions I get from Java are fairly crap.

Or maybe we could devise some checks (that will run across all operating systems) that can be used to validate a host entry to check for common issues before actually trying to bind to it. Then at least we could provide a more useful error message than the one Java gives.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

A general “try this” would also be useful when catching that specific generalized error.

https://ortussolutions.atlassian.net/browse/COMMANDBOX-700

Pulls welcome if you want to take a stab at it. Otherwise I’ll get to it in a while…

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com