Java Service Wrapper Executable Runnable Jar - java

WrapperAppJar
I am wrapping an executable runnable jar file as a window service. Based upon the tutorial on Tanuki software site I export my app from eclipse as an executable jar file and tried wrappig it into a windows service. My app runs smoothly from the CLI when I execute java -jar smpp-portal -port 90. However with the Wrapper service I am getting some errors.
This is my configuration file
#encoding=UTF-8
# Configuration files must begin with a line specifying the encoding
# of the the file.
#********************************************************************
# Wrapper License Properties (Ignored by Community Edition)
#********************************************************************
# Professional and Standard Editions of the Wrapper require a valid
# License Key to start. Licenses can be purchased or a trial license
# requested on the following pages:
# http://wrapper.tanukisoftware.com/purchase
# http://wrapper.tanukisoftware.com/trial
# Include file problems can be debugged by removing the first '#'
# from the following line:
##include.debug
# The Wrapper will look for either of the following optional files for a
# valid License Key. License Key properties can optionally be included
# directly in this configuration file.
#include ../conf/wrapper-license.conf
#include ../conf/wrapper-license-%WRAPPER_HOST_NAME%.conf
# The following property will output information about which License Key(s)
# are being found, and can aid in resolving any licensing problems.
#wrapper.license.debug=TRUE
#********************************************************************
# Wrapper Localization
#********************************************************************
# Specify the locale which the Wrapper should use. By default the system
# locale is used.
wrapper.lang=en_US # en_US or ja_JP
# Specify the location of the Wrapper's language resources. If these are
# missing, the Wrapper will default to the en_US locale.
#wrapper.lang.folder=../lang
#********************************************************************
# 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
# 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=org.tanukisoftware.wrapper.WrapperJarApp
# 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=../lib/wrapper.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=../lib/smpp-portal.jar
wrapper.app.parameter.2=-port
#********************************************************************
# Wrapper Logging Properties
#********************************************************************
# Enables Debug output from the Wrapper.
# wrapper.debug=TRUE
# Format of output for the console. (See docs for formats)
wrapper.console.format=PM
# Log Level for console output. (See docs for log levels)
wrapper.console.loglevel=INFO
# Log file to use for wrapper output logging.
wrapper.logfile=../logs/wrapper.log
# Format of output for the log file. (See docs for formats)
wrapper.logfile.format=LPTM
# Log Level for log file output. (See docs for log levels)
wrapper.logfile.loglevel=INFO
# Maximum size that the log file will be allowed to grow to before
# the log is rolled. Size is specified in bytes. The default value
# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
# 'm' (mb) suffix. For example: 10m = 10 megabytes.
wrapper.logfile.maxsize=0
# Maximum number of rolled log files which will be allowed before old
# files are deleted. The default value of 0 implies no limit.
wrapper.logfile.maxfiles=0
# Log Level for sys/event log output. (See docs for log levels)
wrapper.syslog.loglevel=NONE
#********************************************************************
# Wrapper General Properties
#********************************************************************
# Allow for the use of non-contiguous numbered properties
wrapper.ignore_sequence_gaps=TRUE
# Do not start if the pid file already exists.
wrapper.pidfile.strict=TRUE
# Title to use when running as a console
wrapper.console.title=Unity SMPP Server
#********************************************************************
# Wrapper JVM Checks
#********************************************************************
# Detect DeadLocked Threads in the JVM. (Requires Standard Edition)
wrapper.check.deadlock=TRUE
wrapper.check.deadlock.interval=10
wrapper.check.deadlock.action=RESTART
wrapper.check.deadlock.output=FULL
# Out Of Memory detection.
# (Ignore output from dumping the configuration to the console. This is only needed by the TestWrapper sample application.)
wrapper.filter.trigger.999=wrapper.filter.trigger.*java.lang.OutOfMemoryError
wrapper.filter.allow_wildcards.999=TRUE
wrapper.filter.action.999=NONE
# Ignore -verbose:class output to avoid false positives.
wrapper.filter.trigger.1000=[Loaded java.lang.OutOfMemoryError
wrapper.filter.action.1000=NONE
# (Simple match)
wrapper.filter.trigger.1001=java.lang.OutOfMemoryError
# (Only match text in stack traces if -XX:+PrintClassHistogram is being used.)
#wrapper.filter.trigger.1001=Exception in thread "*" java.lang.OutOfMemoryError
#wrapper.filter.allow_wildcards.1001=TRUE
wrapper.filter.action.1001=RESTART
wrapper.filter.message.1001=The JVM has run out of memory.
#********************************************************************
# Wrapper Email Notifications. (Requires Professional Edition)
#********************************************************************
# Common Event Email settings.
#wrapper.event.default.email.debug=TRUE
#wrapper.event.default.email.smtp.host=<SMTP_Host>
#wrapper.event.default.email.smtp.port=25
#wrapper.event.default.email.subject=[%WRAPPER_HOSTNAME%:%WRAPPER_NAME%:%WRAPPER_EVENT_NAME%] Event Notification
#wrapper.event.default.email.sender=<Sender email>
#wrapper.event.default.email.recipient=<Recipient email>
# Configure the log attached to event emails.
#wrapper.event.default.email.attach_log=TRUE
#wrapper.event.default.email.maillog.lines=50
#wrapper.event.default.email.maillog.format=LPTM
#wrapper.event.default.email.maillog.loglevel=INFO
# Enable specific event emails.
#wrapper.event.wrapper_start.email=TRUE
#wrapper.event.jvm_prelaunch.email=TRUE
#wrapper.event.jvm_start.email=TRUE
#wrapper.event.jvm_started.email=TRUE
#wrapper.event.jvm_deadlock.email=TRUE
#wrapper.event.jvm_stop.email=TRUE
#wrapper.event.jvm_stopped.email=TRUE
#wrapper.event.jvm_restart.email=TRUE
#wrapper.event.jvm_failed_invocation.email=TRUE
#wrapper.event.jvm_max_failed_invocations.email=TRUE
#wrapper.event.jvm_kill.email=TRUE
#wrapper.event.jvm_killed.email=TRUE
#wrapper.event.jvm_unexpected_exit.email=TRUE
#wrapper.event.wrapper_stop.email=TRUE
# Specify custom mail content
wrapper.event.jvm_restart.email.body=The JVM was restarted.\n\nPlease check on its status.\n
#********************************************************************
# Wrapper Windows NT/2000/XP Service Properties
#********************************************************************
# WARNING - Do not modify any of these properties when an application
# using this configuration file has been installed as a service.
# Please uninstall the service before modifying this section. The
# service can then be reinstalled.
# Name of the service
wrapper.name=SmppServer
# Display name of the service
wrapper.displayname=Unity SMPP Server
# Description of the service
wrapper.description=Unity SMPP Server
# Service dependencies. Add dependencies as needed starting from 1
wrapper.ntservice.dependency.1=
# Mode in which the service is installed. AUTO_START, DELAY_START or DEMAND_START
wrapper.ntservice.starttype=AUTO_START
# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=false
However I got the following error message:
wrapper | --> Wrapper Started as Console
wrapper | Java Service Wrapper Professional Edition 64-bit 3.5.17
wrapper | Copyright (C) 1999-2012 Tanuki Software, Ltd. All Rights Reserved.
wrapper | http://wrapper.tanukisoftware.com
wrapper |
wrapper | --------------------------------------------------------------------
wrapper | Thank you for your interest in the Java Service Wrapper.
wrapper |
wrapper | You are running with a full featured trial License Key which will
wrapper | allow you to run or restart the Java Service Wrapper as many times
wrapper | as you like. Each invocation of the Wrapper will shutdown
wrapper | automatically after 15 minutes.
wrapper |
wrapper | This limited trial License Key is useful for quick configuration
wrapper | tests on various machines without the need to request a trial
wrapper | license. If more time is required, you can also immediately obtain
wrapper | a one-month Free trial license:
wrapper | http://wrapper.tanukisoftware.com/trial
wrapper |
wrapper | The Java Service Wrapper requires a License Key to activate the
wrapper | software. License Keys can be purchased on the Java Service Wrapper
wrapper | web site:
wrapper | http://wrapper.tanukisoftware.com/purchase
wrapper |
wrapper | This trial License Key in intended for testing and development and
wrapper | should not be used as part of a production environment.
wrapper | --------------------------------------------------------------------
wrapper |
wrapper |
wrapper | Launching a JVM...
wrapper | Command: "C:\Windows\system32\java.exe" -Dfile.encoding=Cp1252 -Duser.language=en -Djava.library.path="../lib" -classpath "../lib/wrapper.jar" -Dwrapper.key="KEggEM-am9F0iQdg0DR2yCJvAaJoF1WU" -Dwrapper.port=32000 -Dwrapper.jvm.port.
min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=7856 -Dwrapper.version="3.5.17-pro" -Dwrapper.native_library="wrapper" -Dwrapper.arch="x86" -Dwrapper.cpu.timeout="10" -Dwrapper.jvmid=1 -Dwrapper.lang.domain=wrapper -Dwrapper.lang.folder=.
./lang org.tanukisoftware.wrapper.WrapperJarApp ../lib/smpp-portal.jar -port
jvm 1 | WrapperManager: Initializing...
jvm 1 | Missing attributes for JarRsrcLoader in Manifest (Rsrc-Main-Class, Rsrc-Class-Path)
jvm 1 | WrapperJarApp:
jvm 1 | WrapperJarApp Error: Encountered an error running main:
jvm 1 | WrapperJarApp Error: java.lang.NullPointerException
jvm 1 | WrapperJarApp Error: at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:46)
jvm 1 | WrapperJarApp Error: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jvm 1 | WrapperJarApp Error: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
jvm 1 | WrapperJarApp Error: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
jvm 1 | WrapperJarApp Error: at java.lang.reflect.Method.invoke(Unknown Source)
jvm 1 | WrapperJarApp Error: at org.tanukisoftware.wrapper.WrapperJarApp.run(WrapperJarApp.java:394)
jvm 1 | WrapperJarApp Error: at java.lang.Thread.run(Unknown Source)
wrapper | <-- Wrapper Stopped
Press any key to continue . . .
Can someone help me?
Thank you in advance

