i try to use the appassembler-maven-plugin to ease the use of the Java-Service-Wrapper
My Setup is as follows:
MyServiceWrapper:
package aaa.bbb.ccc;
import org.tanukisoftware.wrapper.WrapperListener;
import org.tanukisoftware.wrapper.WrapperManager;
public class MyServiceWrapper implements WrapperListener {
@Override
public void controlEvent(int arg0) {
}
@Override
public Integer start(String[] arg0) {
return null;
}
@Override
public int stop(int exitCode) {
return exitCode;
}
public static void main(String[] args) {
WrapperManager.start(new MyServiceWrapper(), args);
}
}
appassembler-maven-plugin in my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>generate-jsw-scripts</id>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
</goals>
<configuration>
<!--declare the JSW config -->
<daemons>
<daemon>
<id>MyServiceWrapper</id>
<mainClass>aaa.bbb.ccc.MyServiceWrapper</mainClass>
<platforms>
<platform>jsw</platform>
</platforms>
</daemon>
</daemons>
<target>${project.build.directory}/appassembler</target>
</configuration>
</execution>
</executions>
</plugin>
This generates the wrapper.conf and a lot of other files! But there is one line which is wrong and i don't know how to generate it correctly.
The wrong line is:
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
and it should be:
wrapper.java.mainclass=aaa.bbb.ccc.MyServiceWrapper
If i manually set this line to the correct mentioned line it works!
So: is there any way to generate this line correctly?
PS: Is it possible to set the log-level of the JSW from inside the pom.xml?
appassembler is by default using integration method #1, where the (i.e. your) 'main class' is actually the first parameter to the WrapperSimpleApp class. That's why your mainclass is getting mapped to wrapper.app.parameter.1, and not wrapper.java.mainclass...
In most cases you don't need to generate your own implementation of WrapperListener interface and sticking to integration method#1 will be working most of the time....
If you really want to use integration method#3, i.e. provide your own WrapperListener implementation, you have to add the following into your pom.xml:
<property>
<name>wrapper.java.mainclass</name>
<value>my.WrapperListenerImpl</value>
</property>
<property>
<name>wrapper.logfile.loglevel</name>
<value>DEBUG</value>
</property>
Full example can be found >here<
This will add or overwrite existing configuration properties... you can use that also for the loglevel ;)