当我尝试从Java代码启动Grizzly服务器时,出现错误提示。请帮助。
javax.ws.rs.ProcessingException:无法启动Grizzly HTTP服务器:无法分配请求的地址:绑定在org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:299)在org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:119)在org.alm.TestClient.setUp(TestClient.java:40)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在java.lang.reflect.Method.invoke(Method.java:606)在org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)在org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:130)在org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:173)在org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)在org.testng.TestRunner.runWorkers(TestRunner.java:1178)在org.testng.TestRunner.privateRun(TestRunner.java:757)在org.testng.TestRunner.run(TestRunner.java:608)在org.testng.SuiteRunner.runTest(SuiteRunner.java:334)在org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)在org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)在org.testng.SuiteRunner.run(SuiteRunner.java:240)在org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)在org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)在org.testng.TestNG.runSuitesSequentially(TestNG.java:1158)在org.testng.TestNG.runSuitesLocally(TestNG.java:1083)在org.testng.TestNG.run(TestNG.java:999)在org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)引起原因:java.net.BindException:无法分配请求的地址:绑定在sun.nio.ch.Net.bind0(本机方法)
代码
@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:无法启动Grizzly HTTP服务器:无法分配请求的地址:绑定在>
请确保在同一台计算机上使用相同的端口(即
8443
)没有运行任何应用程序。因为Grizzly会尝试获取相同的端口,但是它可能被同一台计算机上的另一个应用程序阻止。或者,您可以尝试分配其他端口。
我刚遇到此错误,但由于其他原因:DNS。