I tried the webstart plugin in a prrof of concept involving an embedded tomcat server. The plugin is bound to the package phase and takes a longtime to execute, I would recommend to invoke it manually from the command line. It generates a zip file in the target directory containing the jnlp file and all dependencies. This file can then be extraced and put on a webserver. The url in the pom should point to this path on the server. When started, the app runs a tomcat server on localhost port 8080 with a simple servlet that just returns the requested path as a string.
Let me know if this works for you.
Here is the pom of the project, the plugin configuration was mostly copied from the documentation here
4.0.0
net.jhorstmann
EmbeddedTomcatWebstart
1.0-SNAPSHOT
jar
EmbeddedTomcatWebstart
http://localhost/jnlp/
Organisation
UTF-8
7.0.6
jboss
http://repository.jboss.org/nexus/content/groups/public/
sonatype
http://oss.sonatype.org/content/repositories/releases/
org.apache.maven.plugins
maven-compiler-plugin
2.3.2
1.5
1.5
org.apache.maven.plugins
maven-jar-plugin
2.3.1
net.jhorstmann.embeddedtomcat7.App
org.codehaus.mojo.webstart
webstart-maven-plugin
package
jnlp-inline
false
lib
true
app.jnlp
net.jhorstmann.embeddedtomcat7.App
${basedir}/keystore
password
password
EmbeddedTomcatWebstart
EmbeddedTomcatWebstart
Organisation Unit
Organisation
Location
State
Country
true
true
true
true
true
false
true
org.apache.tomcat
tomcat-catalina
${tomcat.version}
org.apache.tomcat
tomcat-coyote
${tomcat.version}
Here is a custom template for the jnlp file placed at src/main/jnlp/template.vm
, I can't remember why I needed that exactly:
$project.Name
$project.Organization.Name
$project.Description
#if($offlineAllowed)
#end
#if($allPermissions)
#end
$dependencies
This is the main class at src/main/java/net/jhorstmann/embeddedtomcat7/App.java
package net.jhorstmann.embeddedtomcat7;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
import org.apache.catalina.startup.Tomcat;
public class App {
public static void main(String[] args) throws LifecycleException, ServletException, IOException {
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File webappDir = new File(tmpDir, "embeddedtomcat7");
webappDir.mkdir();
final Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir(tmpDir.getAbsolutePath());
tomcat.getConnector().setURIEncoding("UTF-8");
String contextPath = "/";
Context context = tomcat.addContext(contextPath, webappDir.getAbsolutePath());
Wrapper wrapper = tomcat.addServlet(contextPath, "Test", new TestServlet());
//Wrapper wrapper = tomcat.addServlet(contextPath, "Async", new AsyncServlet());
//wrapper.setAsyncSupported(true);
wrapper.addMapping("/*");
tomcat.start();
tomcat.getServer().await();
}
}
And finally a servlet at src/main/java/net/jhorstmann/embeddedtomcat7/TestServlet.java
package net.jhorstmann.embeddedtomcat7;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html; charset=utf-8");
PrintWriter writer = resp.getWriter();
writer.println("" + req.getPathInfo() + "
");
writer.close();
}
}