问题描述:

We have a Nexus server which worked fine until friday. Nexus was stopped and since we are unable to start it again but I can't figure out why ?

I think it's a Jetty problem. Here is the stack strace:

jvm 1 | 2012-08-13 09:31:10 WARN [er_start_runner] - org.mortbay.log - failed [email protected]*: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)

The configuration is (jetty.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>

and the 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 version is 1.9.2.3

I can't understand:

why it wants to start a connector at port 8080 (while I only set port 8081) and

what means the address * (and why not 0.0.0.0) ? And of course why it doesn't want to start anymore ?

Thanks a lot for all your ideas!

网友答案:

Solved!

The file jetty.xml had only the 'r' permission which is not enough: it must have the 'x' permission too. So Jetty was unable to read the file jetty.xml and in that case it tries to start a default connector on '*:8080' => * is not resolvable (I don't know why they used * instead of 0.0.0.0 ???)

So it was a configuration issue.

网友答案:

I cannot comment on the 8080 vs 8081 issue, but as for the SocketException ...

The SocketException: unresolved address is usually due to some sort of host/dns/resolve configuration issue present on your system.

The most basic testcase for java that might help identify the issue would be the following

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();
        }
    }
}

Run this, and you should have the output

InetAddress => /0.0.0.0
InetAddress.isAnyLocalAddress = true
InetAddress.isLinkLocalAddress = false
InetAddress.isLoopbackAddress = false
InetSocketAddr = /0.0.0.0:8080
InetSocketAddr.isUnresolved = false

What's important to note are the 2 lines...

  • InetAddress.isAnyLocalAddress = true - means that java + OS reports this as the ANY addr
  • InetSocketAddr.isUnresolved = false - means that java + OS was able to resolve this socket address

If you get an exception during this test, then you have some sort of fundamental host resolution issue on your system (dns, dhcp. vpn, etc/hosts, no IPv4 available, etc...), nothing you do in java, jetty, or nexus can fix this sort of issue. You'll need to address this (no pun intended) at the OS / Networking level.

相关阅读:
Top