通过 Boxfuse 将 Grizzly 应用程序部署到 AWS 失败
Deploying Grizzly app to AWS via Boxfuse fails
我有一个 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 版本做任何不同的事情,但我认为重点是我不必这样做。任何帮助表示赞赏。谢谢!
在 AWS 上用于单实例应用程序 BOXFUSE_INSTANCE_IP
包含该环境的应用程序的弹性 IP。在实例启动时,它仍然属于旧版本的应用程序(如果有的话),只有在健康检查通过后才会分配给该实例。
我有一个 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 版本做任何不同的事情,但我认为重点是我不必这样做。任何帮助表示赞赏。谢谢!
在 AWS 上用于单实例应用程序 BOXFUSE_INSTANCE_IP
包含该环境的应用程序的弹性 IP。在实例启动时,它仍然属于旧版本的应用程序(如果有的话),只有在健康检查通过后才会分配给该实例。