Programa Java como Serviço no Windows Server

6 respostas
S

Pessoal andei pesquisando e vi que a galera usa o JavaService para colocar os programas em java como serviço no windows.

Eu usei este exemplo para fazer testes com o meu programa java http://javafree.uol.com.br/files_user/files/A/6D/EB/JavaService.rar

Na minha maquina usando Windows 7 tudo deu certo, agora ao fazer o mesmo processo no Windows Server 2003 e 2008 no momento que executo o bat de instalação diz que o serviço não pode ser iniciado, o usuário que estou usando é o administrador do sistema.

Gostaria de saber se alguém teve este problema em tentar colocar um jar como serviço no Windows Server e como resolveu?

Obrigado!

6 Respostas

B

Shakall:
Pessoal andei pesquisando e vi que a galera usa o JavaService para colocar os programas em java como serviço no windows.
Eu usei este exemplo para fazer testes com o meu programa java http://javafree.uol.com.br/files_user/files/A/6D/EB/JavaService.rar
Na minha maquina usando Windows 7 tudo deu certo, agora ao fazer o mesmo processo no Windows Server 2003 e 2008 no momento que executo o bat de instalação diz que o serviço não pode ser iniciado, o usuário que estou usando é o administrador do sistema.
Gostaria de saber se alguém teve este problema em tentar colocar um jar como serviço no Windows Server e como resolveu?
Obrigado!

Eu utilizo o Java Service Wrapper e nunca tive problemas, funciona em várias plataformas.
Verifique a possibilidade de utiliza-lo.

S

bombbr:
Shakall:
Pessoal andei pesquisando e vi que a galera usa o JavaService para colocar os programas em java como serviço no windows.
Eu usei este exemplo para fazer testes com o meu programa java http://javafree.uol.com.br/files_user/files/A/6D/EB/JavaService.rar
Na minha maquina usando Windows 7 tudo deu certo, agora ao fazer o mesmo processo no Windows Server 2003 e 2008 no momento que executo o bat de instalação diz que o serviço não pode ser iniciado, o usuário que estou usando é o administrador do sistema.
Gostaria de saber se alguém teve este problema em tentar colocar um jar como serviço no Windows Server e como resolveu?
Obrigado!

Eu utilizo o Java Service Wrapper e nunca tive problemas, funciona em várias plataformas.
Verifique a possibilidade de utiliza-lo.

Problema que Wrapper não fuciona em Server 2008. Queria uma solução para ambos 2003 e 2008

S

E ae amigo, consegui configurar o Wrapper, mas estou com um problema, ao iniciar o serviço ele fica no status de Iniciando e não sai disso, minha aplicação está funcionando de boa, depois de algum tempo no log da o seguinte erro e minha aplicação para de funcionar. Tem idéia do que seja?

