java web start - Looking for Webstart Maven Plugin sample application -


i looking source code complete application uses webstart maven plugin.

any ideas?

i tried webstart plugin in prrof of concept involving embedded tomcat server. plugin bound package phase , takes longtime execute, recommend invoke manually command line. generates zip file in target directory containing jnlp file , dependencies. file can extraced , put on webserver. url in pom should point path on server. when started, app runs tomcat server on localhost port 8080 simple servlet returns requested path string.

let me know if works you.

here pom of project, plugin configuration copied documentation here

<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"   xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">     <modelversion>4.0.0</modelversion>     <groupid>net.jhorstmann</groupid>     <artifactid>embeddedtomcatwebstart</artifactid>     <version>1.0-snapshot</version>     <packaging>jar</packaging>     <name>embeddedtomcatwebstart</name>     <url>http://localhost/jnlp/</url>     <organization>         <name>organisation</name>     </organization>     <properties>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>         <tomcat.version>7.0.6</tomcat.version>     </properties>     <repositories>         <repository>             <id>jboss</id>             <url>http://repository.jboss.org/nexus/content/groups/public/</url>         </repository>         <repository>             <id>sonatype</id>             <url>http://oss.sonatype.org/content/repositories/releases/</url>         </repository>     </repositories>     <build>         <plugins>             <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-compiler-plugin</artifactid>                 <version>2.3.2</version>                 <configuration>                     <source>1.5</source>                     <target>1.5</target>                 </configuration>             </plugin>             <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-jar-plugin</artifactid>                 <version>2.3.1</version>                 <configuration>                     <archive>                         <manifest>                             <mainclass>net.jhorstmann.embeddedtomcat7.app</mainclass>                         </manifest>                     </archive>                 </configuration>             </plugin>             <plugin>                 <groupid>org.codehaus.mojo.webstart</groupid>                 <artifactid>webstart-maven-plugin</artifactid>                 <executions>                     <execution>                         <!-- bind phase, prefer call manualls -->                         <phase>package</phase>                         <goals>                             <goal>jnlp-inline</goal> <!-- use jnlp, jnlp-inline or jnlp-single appropriate -->                         </goals>                     </execution>                 </executions>                 <configuration>                     <!--outputdirectory></outputdirectory--> <!-- not required?? -->                      <!-- set true exclude transitive dependencies. default false. -->                     <excludetransitive>false</excludetransitive>                      <!-- path libraries stored within jnlp structure. not required. default libraries within working directory -->                     <libpath>lib</libpath>                     <outputjarversions>true</outputjarversions>                     <!-- [optional] transitive dependencies filter - if omitted, transitive dependencies included -->                     <dependencies>                         <!-- note groupid , artifactid must specified here. because of limitation of include/excludesartifactfilter -->                         <!--                         <includes>                             <include>commons-logging:commons-logging</include>                             <include>commons-cli:commons-cli</include>                         </includes>                         -->                         <!--                         <excludes>                             <exclude></exclude>                         <excludes>                         -->                     </dependencies>                      <!--                     <resourcesdirectory>${project.basedir}/src/main/jnlp/resources</resourcesdirectory>                     -->                     <!-- default value -->                      <!-- jnlp generation -->                     <jnlp>                         <!-- default values -->                         <!--inputtemplateresourcepath>${project.basedir}</inputtemplateresourcepath-->                         <!--inputtemplate>src/main/jnlp/template.vm</inputtemplate--> <!-- relative inputtemplateresourcepath -->                         <outputfile>app.jnlp</outputfile> <!-- defaults launch.jnlp -->                          <!-- used automatically identify jar containing main class. -->                         <!-- perhaps going change -->                         <mainclass>net.jhorstmann.embeddedtomcat7.app</mainclass>                     </jnlp>                       <!-- signing -->                     <!-- defining automatically sign jar , dependencies, if necessary -->                     <sign>                         <keystore>${basedir}/keystore</keystore>                         <keypass>password</keypass>  <!-- need override passwords command line. ${keypass} -->                         <storepass>password</storepass> <!-- ${storepass} -->                         <!--storetype>fillme</storetype-->                         <alias>embeddedtomcatwebstart</alias>                          <!--validity>fillme</validity-->                          <!-- required generating keystore -->                         <dnamecn>embeddedtomcatwebstart</dnamecn>                         <dnameou>organisation unit</dnameou>                         <dnameo>organisation</dnameo>                         <dnamel>location</dnamel>                         <dnamest>state</dnamest>                         <dnamec>country</dnamec>                          <verify>true</verify> <!-- verify signing operation succeeded -->                          <!-- keystore management -->                         <keystoreconfig>                             <delete>true</delete> <!-- delete keystore -->                             <gen>true</gen>       <!-- optional shortcut generate store. -->                         </keystoreconfig>                     </sign>                      <!-- building process -->                      <pack200>true</pack200>                     <gzip>true</gzip> <!-- default force when pack200 false, true when pack200 selected ?? -->                      <!-- causes version attribute output in each jar resource element, optional, default false -->                     <outputjarversions>false</outputjarversions>                      <!--install>false</install--> <!-- not yet supported -->                     <verbose>true</verbose>                 </configuration>             </plugin>         </plugins>     </build>     <dependencies>         <dependency>             <groupid>org.apache.tomcat</groupid>             <artifactid>tomcat-catalina</artifactid>             <version>${tomcat.version}</version>         </dependency>         <dependency>             <groupid>org.apache.tomcat</groupid>             <artifactid>tomcat-coyote</artifactid>             <version>${tomcat.version}</version>         </dependency>     </dependencies> </project> 

here custom template jnlp file placed @ src/main/jnlp/template.vm, can't remember why needed exactly:

<?xml version="1.0" encoding="utf-8"?> <jnlp     spec="$jnlpspec"     codebase="$project.url"     href="$outputfile">   <information>     <title>$project.name</title>     <vendor>$project.organization.name</vendor>     <homepage href="$project.url"/>     <description>$project.description</description> #if($offlineallowed)     <offline-allowed/> #end   </information> #if($allpermissions)   <security>      <all-permissions/>   </security> #end   <resources>     <j2se version="$j2seversion"/>      $dependencies   </resources>   <application-desc main-class="$mainclass"/> </jnlp> 

this main class @ 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 servlet @ 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("<h1>" + req.getpathinfo() + "</h1>");         writer.close();     } } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -