I have a Grizzly application that I'm trying to deploy to AWS using Boxfuse. The Grizzly server is started like so:
String instanceIP = System.getProperty(BOXFUSE_INSTANCE_IP)
String port = System.getProperty(BOXFUSE_PORTS_HTTP)
String BASE_URI = "http://" + instanceIP + ":" + port;
System.out.println(BASE_URI);
final ResourceConfig rc = new ResourceConfig().packages("com.homer.web");
GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
This all works fine locally (I see my 'Hello World' page if I go to http://localhost:8080) but when I push to AWS I get this Grizzly error:
i-620cd2df => http://52.58.25.146:8080
i-620cd2df => Exception in thread "main" javax.ws.rs.ProcessingException: Failed to start Grizzly HTTP server: Cannot assign requested address
i-620cd2df => at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:299)
i-620cd2df => at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:119)
i-620cd2df => at com.homer.web.MyApp.main(MyApp.java:43)
i-620cd2df => Caused by: java.net.BindException: Cannot assign requested address
i-620cd2df => at sun.nio.ch.Net.bind0(Native Method)
i-620cd2df => at sun.nio.ch.Net.bind(Net.java:433)
i-620cd2df => at sun.nio.ch.Net.bind(Net.java:425)
i-620cd2df => at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
i-620cd2df => at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
i-620cd2df => at org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler.bindToChannelAndAddress(TCPNIOBindingHandler.java:131)
i-620cd2df => at org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler.bind(TCPNIOBindingHandler.java:88)
i-620cd2df => at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:248)
i-620cd2df => at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:228)
i-620cd2df => at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:219)
i-620cd2df => at org.glassfish.grizzly.http.server.NetworkListener.start(NetworkListener.java:714)
i-620cd2df => at org.glassfish.grizzly.http.server.HttpServer.start(HttpServer.java:278)
i-620cd2df => at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:296)
I don't know if I'm supposed to do anything differently for the AWS version but I thought the point was I wouldn't have to. Any help is appreciated. Thanks!