STATUS | wrapper  | 2012/11/27 23:25:37 | --> Wrapper Started as Service
STATUS | wrapper  | 2012/11/27 23:25:37 | Java Service Wrapper Community Edition 32-bit 3.5.16
STATUS | wrapper  | 2012/11/27 23:25:37 |   Copyright (C) 1999-2012 Tanuki Software, Ltd. All Rights Reserved.
STATUS | wrapper  | 2012/11/27 23:25:37 |     http://wrapper.tanukisoftware.com
STATUS | wrapper  | 2012/11/27 23:25:37 | 
STATUS | wrapper  | 2012/11/27 23:25:38 | Launching a JVM...
INFO   | jvm 1    | 2012/11/27 23:25:38 | Finalizado:631
ERROR  | wrapper  | 2012/11/27 23:26:07 | Startup failed: Timed out waiting for a signal from the JVM.
ADVICE | wrapper  | 2012/11/27 23:26:07 | 
ADVICE | wrapper  | 2012/11/27 23:26:07 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:26:07 | Advice:
ADVICE | wrapper  | 2012/11/27 23:26:07 | The Wrapper consists of a native component as well as a set of classes
ADVICE | wrapper  | 2012/11/27 23:26:07 | which run within the JVM that it launches.  The Java component of the
ADVICE | wrapper  | 2012/11/27 23:26:07 | Wrapper must be initialized promptly after the JVM is launched or the
ADVICE | wrapper  | 2012/11/27 23:26:07 | Wrapper will timeout, as just happened.  Most likely the main class
ADVICE | wrapper  | 2012/11/27 23:26:07 | specified in the Wrapper configuration file is not correctly initializing
ADVICE | wrapper  | 2012/11/27 23:26:07 | the Wrapper classes:
ADVICE | wrapper  | 2012/11/27 23:26:07 |     Main
ADVICE | wrapper  | 2012/11/27 23:26:07 | While it is possible to do so manually, the Wrapper ships with helper
ADVICE | wrapper  | 2012/11/27 23:26:07 | classes to make this initialization processes automatic.
ADVICE | wrapper  | 2012/11/27 23:26:07 | Please review the integration section of the Wrapper's documentation
ADVICE | wrapper  | 2012/11/27 23:26:07 | for the various methods which can be employed to launch an application
ADVICE | wrapper  | 2012/11/27 23:26:07 | within the Wrapper:
ADVICE | wrapper  | 2012/11/27 23:26:07 |     http://wrapper.tanukisoftware.com/doc/english/integrate.html
ADVICE | wrapper  | 2012/11/27 23:26:07 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:26:07 | 
ERROR  | wrapper  | 2012/11/27 23:26:07 | JVM did not exit on request, terminated
STATUS | wrapper  | 2012/11/27 23:26:12 | Launching a JVM...
ERROR  | wrapper  | 2012/11/27 23:26:41 | Startup failed: Timed out waiting for a signal from the JVM.
ADVICE | wrapper  | 2012/11/27 23:26:41 | 
ADVICE | wrapper  | 2012/11/27 23:26:41 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:26:41 | Advice:
ADVICE | wrapper  | 2012/11/27 23:26:41 | The Wrapper consists of a native component as well as a set of classes
ADVICE | wrapper  | 2012/11/27 23:26:41 | which run within the JVM that it launches.  The Java component of the
ADVICE | wrapper  | 2012/11/27 23:26:41 | Wrapper must be initialized promptly after the JVM is launched or the
ADVICE | wrapper  | 2012/11/27 23:26:41 | Wrapper will timeout, as just happened.  Most likely the main class
ADVICE | wrapper  | 2012/11/27 23:26:41 | specified in the Wrapper configuration file is not correctly initializing
ADVICE | wrapper  | 2012/11/27 23:26:41 | the Wrapper classes:
ADVICE | wrapper  | 2012/11/27 23:26:41 |     Main
ADVICE | wrapper  | 2012/11/27 23:26:41 | While it is possible to do so manually, the Wrapper ships with helper
ADVICE | wrapper  | 2012/11/27 23:26:41 | classes to make this initialization processes automatic.
ADVICE | wrapper  | 2012/11/27 23:26:41 | Please review the integration section of the Wrapper's documentation
ADVICE | wrapper  | 2012/11/27 23:26:41 | for the various methods which can be employed to launch an application
ADVICE | wrapper  | 2012/11/27 23:26:41 | within the Wrapper:
ADVICE | wrapper  | 2012/11/27 23:26:41 |     http://wrapper.tanukisoftware.com/doc/english/integrate.html
ADVICE | wrapper  | 2012/11/27 23:26:41 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:26:41 | 
ERROR  | wrapper  | 2012/11/27 23:26:42 | JVM did not exit on request, terminated
STATUS | wrapper  | 2012/11/27 23:26:47 | Launching a JVM...
ERROR  | wrapper  | 2012/11/27 23:27:16 | Startup failed: Timed out waiting for a signal from the JVM.
ADVICE | wrapper  | 2012/11/27 23:27:16 | 
ADVICE | wrapper  | 2012/11/27 23:27:16 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:27:16 | Advice:
ADVICE | wrapper  | 2012/11/27 23:27:16 | The Wrapper consists of a native component as well as a set of classes
ADVICE | wrapper  | 2012/11/27 23:27:16 | which run within the JVM that it launches.  The Java component of the
ADVICE | wrapper  | 2012/11/27 23:27:16 | Wrapper must be initialized promptly after the JVM is launched or the
ADVICE | wrapper  | 2012/11/27 23:27:16 | Wrapper will timeout, as just happened.  Most likely the main class
ADVICE | wrapper  | 2012/11/27 23:27:16 | specified in the Wrapper configuration file is not correctly initializing
ADVICE | wrapper  | 2012/11/27 23:27:16 | the Wrapper classes:
ADVICE | wrapper  | 2012/11/27 23:27:16 |     Main
ADVICE | wrapper  | 2012/11/27 23:27:16 | While it is possible to do so manually, the Wrapper ships with helper
ADVICE | wrapper  | 2012/11/27 23:27:16 | classes to make this initialization processes automatic.
ADVICE | wrapper  | 2012/11/27 23:27:16 | Please review the integration section of the Wrapper's documentation
ADVICE | wrapper  | 2012/11/27 23:27:16 | for the various methods which can be employed to launch an application
ADVICE | wrapper  | 2012/11/27 23:27:16 | within the Wrapper:
ADVICE | wrapper  | 2012/11/27 23:27:16 |     http://wrapper.tanukisoftware.com/doc/english/integrate.html
ADVICE | wrapper  | 2012/11/27 23:27:16 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:27:16 | 
ERROR  | wrapper  | 2012/11/27 23:27:16 | JVM did not exit on request, terminated
STATUS | wrapper  | 2012/11/27 23:27:21 | Launching a JVM...
ERROR  | wrapper  | 2012/11/27 23:27:50 | Startup failed: Timed out waiting for a signal from the JVM.
ADVICE | wrapper  | 2012/11/27 23:27:50 | 
ADVICE | wrapper  | 2012/11/27 23:27:50 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:27:50 | Advice:
ADVICE | wrapper  | 2012/11/27 23:27:50 | The Wrapper consists of a native component as well as a set of classes
ADVICE | wrapper  | 2012/11/27 23:27:50 | which run within the JVM that it launches.  The Java component of the
ADVICE | wrapper  | 2012/11/27 23:27:50 | Wrapper must be initialized promptly after the JVM is launched or the
ADVICE | wrapper  | 2012/11/27 23:27:50 | Wrapper will timeout, as just happened.  Most likely the main class
ADVICE | wrapper  | 2012/11/27 23:27:50 | specified in the Wrapper configuration file is not correctly initializing
ADVICE | wrapper  | 2012/11/27 23:27:50 | the Wrapper classes:
ADVICE | wrapper  | 2012/11/27 23:27:50 |     Main
ADVICE | wrapper  | 2012/11/27 23:27:50 | While it is possible to do so manually, the Wrapper ships with helper
ADVICE | wrapper  | 2012/11/27 23:27:50 | classes to make this initialization processes automatic.
ADVICE | wrapper  | 2012/11/27 23:27:50 | Please review the integration section of the Wrapper's documentation
ADVICE | wrapper  | 2012/11/27 23:27:50 | for the various methods which can be employed to launch an application
ADVICE | wrapper  | 2012/11/27 23:27:50 | within the Wrapper:
ADVICE | wrapper  | 2012/11/27 23:27:50 |     http://wrapper.tanukisoftware.com/doc/english/integrate.html
ADVICE | wrapper  | 2012/11/27 23:27:50 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:27:50 | 
ERROR  | wrapper  | 2012/11/27 23:27:51 | JVM did not exit on request, terminated
STATUS | wrapper  | 2012/11/27 23:27:56 | Launching a JVM...
ERROR  | wrapper  | 2012/11/27 23:28:25 | Startup failed: Timed out waiting for a signal from the JVM.
ADVICE | wrapper  | 2012/11/27 23:28:25 | 
ADVICE | wrapper  | 2012/11/27 23:28:25 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:28:25 | Advice:
ADVICE | wrapper  | 2012/11/27 23:28:25 | The Wrapper consists of a native component as well as a set of classes
ADVICE | wrapper  | 2012/11/27 23:28:25 | which run within the JVM that it launches.  The Java component of the
ADVICE | wrapper  | 2012/11/27 23:28:25 | Wrapper must be initialized promptly after the JVM is launched or the
ADVICE | wrapper  | 2012/11/27 23:28:25 | Wrapper will timeout, as just happened.  Most likely the main class
ADVICE | wrapper  | 2012/11/27 23:28:25 | specified in the Wrapper configuration file is not correctly initializing
ADVICE | wrapper  | 2012/11/27 23:28:25 | the Wrapper classes:
ADVICE | wrapper  | 2012/11/27 23:28:25 |     Main
ADVICE | wrapper  | 2012/11/27 23:28:25 | While it is possible to do so manually, the Wrapper ships with helper
ADVICE | wrapper  | 2012/11/27 23:28:25 | classes to make this initialization processes automatic.
ADVICE | wrapper  | 2012/11/27 23:28:25 | Please review the integration section of the Wrapper's documentation
ADVICE | wrapper  | 2012/11/27 23:28:25 | for the various methods which can be employed to launch an application
ADVICE | wrapper  | 2012/11/27 23:28:25 | within the Wrapper:
ADVICE | wrapper  | 2012/11/27 23:28:25 |     http://wrapper.tanukisoftware.com/doc/english/integrate.html
ADVICE | wrapper  | 2012/11/27 23:28:25 | ------------------------------------------------------------------------
ADVICE | wrapper  | 2012/11/27 23:28:25 | 
ERROR  | wrapper  | 2012/11/27 23:28:25 | JVM did not exit on request, terminated
FATAL  | wrapper  | 2012/11/27 23:28:26 | There were 5 failed launches in a row, each lasting less than 300 seconds.  Giving up.
FATAL  | wrapper  | 2012/11/27 23:28:26 |   There may be a configuration problem: please check the logs.
STATUS | wrapper  | 2012/11/27 23:28:26 | <-- Wrapper Stopped
B