unhillbilly has a good point. But actually it's not the real reason for the error you are seeing.
Basically the manifest file in your jar file appears incorrect.
When you created the jar file, you were probably exporting your project from eclipse as runnable jar and selected as library handling to package the required jar files into the generated jar...
So by doing this Eclipse is using the class JarRsrcLoader.
This class is in fact the main class of your executable jar and not as you might thought your main class.
JarRsrcLoader requires 2 parameters being set in the manifest file: Rsrc-Main-Class and Rsrc-Class-Path.
Rsrc-Main-Class is the class name of your actual main class.
Rsrc-Class-Path is the class path (with all included jar files in the jar file) to launch your application.
Your manifest file appears to miss those 2 properties.
So you can resolve this by changing the way how you are exporting the jar file, for instance use "extract required libraries in jar".
Another option would be to add the 2 missing properties into your META-INF/manifest.mf file.

Is a value missing for the port option? You say that your jar is run as:
java -jar smpp-portal -port 90
However, the wrapper config doesn't seem to have the port number as an application parameter:
# Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=../lib/smpp-portal.jar
wrapper.app.parameter.2=-port

You can use other executable wrapper
Launch4J - Download
JSmooth - Download
Other options are also available :)

Related

ActiveMQ data and conf folder needs to be changed to different file system in Linux

