Java 已使用地址:JVM_Bind

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3714957/
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-14 03:50:16  来源:igfitidea点击:

Address already in use: JVM_Bind

javajakarta-eeglassfish

提问by Bogdan

I'm using Glassfish 3.0.1, JVM 1.6.0_21 on Windows XP Pro;

我在 Windows XP Pro 上使用 Glassfish 3.0.1、JVM 1.6.0_21;

I don't know exactly what has changed in my environment but I get this stacktrace as soon as I try to deploy an enterprise application (ejb module + app client module).

我不知道我的环境到底发生了什么变化,但是一旦我尝试部署企业应用程序(ejb 模块 + 应用程序客户端模块),我就会得到这个堆栈跟踪。

There is nothing running on port 3820, except Glassfish... I checked with netstat with the server stopped and the server started.

除了 Glassfish 之外,端口 3820 上没有任何东西在运行……我在服务器停止并启动服务器的情况下检查了 netstat。

What could be the cause of this? Some internal process conflict?

这可能是什么原因?一些内部进程冲突?

Any tips on how I can debug this further?

关于如何进一步调试的任何提示?

WARNING: Can not find resource bundle for this logger.  class name that failed: org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory
SEVERE: iiop.createsocket_exception
WARNING: Can not find resource bundle for this logger.  class name that failed: org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory
SEVERE: java.net.BindException: Address already in use: JVM_Bind
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
        at java.net.ServerSocket.bind(ServerSocket.java:319)
        at java.net.ServerSocket.<init>(ServerSocket.java:185)
        at javax.net.ssl.SSLServerSocket.<init>(SSLServerSocket.java:106)
        at com.sun.net.ssl.internal.ssl.SSLServerSocketImpl.<init>(SSLServerSocketImpl.java:106)
        at com.sun.net.ssl.internal.ssl.SSLServerSocketFactoryImpl.createServerSocket(SSLServerSocketFactoryImpl.java:72)
        at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSSLServerSocket(IIOPSSLSocketFactory.java:402)
        at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createServerSocket(IIOPSSLSocketFactory.java:281)
        at com.sun.corba.ee.impl.transport.SocketOrChannelAcceptorImpl.initialize(SocketOrChannelAcceptorImpl.java:91)
        at com.sun.corba.ee.impl.transport.CorbaTransportManagerImpl.getAcceptors(CorbaTransportManagerImpl.java:247)
        at com.sun.corba.ee.impl.transport.CorbaTransportManagerImpl.addToIORTemplate(CorbaTransportManagerImpl.java:264)
        at com.sun.corba.ee.spi.oa.ObjectAdapterBase.initializeTemplate(ObjectAdapterBase.java:131)
        at com.sun.corba.ee.impl.oa.poa.POAImpl.initialize(POAImpl.java:474)
        at com.sun.corba.ee.impl.oa.poa.POAImpl.makeRootPOA(POAImpl.java:323)
        at com.sun.corba.ee.impl.oa.poa.POAFactory.evaluate(POAFactory.java:279)
        at com.sun.corba.ee.impl.orbutil.closure.Future.evaluate(Future.java:57)
        at com.sun.corba.ee.impl.resolver.LocalResolverImpl.resolve(LocalResolverImpl.java:51)
        at com.sun.corba.ee.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:55)
        at com.sun.corba.ee.impl.orb.ORBImpl.resolve_initial_references(ORBImpl.java:1289)
        at com.sun.corba.ee.impl.naming.cosnaming.TransientNameService.initialize(TransientNameService.java:122)
        at com.sun.corba.ee.impl.naming.cosnaming.TransientNameService.<init>(TransientNameService.java:90)
        at org.glassfish.enterprise.iiop.impl.PEORBConfigurator.configure(PEORBConfigurator.java:154)
        at com.sun.corba.ee.impl.orb.ORBConfiguratorImpl.runUserConfigurators(ORBConfiguratorImpl.java:191)
        at com.sun.corba.ee.impl.orb.ORBConfiguratorImpl.configure(ORBConfiguratorImpl.java:176)
        at com.sun.corba.ee.impl.orb.ORBImpl.postInit(ORBImpl.java:579)
        at com.sun.corba.ee.impl.orb.ORBImpl.set_parameters(ORBImpl.java:680)
        at com.sun.corba.ee.impl.orb.ORBImpl.setParameters(ORBImpl.java:666)
        at com.sun.corba.ee.spi.osgi.ORBFactory.initialize(ORBFactory.java:91)
        at org.glassfish.enterprise.iiop.impl.GlassFishORBManager.initORB(GlassFishORBManager.java:612)
        at org.glassfish.enterprise.iiop.impl.GlassFishORBManager.getORB(GlassFishORBManager.java:289)
        at org.glassfish.enterprise.iiop.impl.GlassFishORBFactoryImpl.createORB(GlassFishORBFactoryImpl.java:83)
        at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:122)
        at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getProtocolManager(GlassFishORBHelper.java:189)
        at com.sun.ejb.containers.BaseContainer.initializeProtocolManager(BaseContainer.java:810)
        at com.sun.ejb.containers.BaseContainer.<init>(BaseContainer.java:558)
        at com.sun.ejb.containers.AbstractSingletonContainer.<init>(AbstractSingletonContainer.java:136)
        at com.sun.ejb.containers.CMCSingletonContainer.<init>(CMCSingletonContainer.java:73)
        at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:109)
        at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:207)
        at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:197)
        at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:63)
        at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:175)
        at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:216)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:338)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.execute(CommandRunnerImpl.java:305)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access0(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)

