java.net.SocketException:无法识别的Windows套接字错误:0:JVM_Bind(JBOSS)

时间:2010-10-16 03:28:01

标签: java windows-7 jboss java-ee jvm


我在Windows 7上使用JBoss 4.0.5 GA和Java 1.5版(我必须使用旧的Java版本和JBoss,因为我正在使用遗留系统)。当我启动服务器时,我收到以下错误:

java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind  

我相信这会导致许多其他例外情况:

11:09:26,925 WARN  [ServiceController] Problem starting servicejboss.cache:service=TomcatClustering Cache
java.lang.NullPointerException
    at org.jgroups.protocols.FD_SOCK.down(FD_SOCK.java:235)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.protocols.FD.down(FD.java:278)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.stack.Protocol.down(Protocol.java:540)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.protocols.pbcast.NAKACK.down(NAKACK.java:297)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.protocols.UNICAST.down(UNICAST.java:262)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.protocols.pbcast.STABLE.down(STABLE.java:292)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.protocols.pbcast.GMS.down(GMS.java:605)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.protocols.FC.down(FC.java:122)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.protocols.FRAG2.down(FRAG2.java:146)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.Protocol.passDown(Protocol.java:510)
    at org.jgroups.protocols.pbcast.STATE_TRANSFER.down(STATE_TRANSFER.java:217)
    at org.jgroups.stack.Protocol.receiveDownEvent(Protocol.java:467)
    at org.jgroups.stack.ProtocolStack.down(ProtocolStack.java:331)
    at org.jgroups.JChannel.down(JChannel.java:1035)
    at org.jgroups.JChannel.connect(JChannel.java:374)
    at org.jboss.cache.TreeCache.startService(TreeCache.java:1424)
    at org.jboss.cache.aop.PojoCache.startService(PojoCache.java:94)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)

    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy4.start(Unknown Source)
    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy8.deploy(Unknown Source)
    at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
    at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
    at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
    at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)

    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy4.start(Unknown Source)
    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy5.deploy(Unknown Source)
    at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    at org.jboss.Main.boot(Main.java:200)
    at org.jboss.Main$1.run(Main.java:490)
    at java.lang.Thread.run(Thread.java:619)  

如果有人能提供帮助,我非常感谢。至少要弄清楚我应该在哪里寻找解决方案(例如,这是一个与Windows 7和JBoss群集不兼容的错误吗?这是因为错误的端口配置吗?等等)

感谢。

11 个答案:

答案 0 :(得分:28)

在某些安装了IPv6 TCP堆栈的Windows系统上会出现此问题。如果计算机上同时安装了IPv4和IPv6,则Java虚拟机(JVM)可能在关闭或打开操作系统级别的套接字时遇到问题。

添加以下JVM选项:-Djava.net.preferIPv4Stack=true

我已经看到这种情况发生在默认安装了IPv4和IPv6堆栈的Windows 7和Windows 2008系统上。

答案 1 :(得分:15)

你很可能已经绑定了JBoss正在使用的端口上的另一个进程(8080?),这会阻止JBoss正确启动(请参阅this page以获取JBoss使用的端口列表)。

找到冲突的进程并将其关闭:

  • 使用netstat -a -o -n并查找JBoss使用的端口(例如8080)和相应的pid
  • 然后使用tasklist /FI "PID eq <pid>"查找流程

或者更改JBoss默认端口。有几种方法可以做到这一点,但最好的方法是使用Service Binding Manager(请参阅Configuring Multiple JBoss Instances On One Machine中的详细说明。)

答案 2 :(得分:3)

我有类似的问题。我使用process-xp并终止javaw.exe,然后重新启动应用程序。它对我有用。

答案 3 :(得分:3)

我在Win7上遇到了同样的问题,试图在这里实现这个例子: http://download.oracle.com/javase/tutorial/networking/sockets/clientServer.html

示例代码中的默认端口是4444.我使用此端口 “无法识别的Windows套接字错误:0:JVM_Bind”

我将端口更改为44444并再次尝试。我从Windows防火墙服务获得一个弹出窗口,询问我该应用程序是否有权访问网络。选择确定我在启动服务器时不再收到错误消息。

经过一些实验后,我发现端口为5000或更小时,我会得到JVM_Bind错误。任何5001或以上的端口都会毫无问题地绑定。

答案 4 :(得分:2)

这是JAVA 32/64位的问题。尝试用32位JVM运行你的jar

答案 5 :(得分:2)

我的Tomcat遇到了这个问题,它变成了与Skype的端口冲突。在我的Skype-&gt;选项 - &gt;高级 - &gt;连接中,我取消选中以下“使用端口80和443作为传入连接的替代方法”。这完全解决了这个问题。

答案 6 :(得分:2)

这解决了我的问题:)添加以下JVM选项:-Djava.net.preferIPv4Stack = true

答案 7 :(得分:2)

我在Windows 10上遇到了与Tomcat相同的问题。将其添加到顶部附近的catalina.bat文件中:

SET JAVA_OPTS=-Djava.net.preferIPv4Stack=true

答案 8 :(得分:1)

我知道这是一个老问题,但我最近刚刚找到了问题的一个原因,以及解决方案。我的服务器套接字程序工作正常,直到我将代码放入循环,然后在第一次尝试后每次尝试Unrecognized Windows Sockets error: 0: JVM_Bind时出现错误accept()。我有这样的代码:

ServerSocket ssock = null;
Socket sock = null;

while (loopCount < loopLimit) {
    ssock = new ServerSocket(port);
    ssock.setSOLimit(millis);
    sock = ssock.accept();
    // some code here...
    loopCount++;
}

只有当我将ssock = new ServerSocket(port)ssock.setSOLimit(millis);置于循环之上时才消除错误。

答案 9 :(得分:0)

以管理员身份打开命令提示符。然后执行 netsh winsock重置

答案 10 :(得分:0)

我不得不在Java参数中添加SystemRoot参数。我不知道为什么Java没有这个参数。以前在工作。使用

SystemRoot = C:\ Windows

有效。 我将Java作为Windows服务nssm执行。