gpt4 book ai didi

java - 无法启动 Grizzly http 服务器

转载 作者:行者123 更新时间:2023-12-02 02:22:55 25 4
gpt4 key购买 nike

当我尝试从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com