我们有一个Nexus服务器,直到星期五都运行良好。Nexus被停止了,因为我们无法再次启动它,但我无法弄清楚为什么?
我认为这是一个码头问题。下面是堆栈跟踪:
jvm 1 | 2012-08-13 09:31:10 WARN [er_start_runner] - org.mortbay.log - failed SelectChannelConnector@*:8080
jvm 1 | java.net.SocketException: Unresolved address
jvm 1 | at sun.nio.ch.Net.translateToSocketException(Net.java:58)
jvm 1 | at sun.nio.ch.Net.translateException(Net.java:84)
jvm 1 | at sun.nio.ch.Net.translateException(Net.java:90)
jvm 1 | at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:61)
jvm 1 | at org.mortbay.jetty.nio.SelectChannelConnector.open(SelectChannelConnector.java:216)
配置为(码头.xml):
<Configure id="Server" class="org.mortbay.jetty.Server">
<Call name="addConnector">
<Arg>
<New class="org.mortbay.jetty.nio.SelectChannelConnector">
<Set name="host">${application-host}</Set>
<Set name="port">${application-port}</Set>
</New>
</Arg>
</Call>
<Set name="handler">
<New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection">
<!-- The following configuration is REQUIRED, and MUST BE FIRST.
It makes the Plexus container available for use in the Nexus webapp. -->
<Call name="addLifeCycleListener">
<Arg>
<New class="org.sonatype.plexus.jetty.custom.InjectExistingPlexusListener" />
</Arg>
</Call>
<!-- The following configuration disables JSP taglib support, the validation of which
slows down Jetty's startup significantly. -->
<Call name="addLifeCycleListener">
<Arg>
<New class="org.sonatype.plexus.jetty.custom.DisableTagLibsListener" />
</Arg>
</Call>
</New>
</Set>
<New id="NexusWebAppContext" class="org.mortbay.jetty.webapp.WebAppContext">
<Arg><Ref id="Contexts"/></Arg>
<Arg>${webapp}</Arg>
<Arg>${webapp-context-path}</Arg>
<Set name="extractWAR">false</Set>
</New>
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
</Configure>
和 plexus.properties:
application-port=8081
application-host=0.0.0.0
runtime=${basedir}/runtime
apps=${runtime}/apps
nexus-work=${basedir}/../../data/nexus/sonatype-work/nexus
nexus-app=${runtime}/apps/nexus
webapp=${runtime}/apps/nexus/webapp
webapp-context-path=/nexus
security-xml-file=${nexus-work}/conf/security.xml
application-conf=${nexus-work}/conf
runtime-tmp=${runtime}/tmp
# If this file is present, it will be used to configure Jetty.
jetty.xml=${basedir}/conf/jetty.xml
# Uncomment this to use the debug js files
#index.template.file=templates/index-debug.vm
Nexus版本是1.9.2.3
我无法理解:为什么它想在端口 8080 启动连接器(而我只设置端口 8081)和地址*是什么意思(为什么不是0.0.0.0)?当然,为什么它不想再开始了?
非常感谢您的所有想法!
我无法评论 8080 与 8081 问题,但至于套接字异常......
套接字异常:未解析的地址通常是由于系统上存在某种主机/dns/解析配置问题。
可能有助于识别问题的 java 最基本的测试用例如下
import java.net.InetAddress;
import java.net.InetSocketAddress;
public class AddrTest
{
public static void main(String[] args)
{
try
{
InetAddress addr = InetAddress.getByName("0.0.0.0");
System.out.println("InetAddress => " + addr);
System.out.println("InetAddress.isAnyLocalAddress = " + addr.isAnyLocalAddress());
System.out.println("InetAddress.isLinkLocalAddress = " + addr.isLinkLocalAddress());
System.out.println("InetAddress.isLoopbackAddress = " + addr.isLoopbackAddress());
InetSocketAddress isockaddr = new InetSocketAddress(addr,8080);
System.out.println("InetSocketAddr = " + isockaddr);
System.out.println("InetSocketAddr.isUnresolved = " + isockaddr.isUnresolved());
}
catch (Throwable e)
{
e.printStackTrace();
}
}
}
运行这个,你应该有输出
InetAddress => /0.0.0.0
InetAddress.isAnyLocalAddress = true
InetAddress.isLinkLocalAddress = false
InetAddress.isLoopbackAddress = false
InetSocketAddr = /0.0.0.0:8080
InetSocketAddr.isUnresolved = false
需要注意的是 2 行...
-
InetAddress.isAnyLocalAddress = true
- 表示 java + OS 将此报告为 ANY 地址 -
InetSocketAddr.isUnresolved = false
- 表示 java + OS 能够解析此套接字地址
如果在此测试期间遇到异常,那么您的系统上存在某种基本的主机解析问题(dns,dhcp.vpn等/主机,没有可用的IPv4等),您在java,jetty或nexus中所做的任何事情都无法解决此类问题。 您需要在操作系统/网络级别解决此问题(无双关语)。
我也有类似的问题。Jetty 在 docker 容器内运行(jetty:9.3.24-jre8)。你需要在start.ini中注释掉关于http.host的行:
#jetty.http.host='0.0.0.0'
由于某种原因,网络接口会混淆。
解决了!
文件码头.xml只有"r"权限,这还不够:它还必须具有"x"权限。所以 Jetty 无法读取文件码头.xml在这种情况下,它尝试在"*:8080"上启动默认连接器 => * 是不可解析的(我不知道为什么他们使用 * 而不是 0.0.0.0 ???)
所以这是一个配置问题。