I have downloaded and setup ActiveMQ 5.15.0 in my machine and followed this guide.
In conf folder I see in conf/log4j.properties there is a line with the path for Log Location.
log4j.appender.logfile.file=${activemq.data}/activemq.log
How this variable ${activemq.data} is configured and how to change it?
The value for ${activemq.data} is read from the environment variable $ACTIVEMQ_DATA by the activemq script when starting the broker. For example, when you start the broker using the default configuration you'll see this logged:
$ ./activemq console
...
ACTIVEMQ_HOME: /home/jbertram/java/apache-activemq-5.15.8
ACTIVEMQ_BASE: /home/jbertram/java/apache-activemq-5.15.8
ACTIVEMQ_CONF: /home/jbertram/java/apache-activemq-5.15.8/conf
ACTIVEMQ_DATA: /home/jbertram/java/apache-activemq-5.15.8/data
Loading message broker from: xbean:activemq.xml
...
However, if you set the $ACTIVEMQ_DATA variable to something else, e.g.:
$ export ACTIVEMQ_DATA=/tmp
Then this will be logged:
$ ./activemq console
...
ACTIVEMQ_HOME: /home/jbertram/java/apache-activemq-5.15.8
ACTIVEMQ_BASE: /home/jbertram/java/apache-activemq-5.15.8
ACTIVEMQ_CONF: /home/jbertram/java/apache-activemq-5.15.8/conf
ACTIVEMQ_DATA: /tmp
Loading message broker from: xbean:activemq.xml
...
You can also change this using the bin/env file. This is what the default env contains:
...
# Active MQ installation dirs
# ACTIVEMQ_HOME="<Installationdir>/"
# ACTIVEMQ_BASE="$ACTIVEMQ_HOME"
# ACTIVEMQ_CONF="$ACTIVEMQ_BASE/conf"
# ACTIVEMQ_DATA="$ACTIVEMQ_BASE/data"
# ACTIVEMQ_TMP="$ACTIVEMQ_BASE/tmp"
...
You could change this to be something like this:
...
# Active MQ installation dirs
# ACTIVEMQ_HOME="<Installationdir>/"
# ACTIVEMQ_BASE="$ACTIVEMQ_HOME"
# ACTIVEMQ_CONF="$ACTIVEMQ_BASE/conf"
ACTIVEMQ_DATA="/tmp"
# ACTIVEMQ_TMP="$ACTIVEMQ_BASE/tmp"
...
It's worth noting that ActiveMQ "Classic" 5.15.0 was released in June of 2017 (i.e. over 5 years ago now). I strongly recommend you upgrade to a more recent release, ideally the latest.

