java - 无法启动 Grizzly http 服务器

标签 java rest jakarta-ee grizzly

当我尝试从 Java 代码启动 Grizzly 服务器时,出现以下错误。请帮忙。

javax.ws.rs.ProcessingException: Failed to start Grizzly HTTP server: Cannot assign requested address: bind at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:299) at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:119) at org.alm.TestClient.setUp(TestClient.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130) at
org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105) at org.testng.TestRunner.runWorkers(TestRunner.java:1178) at org.testng.TestRunner.privateRun(TestRunner.java:757) at org.testng.TestRunner.run(TestRunner.java:608) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1158) at org.testng.TestNG.runSuitesLocally(TestNG.java:1083) at org.testng.TestNG.run(TestNG.java:999) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76) Caused by: java.net.BindException: Cannot assign requested address: bind at sun.nio.ch.Net.bind0(Native Method)

代码

@BeforeClass
    public void setUp() throws Exception
    {
        final ResourceConfig rc = new ResourceConfig(AlmApiStub.class);
        System.out.println(config.host()+config.port());
        server = GrizzlyHttpServerFactory.createHttpServer(
                URI.create(String.format("https://%s:%s/", config.host(), config.port())), rc);
    }

最佳答案

javax.ws.rs.ProcessingException: Failed to start Grizzly HTTP server: Cannot assign requested address: bind at

确保没有任何应用程序在同一台计算机上运行,​​使用相同的端口,即 8443。因为 Grizzly 会尝试获取相同的端口,但它可能会被同一台计算机上的另一个应用程序阻止。或者,您可以尝试分配不同的端口。

关于java - 无法启动 Grizzly http 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48236926/

相关文章:

java - Arduino - Serial.read() 无法读取两位数数据?

java - 为什么 (int) (Math.random() * 0xFFFFFFFF) 是 0

php - Symfony2 实体用户提供者覆盖自定义身份验证提供者

api - 与Twilio一样,按日期对REST API进行版本控制有什么好处?

java - 如何正确管理 EJBException

java - Java 的 SAAS 框架

java - 从 jTextArea 上的 shell 命令获取结果

java - 使用数组矩阵RGB java将图像转换为灰度

http - 网络服务器应该忽略额外的查询参数还是返回错误?

javascript - 如何使用 Watir 单击由 javascript 生成的元素?