WARNING: Can not find resource bundle for this logger.  class name that failed: org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory
WARNING: Can not find resource bundle for this logger.  class name that failed: org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory
SEVERE: "IOP00410216: (COMM_FAILURE) Unable to create IIOP listener on the specified host/port: all interfaces/3820"

EDITHere it's exactly what I tried:

编辑这正是我尝试过的:

C:\Documents and Settings\b.tanase>netstat -p tcp -ano | findstr :3820

asadmin> start-domain domain1
Waiting for DAS to start ...
Started domain: domain1
Domain location: D:\java\glassfish-3.0.1\glassfish\domains\domain1
Log file: D:\java\glassfish-3.0.1\glassfish\domains\domain1\logs\server.log
Admin port for the domain: 4848
Command start-domain executed successfully.

C:\Documents and Settings\b.tanase>netstat -p tcp -ano | findstr :3820

asadmin> deploy d:/java/projects/netbeans-projects/CountingSystem/dist/CountingS
ystem.ear
com.sun.enterprise.admin.cli.CommandException: remote failure: Exception while l
oading the app : java.lang.RuntimeException: EJB Container initialization error
Exception while invoking class org.glassfish.ejb.startup.EjbDeployer load method
 : java.lang.RuntimeException: EJB Container initialization error


Command deploy failed.

C:\Documents and Settings\b.tanase>netstat -p tcp -ano | findstr :3820
  TCP    0.0.0.0:3820           0.0.0.0:0              LISTENING       2428

As you can see there's nothing listening on port 3820 until the deployment failes (before EJB Container initialization error I get in the server log the stacktrace posted at the beggining of the post)

正如您所看到的,在部署失败之前,端口 3820 上没有任何监听(在 EJB 容器初始化错误之前,我在服务器日志中获取了在帖子开始时发布的堆栈跟踪)

采纳答案by MrPotes

I notice you are using windows, which is particularly bad about using low port numbers for outgoing sockets. See herefor how to reserve the port number that you want to rely on using for glassfish.

我注意到您正在使用 Windows,这对于将低端口号用于传出套接字尤其不利。请参阅此处了解如何保留要用于 glassfish 的端口号。

回答by J-16 SDiZ

Your local port 443 / 8181 / 3820 is used.

您的本地端口 443 / 8181 / 3820 已使用。

If you are on linux/unix:

如果您使用的是 linux/unix:

  • use netstat -anand lsof -nto check who is using this port
  • 使用netstat -anlsof -n检查谁在使用这个端口

If you are on windows

如果你在窗户上

  • use netstat -anand tcpviewto check.
  • 使用netstat -antcpview检查。

回答by Aravind Yarram

as the exception says there is already another server running on the same port. you can either kill that service or change glassfish to run on another poet

因为异常说已经有另一台服务器在同一端口上运行。您可以终止该服务或更改 glassfish 以运行另一位诗人

回答by Tom Clift

The logged error does say that port 3820 is the problem, but I would suggest investigating allthe ports that your app is trying to listen on. I ran into this problem and the issue was a port that I'd forgotten about - not the "main" one that I was looking for.

记录的错误确实表明端口 3820 是问题所在,但我建议调查您的应用程序试图侦听的所有端口。我遇到了这个问题,问题是我忘记了一个端口 - 而不是我正在寻找的“主要”端口。

回答by Contango

As an aside, under Windows, ProcessExploreris fantastic for observing the existing TCP/IP connections for each process.

顺便说一句,在 Windows 下,ProcessExplorer非常适合观察每个进程的现有 TCP/IP 连接。

回答by prathip

You can try to use TCPViewutility.

您可以尝试使用TCPView实用程序。

Try to find in the localportcolumn is there any process worked on "busy"port. Right click and end the process. Then try to start the Tomcat.

尝试在localport列中查找是否有任何进程在“繁忙”端口上工作。右键单击并结束该过程。然后尝试启动Tomcat

Its really works for me.

它真的对我有用。

回答by epeleg

on windows open a cmd.exe window with administrator permissions and use netstat -a -b -oyou will get the id of the proccess that holds your port and be able to kill it using task manager.

在 Windows 上打开一个具有管理员权限的 cmd.exe 窗口并使用netstat -a -b -o您将获得保存您的端口的进程的 ID,并能够使用任务管理器将其杀死。

回答by Dirk Schumacher

My answer does 100% fit to this problem, but I want to document my solution and the trap behind it, since the Exception is the same.

我的答案 100% 适合这个问题,但我想记录我的解决方案及其背后的陷阱,因为异常是相同的。

My port was always in use testing a Jetty in a Junit testcase. Problem was Google's code pro on Eclipse, which, I guess, was testing in the background and thus starting jetty before me all the time. Workaround: let Eclipse open *.java files always w/ the Java editor instead of Google's Junit editor. That seems to help.

我的端口一直用于在 Junit 测试用例中测试 Jetty。问题是 Eclipse 上的 Google 代码专家,我猜它是在后台进行测试,因此一直在我之前启动 jetty。解决方法:让 Eclipse 始终使用 Java 编辑器而不是 Google 的 Junit 编辑器打开 *.java 文件。这似乎有帮助。

回答by Lijo George

This problem mostly occurs because there could be another istance of the code running, from some previous tests you did most probably. Find out and close any other instance or if it is ok, try restarting the server.

出现此问题的主要原因是代码可能存在另一个运行阶段,这可能是您之前做过的一些测试。找出并关闭任何其他实例,如果没有问题,请尝试重新启动服务器。