Not running with JRE 8

I have this huge legacy code that is built upon Java and C that uses JNI calls etc. It is working fine with JRE 7. I am getting following exception while running on JRE 8.
#INVENTORYTUNER: Finished setting trusted transmitters, added: vw-pun-mar-dv07
#java.lang.NoClassDefFoundError: sun/io/CharToByteConverter
# at com.marimba.tools.util.ByteBuffer.setEncoding(ByteBuffer.java:109)
# at com.marimba.tools.util.ByteBuffer.<init>(ByteBuffer.java:97)
# at com.marimba.tools.logs.LogEntry.<init>(LogEntry.java:21)
# at com.marimba.tools.logs.GenericLog.logData(GenericLog.java:91)
# at com.marimba.tools.logs.GenericLog.log(GenericLog.java:84)
# at com.marimba.tools.logs.LogDispatcher.log(LogDispatcher.java:267)
# at com.marimba.castanet.tuner.Workspace.log(Workspace.java:1112)
# at com.marimba.castanet.tuner.Workspace.log(Workspace.java:1031)
# at com.marimba.castanet.tuner.Workspace.log(Workspace.java:1024)
# at com.marimba.castanet.tuner.Channel.<init>(Channel.java:180)
# at com.marimba.castanet.tuner.Workspace.getChannelCreate(Workspace.java:701)
# at com.marimba.castanet.tuner.Workspace.getChannelCreate(Workspace.java:684)
# at com.marimba.castanet.launch.Launcher$Create.run(Launcher.java:399)
# at com.marimba.tools.util.ThreadPool.runClient(ThreadPool.java:374)
# at com.marimba.tools.util.ThreadPool.run(ThreadPool.java:360)
# at java.lang.Thread.run(Unknown Source)
Internally, we are using this zip to support deprecated methods. How to proceed this ?
Is marbima something you are using as a third party lib or something that you are working on?
As folks in the comments mentioned the CharToByteConverter has been replaced by java.nio.charset
See Java Class chartobyteconverter Type deprecated
If you are using marbima as a third party lib, contact the devs to see if it is certified for JDK 1.8, if you develop it, you need to modify it to remove the deprecated classes.

neo4j keeps giving erros and is not running,can you help me with its errors?