Shakall:
E ae amigo, consegui configurar o Wrapper, mas estou com um problema, ao iniciar o serviço ele fica no status de Iniciando e não sai disso, minha aplicação está funcionando de boa, depois de algum tempo no log da o seguinte erro e minha aplicação para de funcionar. Tem idéia do que seja?

Nunca utilizei o Java Service Wrapper com Windows Server 2008, com o 2003 sei que funciona bem, na documentação diz que o 2008 é suportado.

O que ocorre é que o Windows espera que a aplicação o sinalize que a aplicação está no ar. Se isto não ocorrer o Windows derruba a aplicação.

Você deve implementar uma classe que implemente WrapperListener, ou pode utilizar uma já implementada: WrapperSimpleApp.

Veja na documentação as várias formas de integra-lo com sua aplicação. http://wrapper.tanukisoftware.com/doc/english/integrate.html

S

Valeu pela força, resolvi o problema usando yajsw agora ta rodando o service tanto no 2003 quanto no 2008 e sem necessidade de alteração no jar.

E

Shakall:

Problema que Wrapper não fuciona em Server 2008. Queria uma solução para ambos 2003 e 2008

O Windows Server 2008 “trava” um pouco a configuração do %TEMP%. A solução mais simples é configurar tmpdir:
http://wrapper.tanukisoftware.com/doc/english/prop-java-tmpdir-x.html

Criado 27 de novembro de 2012
Ultima resposta 15 de jan. de 2013
Respostas 6
Participantes 3