我有一个Grizzly应用程序,我尝试使用Boxfuse部署到AWS。 Grizzly服务器就像这样启动:
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);
这一切在本地工作正常(如果我去http://localhost:8080,我会看到我的' Hello World'页面)但是当我推送到AWS时,我得到了这个Grizzly错误:
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)
我不知道我是否应该为AWS版本做任何不同的事情,但我认为重点是我不必。任何帮助表示赞赏。谢谢!
答案 0 :(得分:0)
在AWS上,单实例应用程序BOXFUSE_INSTANCE_IP
包含该环境的应用程序的弹性IP。在实例启动时,它仍然属于应用程序的旧版本(如果有的话),并且只有在健康检查通过后才会分配给该实例。