I downloaded neo4j.zip from its site and extract it.
I downloaded and installed jdk 7, I have two folders in :
C:\Program Files\Java\jdk1.7.0_75
and
C:\Program Files\Java\jre7
And I clicked on New and made a variable named JAVA_HOME and its value is
C:\Program Files\Java\jdk1.7.0_75
I have added
org.neo4j.server.startup_timeout=0
line to my neo4j-server.properties file because of timeout error and
I have changed the port number in neo4j-server.properties file from 7474 to 80 and 8085, this is my neo4j-server.properties now:
################################################################
# Neo4j
#
# neo4j-server.properties - runtime operational settings
#
################################################################
#***************************************************************
# Server configuration
#***************************************************************
# location of the database directory
org.neo4j.server.database.location=data/graph.db
# Low-level graph engine tuning file
org.neo4j.server.db.tuning.properties=conf/neo4j.properties
# Database mode
# Allowed values:
# HA - High Availability
# SINGLE - Single mode, default.
# To run in High Availability mode, configure the neo4j.properties config file, then uncomment this line:
#org.neo4j.server.database.mode=HA
# Let the webserver only listen on the specified IP. Default is localhost (only
# accept local connections). Uncomment to allow any connection. Please see the
# security section in the neo4j manual before modifying this.
#org.neo4j.server.webserver.address=0.0.0.0
# Require (or disable the requirement of) auth to access Neo4j
dbms.security.auth_enabled=true
#
# HTTP Connector
#
# http port (for all data, administrative, and UI access)
org.neo4j.server.webserver.port=8085
#
# HTTPS Connector
#
# Turn https-support on/off
org.neo4j.server.webserver.https.enabled=true
# https port (for all data, administrative, and UI access)
org.neo4j.server.webserver.https.port=7473
# Certificate location (auto generated if the file does not exist)
org.neo4j.server.webserver.https.cert.location=conf/ssl/snakeoil.cert
# Private key location (auto generated if the file does not exist)
org.neo4j.server.webserver.https.key.location=conf/ssl/snakeoil.key
# Internally generated keystore (don't try to put your own
# keystore there, it will get deleted when the server starts)
org.neo4j.server.webserver.https.keystore.location=data/keystore
# Comma separated list of JAX-RS packages containing JAX-RS resources, one
# package name for each mountpoint. The listed package names will be loaded
# under the mountpoints specified. Uncomment this line to mount the
# org.neo4j.examples.server.unmanaged.HelloWorldResource.java from
# neo4j-server-examples under /examples/unmanaged, resulting in a final URL of
# http://localhost:7474/examples/unmanaged/helloworld/{nodeId}
#org.neo4j.server.thirdparty_jaxrs_classes=org.neo4j.examples.server.unmanaged=/examples/unmanaged
#*****************************************************************
# HTTP logging configuration
#*****************************************************************
# HTTP logging is disabled. HTTP logging can be enabled by setting this
# property to 'true'.
org.neo4j.server.http.log.enabled=false
# Logging policy file that governs how HTTP log output is presented and
# archived. Note: changing the rollover and retention policy is sensible, but
# changing the output format is less so, since it is configured to use the
# ubiquitous common log format
org.neo4j.server.http.log.config=conf/neo4j-http-logging.xml
#*****************************************************************
# Administration client configuration
#*****************************************************************
# location of the servers round-robin database directory. possible values:
# - absolute path like /var/rrd
# - path relative to the server working directory like data/rrd
# - commented out, will default to the database data directory.
org.neo4j.server.webadmin.rrdb.location=data/rrd
org.neo4j.server.startup_timeout=0
but again when I run Neo4j.bat by double clicking on it, cmd window will open and java window will open and will close after some seconds and cmd window will close after it and
http://localhost:8085/browser/
is unavailable.
This is my error from
C:\Users\Fereshteh\Desktop\neo4j-enterprise-2.2.0-windows\neo4j-enterprise-2.2.0\data\graph.db\messages
2015-04-10 01:56:42.689+0000 ERROR [o.n.s.e.EnterpriseBootstrapper]: Failed to start Neo Server on port [8085]
org.neo4j.server.ServerStartupException: Starting Neo4j Server failed: Wanted record LOG_VERSION, but this record wasn't read since the neostore didn't contain it
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:255) ~[neo4j-server-2.2.0.jar:2.2.0]
at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:117) [neo4j-server-2.2.0.jar:2.2.0]
at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:69) [neo4j-server-2.2.0.jar:2.2.0]
Caused by: java.lang.IllegalStateException: Wanted record LOG_VERSION, but this record wasn't read since the neostore didn't contain it
at org.neo4j.kernel.impl.store.record.NeoStoreUtil.getValue(NeoStoreUtil.java:127) ~[neo4j-kernel-2.2.0.jar:2.2.0]
at org.neo4j.kernel.impl.store.record.NeoStoreUtil.getLogVersion(NeoStoreUtil.java:150) ~[neo4j-kernel-2.2.0.jar:2.2.0]
at org.neo4j.kernel.impl.recovery.StoreRecoverer.recoveryNeededAt(StoreRecoverer.java:57) ~[neo4j-kernel-2.2.0.jar:2.2.0]
at org.neo4j.server.preflight.PerformRecoveryIfNecessary.run(PerformRecoveryIfNecessary.java:62) ~[neo4j-server-2.2.0.jar:2.2.0]
at org.neo4j.server.preflight.PreFlightTasks.run(PreFlightTasks.java:71) ~[neo4j-server-2.2.0.jar:2.2.0]
at org.neo4j.server.AbstractNeoServer.runPreflightTasks(AbstractNeoServer.java:387) ~[neo4j-server-2.2.0.jar:2.2.0]
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:195) ~[neo4j-server-2.2.0.jar:2.2.0]
And in my C:\Users\Fereshteh\Desktop\neo4j-enterprise-2.2.0-windows\neo4j-enterprise-2.2.0\data\log
I have just README and windows-wrapper.0.0.txt and windows-wrapper.0.0.log.lck
what should I do to be able to run Neo4j and work with it?
I have windows 7 x86
thanks in advance.
I had the same error today. In my case, it was because the files in the database directory were corrupted (I unzipped an existing graph which failed on first try). After I unzipped the existing graph database correctly - and the database files were fine - it worked. So, maybe your database directory is also corrupted.
Move the neo4j folder to another directory -> \Program'thisblankisbad'Files\ <- was the cause for me. I was trying to reinstall the service on Windows with
neo4j install-service
and neo4j threw:
neo4j Error: mainclass org.neo4j.server.startup.Neo4jCommand could not be found or loaded cause: java.lang.ClassNotFoundException: org.neo4j.server.startup.Neo4jCommand
after i moved the neo4j folder to another directory (NO BLANKS!!!) it was fine
windows 10, neo4j v4.4.9

