Java Service Wrapper错误1053

时间:2014-04-02 08:32:21

标签: java service wrapper

这是我用来创建服务的代码。它来自此处的链接Java service wrapper当我运行服务时遇到以下跟随错误。不知道如何开始这个。我应该如何解决这个问题

我已经仔细检查过Netbean中的代码,它没有任何错误,可以运行w / o任何问题。只有当我将其作为服务运行时,我才能启动它。

日志

INFO   | jvm 1    | 2014/04/02 16:00:45 | Accepting connections on port: 9001
ERROR  | wrapper  | 2014/04/02 16:01:14 | Startup failed: Timed out waiting for a signal from the JVM.

代码

public class HelloWorldServer
    implements Runnable
{
    private final Socket m_socket;
    private final int m_num;

    HelloWorldServer( Socket socket, int num )
    {
        m_socket = socket;
        m_num = num;

        Thread handler = new Thread( this, "handler-" + m_num );
        handler.start();
    }

    public void run()
    {
        try
        {
            try
            {
                System.out.println( m_num + " Connected." );
                BufferedReader in = new BufferedReader( new InputStreamReader( m_socket.getInputStream() ) );
                OutputStreamWriter out = new OutputStreamWriter( m_socket.getOutputStream() );
                out.write( "Welcome connection #" + m_num + "\n\r" );
                out.flush();

                while ( true )
                {
                    String line = in.readLine();
                    if ( line == null )
                    {
                        System.out.println( m_num + " Closed." );
                        return;
                    }
                    else
                    {
                        System.out.println( m_num + " Read: " + line );
                        if ( line.equals( "exit" ) ||line.equals( "quit" ) )
                        {
                            System.out.println( m_num + " Closing Connection." );
                            return;
                        }
                        else if ( line.equals( "crash" ) )
                        {
                            System.out.println( m_num + " Simulating a crash of the Server..." );
                            Runtime.getRuntime().halt(0);
                        }
                        else
                        {
                            System.out.println( m_num + " Write: echo " + line );
                            out.write( "echo " + line + "\n\r" );
                            out.flush();
                        }
                    }
                }
            }
            finally
            {
                m_socket.close();
            }
        }
        catch ( IOException e )
        {
            System.out.println( m_num + " Error: " + e.toString() );
        }
    }

    public static void main( String[] args )
        throws Exception
    {
        int port = 9001;
        if ( args.length > 0 )
        {
            port = Integer.parseInt( args[0] );
        }
        System.out.println( "Accepting connections on port: " + port );
        int nextNum = 1;
        ServerSocket serverSocket = new ServerSocket( port );
        while ( true )
        {
            Socket socket = serverSocket.accept();
            HelloWorldServer hw = new HelloWorldServer( socket, nextNum++ );
        }
    }
}

CONF

#********************************************************************
# Wrapper Java Properties
#********************************************************************
# Java Application
#  Locate the java binary on the system PATH:
wrapper.java.command=java
#  Specify a specific java binary:
#set.JAVA_HOME=/java/path
#wrapper.java.command=%JAVA_HOME%/bin/java
wrapper.java.command=java

# Tell the Wrapper to log the full generated Java command line.
#wrapper.java.command.loglevel=INFO

# Java Main class.  This class must implement the WrapperListener interface
#  or guarantee that the WrapperManager class is initialized.  Helper
#  classes are provided to do this for you.  See the Integration section
#  of the documentation for details.
wrapper.java.mainclass=HelloWorldServer

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=../build/classes
wrapper.java.classpath.3=../dist/HelloWorldServer.jar


# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=../lib

# Java Bits.  On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE

# Java Additional Parameters
wrapper.java.additional.1=

# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=3

# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=64

# Application parameters.  Add parameters as needed starting from 1
#wrapper.app.parameter.1=HelloWorldServer

0 个答案:

没有答案