Java 无法启动 GlassFish 4.0 (Windows) - 端口 1527 - 地址已在使用中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23521740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 23:32:53  来源:igfitidea点击:

Could not start GlassFish 4.0 (Windows) - port 1527 - Address already in use

javawindowsjakarta-eeglassfishnetbeans-7

提问by Juan Jose Polanco Arias

I'm a newbie in Java EE 7.

我是 Java EE 7 的新手。

I have Netbeans 7.4 with GlassFish 4.0 and Java EE 7. In a 64-bit Windows 8.1 Pro machine. I want to start the GlassFish 4.0 Server, so I clicked on the services tab in Netbeans and then in the Servers option I right-clicked GlassFish Server 4.0 and then clicked Start.

我有带有 GlassFish 4.0 和 Java EE 7 的 Netbeans 7.4。在 64 位 Windows 8.1 Pro 机器中。我想启动 GlassFish Server 4.0 服务器,因此我单击 Netbeans 中的服务选项卡,然后在服务器选项中右键单击 GlassFish Server 4.0,然后单击启动。

When I did that I got the following message: "Could not start GlassFish Server 4.0: HTTP or HTTPS listener port is occupied while server is not running". I have also the IIS server, but I stopped it. After stopping IIS I tried to start again the GlassFish but it showed me the same message.

当我这样做时,我收到以下消息:“无法启动 GlassFish Server 4.0:服务器未运行时 HTTP 或 HTTPS 侦听器端口被占用”。我也有 IIS 服务器,但我停止了它。停止 IIS 后,我尝试再次启动 GlassFish,但它显示了相同的消息。

Also there is a window in Netbeans called Output - Java DB Database Processand it showed me the following:

Netbeans 中还有一个名为Output - Java DB Database Process的窗口,它向我展示了以下内容:

Tue May 06 22:03:11 GMT-05:00 2014 : Security manager installed using the Basic server security policy.
Tue May 06 22:03:11 GMT-05:00 2014 Thread[main,5,main] java.io.FileNotFoundException: D:\Users\Juan Jose\.netbeans-derby\derby.log (Access is denied)
Tue May 06 22:03:12 GMT-05:00 2014 : Could not listen on port 1527 on host localhost:
 java.net.BindException: Address already in use: JVM_Bind
Tue May 06 22:03:12 GMT-05:00 2014 : Could not listen on port 1527 on host localhost:
 java.net.BindException: Address already in use: JVM_Bind

I ran a netstat -a in Windows to see what was happening with the 1527 port and that port is in LISTENING mode.

我在 Windows 中运行了 netstat -a 以查看 1527 端口发生了什么并且该端口处于侦听模式。

So how can I know what application or process is ocuppying the 1527 port?

那么我怎么知道哪个应用程序或进程占用了 1527 端口呢?

Thanks for your help !!

谢谢你的帮助 !!

采纳答案by Paul Vargas

To find the process1that keeps the busy port, try the following command:

要查找保持繁忙端口的进程1,请尝试以下命令:

netstat -ano | find "1527"

This will show a line with the port and the identifier of the process. e.g.:

这将显示带有端口和进程标识符的行。例如:

TCP    127.0.0.1:1527         0.0.0.0:0              LISTENING       2268

Once you have the process ID (e.g. 2268), run the following command for release the port (this will kill the process):

获得进程 ID(例如2268)后,运行以下命令以释放端口(这将终止进程):

taskkill /F /PID 2268

Now, try to start Glassfish.

现在,尝试启动 Glassfish。



On Linux:

在 Linux 上:

lsof -Pnl +M -i6 | grep 1527

Produces:

产生:

java    31139     1001   32u  IPv6 114916062      0t0  TCP 127.0.0.1:1527 (LISTEN)

Killed with:

被杀死:

kill -9 31139


1If you want to know the associated program, see How do I find out what service is using a certain port?

1如果您想了解相关程序,请参阅如何找出正在使用某个端口的服务?

回答by John Clingan

This is not an error you need to worry about. When you start GlassFish, NetBeans will also start the JavaDB (aka, Derby) database, which listens on port 1527 by default. When you shut down NetBeans, it will shut down GlassFish but will not shut down JavaDB. Therefore, when you start NetBeans a second time, NetBeans will try to start JavaDB again and fail because it is already running and listening on port 1527.

这不是您需要担心的错误。当您启动 GlassFish 时,NetBeans 还将启动 JavaDB(又名 Derby)数据库,该数据库默认侦听端口 1527。当您关闭 NetBeans 时,它会关闭 GlassFish,但不会关闭 JavaDB。因此,当您第二次启动 NetBeans 时,NetBeans 将尝试再次启动 JavaDB 并失败,因为它已经在运行并侦听端口 1527。

To shut down the database, you can use the NetBeans Services(Tab)->Databases->JavaDB(right click->Stop Server. To shut down from the command line use $NETBEANS_HOME/glassfish-4.0/javadb/bin/stopNetworkServer, where $NETBEANS_HOME is the top-level directory where NetBeans is installed (at least on Mac/Linux/Unix).

要关闭数据库,您可以使用 NetBeans Services(Tab)->Databases->JavaDB(右键单击->Stop Server。从命令行关闭使用 $NETBEANS_HOME/glassfish-4.0/javadb/bin/stopNetworkServer,其中 $NETBEANS_HOME 是安装 NetBeans 的顶级目录(至少在 Mac/Linux/Unix 上)。

回答by TechDog

If the above doesn't work for anyone pls follow the below steps.. Sure It will work..

如果以上对任何人都不起作用,请按照以下步骤操作..当然它会起作用..

  1. Go to C:\Program Files\glassfish-4.1\glassfish\domains\domain1\config

  2. Open "domain.xml" in a xml editor or u can use notepad++

  3. Find "8080"(below highlighted for ur reference)

    network-listener port="8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool" enter image description here

  4. Replace "8080" with any open port. If you don't know how to find out open port try to use port no "3702" then save your file

  5. now run your project

  1. 转到C:\Program Files\glassfish-4.1\glassfish\domains\domain1\config

  2. 在 xml 编辑器中打开“domain.xml”或者你可以使用 notepad++

  3. 找到“8080”(下面突出显示供您参考)

    network-listener port=" 8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool" 在此处输入图片说明

  4. 用任何开放端口替换“8080”。如果您不知道如何找出开放端口,请尝试使用端口号“3702”,然后保存您的文件

  5. 现在运行你的项目

After running the project please have an eye on the URL

运行项目后请注意网址

http://localhost:8080/......should be http://localhost:3702/.....

http://localhost:8080/...应该是http://localhost:3702/.....

To get open ports follow the below steps

要获得开放端口,请按照以下步骤操作

  1. open cmd.exe

  2. execute cmd "netstat -ano"

  1. 打开cmd.exe

  2. 执行cmd“netstat -ano”

Pick any one which you find is free(Like inside the green box above ) enter image description here

选择您认为免费的任何一个(如上面的绿色框内) 在此处输入图片说明