WrapperManager cannot be resolved error: Java Service Wrapper

I am trying to implement the example given here: http://benjsicam.me/blog/running-a-java-application-as-a-windows-service-part-1-tutorial/
The code basically turns a Java application into a service. The application outputs Date and Time to the console at specific intervals. The whole project gets exported to a runnable JAR file, with required libraries in a separate folder. All I have to do is modify the wrapper.conf file to run Main.jar (which is the exported JAR) and put the exported libraries in the lib folder.
I have followed everything exactly, but I am getting the following problem: WrapperManager cannot be resolved. I am including the links for snapshots which show the Maven project structure, the contents of POM.xml, and code contents of four Java files. Also included are the required source files in Google Drive.
Java version jdk1.8.0_11
Main.java
Google Drive Link
Error Shown:
Wrapper.conf file (removed most of the comments+top part)
wrapper.java.mainclass=batch_Proc.main_prog.Main
# 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=../lib/aopalliance-1.0.jar
wrapper.java.classpath.3=../lib/commons-logging-1.1.1.jar
wrapper.java.classpath.4=../lib/spring-aop-3.2.1.RELEASE.jar
wrapper.java.classpath.5=../lib/spring-beans-3.2.1.RELEASE.jar
wrapper.java.classpath.6=../lib/spring-context-3.2.1.RELEASE.jar
wrapper.java.classpath.7=../lib/spring-context-support-3.2.1.RELEASE.jar
wrapper.java.classpath.8=../lib/spring-core-3.2.1.RELEASE.jar
wrapper.java.classpath.9=../lib/spring-expression-3.2.1.RELEASE.jar
wrapper.java.classpath.10=../lib/spring-web-3.2.1.RELEASE.jar
wrapper.java.classpath.11=../lib/wrappertest.jar
wrapper.java.classpath.12=Main.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=FALSE
# 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=
#********************************************************************
# Wrapper Logging Properties
#********************************************************************
# Enables Debug output from the Wrapper.
wrapper.debug=FALSE
# Format of output for the console. (See docs for formats)
wrapper.console.format=PM
# Log Level for console output. (See docs for log levels)
wrapper.console.loglevel=INFO
# Log file to use for wrapper output logging.
wrapper.logfile=../logs/wrapper.log
# Format of output for the log file. (See docs for formats)
wrapper.logfile.format=LPTM
# Log Level for log file output. (See docs for log levels)
wrapper.logfile.loglevel=INFO
# Maximum size that the log file will be allowed to grow to before
# the log is rolled. Size is specified in bytes. The default value
# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
# 'm' (mb) suffix. For example: 10m = 10 megabytes.
wrapper.logfile.maxsize=0
# Maximum number of rolled log files which will be allowed before old
# files are deleted. The default value of 0 implies no limit.
wrapper.logfile.maxfiles=0
# Log Level for sys/event log output. (See docs for log levels)
wrapper.syslog.loglevel=NONE
#********************************************************************
# Wrapper General Properties
#********************************************************************
# Allow for the use of non-contiguous numbered properties
wrapper.ignore_sequence_gaps=TRUE
# Do not start if the pid file already exists.
wrapper.pidfile.strict=TRUE
# Title to use when running as a console
wrapper.console.title=Test Wrapper Sample Application
#********************************************************************
# Wrapper JVM Checks
#********************************************************************
# Detect DeadLocked Threads in the JVM. (Requires Standard Edition)
wrapper.check.deadlock=TRUE
wrapper.check.deadlock.interval=10
wrapper.check.deadlock.action=RESTART
wrapper.check.deadlock.output=FULL
# Out Of Memory detection.
# (Ignore output from dumping the configuration to the console. This is only needed by the TestWrapper sample application.)
wrapper.filter.trigger.999=wrapper.filter.trigger.*java.lang.OutOfMemoryError
wrapper.filter.allow_wildcards.999=TRUE
wrapper.filter.action.999=NONE
# Ignore -verbose:class output to avoid false positives.
wrapper.filter.trigger.1000=[Loaded java.lang.OutOfMemoryError
wrapper.filter.action.1000=NONE
# (Simple match)
wrapper.filter.trigger.1001=java.lang.OutOfMemoryError
# (Only match text in stack traces if -XX:+PrintClassHistogram is being used.)
#wrapper.filter.trigger.1001=Exception in thread "*" java.lang.OutOfMemoryError
#wrapper.filter.allow_wildcards.1001=TRUE
wrapper.filter.action.1001=RESTART
wrapper.filter.message.1001=The JVM has run out of memory.
#********************************************************************
# Wrapper Email Notifications. (Requires Professional Edition)
#********************************************************************
# Common Event Email settings.
#wrapper.event.default.email.debug=TRUE
#wrapper.event.default.email.smtp.host=<SMTP_Host>
#wrapper.event.default.email.smtp.port=25
#wrapper.event.default.email.subject=[%WRAPPER_HOSTNAME%:%WRAPPER_NAME%:%WRAPPER_EVENT_NAME%] Event Notification
#wrapper.event.default.email.sender=<Sender email>
#wrapper.event.default.email.recipient=<Recipient email>
# Configure the log attached to event emails.
#wrapper.event.default.email.attach_log=TRUE
#wrapper.event.default.email.maillog.lines=50
#wrapper.event.default.email.maillog.format=LPTM
#wrapper.event.default.email.maillog.loglevel=INFO
# Enable specific event emails.
#wrapper.event.wrapper_start.email=TRUE
#wrapper.event.jvm_prelaunch.email=TRUE
#wrapper.event.jvm_start.email=TRUE
#wrapper.event.jvm_started.email=TRUE
#wrapper.event.jvm_deadlock.email=TRUE
#wrapper.event.jvm_stop.email=TRUE
#wrapper.event.jvm_stopped.email=TRUE
#wrapper.event.jvm_restart.email=TRUE
#wrapper.event.jvm_failed_invocation.email=TRUE
#wrapper.event.jvm_max_failed_invocations.email=TRUE
#wrapper.event.jvm_kill.email=TRUE
#wrapper.event.jvm_killed.email=TRUE
#wrapper.event.jvm_unexpected_exit.email=TRUE
#wrapper.event.wrapper_stop.email=TRUE
# Specify custom mail content
wrapper.event.jvm_restart.email.body=The JVM was restarted.\n\nPlease check on its status.\n
# Name of the service
wrapper.name=JavaWindowsServiceSample
# Display name of the service
wrapper.displayname=Java Windows Service Sample
# Description of the service
wrapper.description=A sample java windows service application
# Service dependencies. Add dependencies as needed starting from 1
wrapper.ntservice.dependency.1=
# Mode in which the service is installed. AUTO_START, DELAY_START or DEMAND_START
wrapper.ntservice.starttype=AUTO_START
# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=false
I solved this problem! I had made a simple mistake of not making sure the correct dependencies were downloaded in Maven.
The required jars for WrapperManager and WrapperListener were not available which were causing the errors.

How do you make installer when the project is using many other dependencies in Java?

My main application is written in Java, which has Main.jar. I am preparing final package for deploy.
But it has other dependencies such as third party libraries need to be first available /pre-installed in Windows operating system, once that is installed my application can run, else it will show error and will not work. So i am struggling, end user has to do:
1) Thirdparty.library.msi (install manually) which is a GUI installer itself already
2) Then setup my Main.jar
3) Once it started it looks first for the third party libraries, if does not exist, software fails.
For such case, Is there any proper way to make one installer which can do the job as step 1 and then step 2, but both look like 1 installation?
Follow up: i also want my third party is not visible to the end user for presentation purpose. So i saw there is a tool exists called msi
1) Installer prepare for BATCH
Windows ® Installer. V 3.01.4000.1823
msiexec /Option <Required Parameter> [Optional Parameter]
Install Options
</package | /i> <Product.msi>
Installs or configures a product
/a <Product.msi>
Administrative install - Installs a product on the network
/j<u|m> <Product.msi> [/t <Transform List>] [/g <Language ID>]
Advertises a product - m to all users, u to current user
</uninstall | /x> <Product.msi | ProductCode>
Uninstalls the product
Display Options
/quiet
Quiet mode, no user interaction
/passive
Unattended mode - progress bar only
/q[n|b|r|f]
Sets user interface level
n - No UI
b - Basic UI
r - Reduced UI
f - Full UI (default)
/help
Help information
Restart Options
/norestart
Do not restart after the installation is complete
/promptrestart
Prompts the user for restart if necessary
/forcerestart
Always restart the computer after installation
Logging Options
/l[i|w|e|a|r|u|c|m|o|p|v|x|+|!|*] <LogFile>
i - Status messages
w - Nonfatal warnings
e - All error messages
a - Start up of actions
r - Action-specific records
u - User requests
c - Initial UI parameters
m - Out-of-memory or fatal exit information
o - Out-of-disk-space messages
p - Terminal properties
v - Verbose output
x - Extra debugging information
+ - Append to existing log file
! - Flush each line to the log
* - Log all information, except for v and x options
/log <LogFile>
Equivalent of /l* <LogFile>
Update Options
/update <Update1.msp>[;Update2.msp]
Applies update(s)
/uninstall <PatchCodeGuid>[;Update2.msp] /package <Product.msi | ProductCode>
Remove update(s) for a product
Repair Options
/f[p|e|c|m|s|o|d|a|u|v] <Product.msi | ProductCode>
Repairs a product
p - only if file is missing
o - if file is missing or an older version is installed (default)
e - if file is missing or an equal or older version is installed
d - if file is missing or a different version is installed
c - if file is missing or checksum does not match the calculated value
a - forces all files to be reinstalled
u - all required user-specific registry entries (default)
m - all required computer-specific registry entries (default)
s - all existing shortcuts (default)
v - runs from source and recaches local package
Setting Public Properties
[PROPERTY=PropertyValue]
OR
2) Practical/samples
# Install Silently [works]:
C:\windows\system32\msiexec.exe /I "C:\Documents and Settings\sun\My Documents\Downloads\10.70.msi" /QN
C:\windows\system32\msiexec.exe /I "C:\Documents and Settings\sun\My Documents\Downloads\10.71.msi" /QN
# For future reference [not tested]
start /wait msiexec /i O12Conv.msi /qb
start /wait msiexec /p O12Convsp1-en-us.msp /qb
start /wait msiexec /i mpsetupedp.msi
# other samples [not tested]
msiexec /package Application.msi /quiet
msiexec /uninstall Application.msi /quiet
msiexec /update msipatch.msp /quiet
msiexec /uninstall msipatch.msp /package Application.msi / quiet
All UI based installation tools have ability to run external programs and to run in batch mode that is controlled by command line arguments.
So, if your thirdparty.msi is what you have and have to use I's suggest you to find the ability to run it in a batch mode. Then create your own installation procedure that will invoke this 3rd party MSI.
There are various tools that for creating UI based installations programs (InstallShieled, InstallAnywhere etc).
How about creating a DOS batch script(.bat) and call the msi installer and JAR in that particular order from there?.
there is a way to check if the dependent app is installed [like an env variable being set]. If not then the packaging script can install it. I have done this in Install Shield; not sure about other tools.

Categories

Resources