Lukasz,

We have been doing this and it's no so hard to collect all jars and make it a double-clickable jar...
Here's our maven.xml extract...
You'll note that we call a GUI for that... it makes no sense to make a double-clickable jar that's not a GUI, I feel. This class also sets the catalina.home system-property (assuming the classloader is a subclass URLClassLoader). I simply use logFactor 5 as a GUI... Some authors which run their own servers have liked it.


<jar destFile="target/${fatJarName}">

      <zipfileset src="target/${maven.final.name}.jar"/>
      <j:forEach var="lib" items="${pom.artifacts}">
        <zipfileset src="${lib.file}"/>
      </j:forEach>

<fileset dir="conf"><include name="log4j.properties"/></fileset>

<manifest><attribute name="Main-Class" value="org.activemath.config.startup.AMMonolithicWithGUI"/></manifest>
</jar>


      <copy file="target/${fatJarName}"
        todir="."/>

</goal>


We've even partially also succeeded in running it over JNLP... the trouble remaining that you need a home for such things as the work directory....
Aside of the things previously mentionned, I got biten by class-loading stories. Here's our invoke, basically extracted from the boostrap of catalina. (this classloader subtleties allow the boostrap classes of tomcat to be invisible to webapps):


      String[] args = new String[] {"start"};
      ClassLoader loader = AMMonolithicWithGUI.class.getClassLoader();
      Class startupClass = loader.loadClass
          ("org.apache.catalina.startup.Catalina");
      Object startupInstance = startupClass.newInstance();
      Method setClassLoaderMethod =
        startupClass.getMethod("setParentClassLoader",
        new Class[] { ClassLoader.class});
      setClassLoaderMethod.invoke(startupInstance, new Object[]                 
        {loader});
      Method processMethod = startupClass.getMethod("process",
        new Class[] {String[].class});
      processMethod.invoke(startupInstance,new Object[] {args});

Hope that helps.

Paul


Lukasz Piestrzeniewicz wrote:
Hello!

I wonder if anyone has expirience with embedding Tomcat using Maven and
would like to share his knowleadge?

We use Maven in our new project (which is a web application). We would
like to build version of application with embedded Tomcat. The final
archive should contain the application war file, the Catalina core (we
plan to use Tomcat 4.1.27) and all dependices needed by the Catalina.
And of course a tiny bit of Java putting it all together.

What should be the preferred tactics? To place all jars needed by the
Catalina (with Catalina itself) in the Maven repository and use them as
dependices? Or rather use $CATALINA_HOME and maven.xml to copy needed
files by hand (needs unpacked and ready-to-run Tomcat on each
developer's machine)?

BTW. Is there any plugin to build end user distribution containing all
dependices, startup scripts etc. (like to the form Maven itself is
distributed)?

Uberjar is usefull but as you realize its not necesessery what I would
like to give to end user:

"...and then, you know, you run this supa-uberjar with java -jar
xxx-uber.jar..." ;)




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to