<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TCO Blog]]></title><description><![CDATA[Blog about Java, Maven, Jenkins and others ]]></description><link>https://tcollignon.github.io</link><image><url>images/mustang.png</url><title>TCO Blog</title><link>https://tcollignon.github.io</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 28 Oct 2018 21:45:47 GMT</lastBuildDate><atom:link href="https://tcollignon.github.io/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Test Maven 3.6.0]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>This is a same blog post as the previous one for maven 3.5.0-alpha-1 here : <a href="https://tcollignon.github.io/2017/02/27/Test-Maven-350-alpha-1.html" class="bare">https://tcollignon.github.io/2017/02/27/Test-Maven-350-alpha-1.html</a></p>
</div>
<div class="paragraph">
<p>A new version of Maven (3.6.0) is currently in Apache [VOTE].</p>
</div>
<div class="paragraph">
<p>Binaries can be found here : <a href="https://dist.apache.org/repos/dist/dev/maven/maven-3/3.6.0/binaries/" class="bare">https://dist.apache.org/repos/dist/dev/maven/maven-3/3.6.0/binaries/</a></p>
</div>
<div class="paragraph">
<p>This is the result of my tests with this version.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configurations">Configurations</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_macosx_dev">MacOsX Dev</h3>
<div class="literalblock">
<div class="content">
<pre> mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
Maven home: /Applications/apache-maven-3.6.0
Java version: 1.8.0_51, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"</pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_jenkins_continous_integration_2_89_x_on_rhel7">Jenkins Continous Integration (2.89.X) On RHEL7</h3>
<div class="literalblock">
<div class="content">
<pre> mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
Maven home: /opt/apache-maven-3.6.0
Java version: 10.0.1, vendor: Oracle Corporation, runtime: /opt/jdk10.0.1
Default locale: fr_FR, platform encoding: Cp1252
OS name: "linux", version: "3.10.0-327.36.3.el7.x86_64", arch: "amd64", family: "unix"</pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_1st_project_takari_way">1st project : Takari way</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this little multi-module project, I have the following plugins :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>takari-lifecycle-plugin:1.12.1</p>
</li>
<li>
<p>maven-surefire-plugin:2.18.1</p>
</li>
<li>
<p>maven-compiler-plugin:3.1</p>
</li>
<li>
<p>maven-resources-plugin:2.6</p>
</li>
<li>
<p>maven-enforcer-plugin:1.3.1</p>
</li>
<li>
<p>maven-war-plugin:2.3</p>
</li>
<li>
<p>swagger-maven-plugin:2.2</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In addition, I have t he following extensions (describe in a .mvn folder) :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>takari-local-repository:0.11.2</p>
</li>
<li>
<p>takari-filemanager:0.8.3</p>
</li>
<li>
<p>aether-connector-okhttp:0.16.0</p>
</li>
<li>
<p>takari-smart-builder:0.4.0</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>I run mvn commands with takari smart builder and 6 threads.</p>
</div>
<div class="sect2">
<h3 id="_compile_and_tests">Compile and Tests</h3>
<div class="paragraph">
<p>mvn clean install</p>
</div>
<div class="paragraph">
<p>Build is SUCCESS with 3.5.0 but <strong>is not</strong> with 3.6.0 details further.</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.5.0 (MacOs)</th>
<th class="tableblock halign-left valign-top">Maven 3.6.0 (MacOs)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01:29 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01:40 min</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2nd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01:25 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01:28 min</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3rd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01:27 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">01:29 min</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><em>NOTE</em>: By default the build is <strong>FAILURE</strong> with 3.6.0 because of this configuration :
I have a multi-module project with this configuration of swagger-maven-plugin in web module.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;resources&gt;
   &lt;resource&gt;
       &lt;directory&gt;src/main/resources&lt;/directory&gt;
       &lt;excludes&gt;
           &lt;exclude&gt;NOTICE.txt&lt;/exclude&gt;
       &lt;/excludes&gt;
       &lt;filtering&gt;true&lt;/filtering&gt;
   &lt;/resource&gt;
&lt;/resources&gt;
&lt;plugin&gt;
   &lt;groupId&gt;com.github.kongchen&lt;/groupId&gt;
   &lt;artifactId&gt;swagger-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;2.2&lt;/version&gt;
   &lt;configuration&gt;
       &lt;apiSources&gt;
           &lt;apiSource&gt;
&lt;outputTemplate&gt;${project.build.resources[0].directory}/markdown.swagger.mustache&lt;/outputTemplate&gt;
           &lt;/apiSource&gt;
       &lt;/apiSources&gt;
   &lt;/configuration&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>It raise this error :</p>
</div>
<div class="paragraph">
<p>[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.</p>
</div>
<div class="paragraph">
<p>Indeed my template is in /Users/thomascollignon/Documents/Workspace_eclipse/neo/<strong>web</strong>/src/main/resources/markdown.swagger.mustache</p>
</div>
<div class="paragraph">
<p>If I change it to this configuration this is <strong>SUCCESS</strong></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;resources&gt;
   &lt;resource&gt;
       &lt;directory&gt;src/main/resources&lt;/directory&gt;
       &lt;excludes&gt;
           &lt;exclude&gt;NOTICE.txt&lt;/exclude&gt;
       &lt;/excludes&gt;
       &lt;filtering&gt;true&lt;/filtering&gt;
   &lt;/resource&gt;
&lt;/resources&gt;
&lt;plugin&gt;
   &lt;groupId&gt;com.github.kongchen&lt;/groupId&gt;
   &lt;artifactId&gt;swagger-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;2.2&lt;/version&gt;
   &lt;configuration&gt;
       &lt;apiSources&gt;
           &lt;apiSource&gt;
&lt;outputTemplate&gt;${project.basedir}/src/main/resources/markdown.swagger.mustache&lt;/outputTemplate&gt;
           &lt;/apiSource&gt;
       &lt;/apiSources&gt;
   &lt;/configuration&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p><em>It&#8217;s a small thing, but it can maybe broke several build.</em></p>
</div>
</div>
<div class="sect2">
<h3 id="_compile_only_no_tests">Compile ONLY (no Tests)</h3>
<div class="paragraph">
<p>mvn clean install -DskipTests</p>
</div>
<div class="paragraph">
<p>Build is SUCCESS with both version 3.5.0 and 3.6.0 (after correction, see above).</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.5.0 (MacOs)</th>
<th class="tableblock halign-left valign-top">Maven 3.6.0 (MacOs)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">11.028 s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">12.140 s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2nd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">18.098 s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">12.108 s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3rd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">17.225 s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">11.246 s</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_in_eclipse_ide">In Eclipse IDE</h3>
<div class="paragraph">
<p>I have Eclipse Oxygen (old version :) ) standard edition with m2e.
I have switch Maven settings to take my 3.6.0 local installation.
Everything works good, maven update/compilation/tests/Tomcat launch.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_2nd_project_classic_way">2nd project : Classic way</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this bigger multi-module project (10 000 classes, 63 modules, 150 000 unit tests), I have the following plugins :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>maven-surefire-plugin:2.22.0</p>
</li>
<li>
<p>maven-compiler-plugin:3.7.0</p>
</li>
<li>
<p>maven-resources-plugin:3.1.0</p>
</li>
<li>
<p>maven-war-plugin:3.2.2</p>
</li>
<li>
<p>maven-jar-plugin:3.1.0</p>
</li>
<li>
<p>maven-install-plugin:2.5.2</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>I have no takari.</p>
</div>
<div class="sect2">
<h3 id="_compile_and_tests_2">Compile and Tests</h3>
<div class="paragraph">
<p>mvn clean install -T 4</p>
</div>
<div class="paragraph">
<p>Build is SUCCESS with both version 3.5.3 and 3.6.0</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.5.3 (Jenkins)</th>
<th class="tableblock halign-left valign-top">Maven 3.6.0 (Jenkins)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">06:19 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">06:21 min</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2nd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">06:13 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">06:30 min</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3rd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">06:18 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">06:26 min</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Functionnaly it&#8217;s the same, compilation is ok, tests are OK too.
At performance level I&#8217;ve seen no improvment.</p>
</div>
</div>
<div class="sect2">
<h3 id="_compile_only_no_tests_2">Compile ONLY (no tests)</h3>
<div class="paragraph">
<p>mvn clean install -T 4 -DskipTests</p>
</div>
<div class="paragraph">
<p>Build is SUCCESS with both version 3.5.3 and 3.6.0</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.5.3 (Jenkins)</th>
<th class="tableblock halign-left valign-top">Maven 3.6.0 (Jenkins)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">03:41 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">03:39 min</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2nd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">03:37 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">03:41 min</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3rd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">03:44 min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">03:39 min</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For now I haven&#8217;t see any blocker to this new version of Apache Maven!</p>
</div>
<div class="paragraph">
<p>&#8658; Just see a little difference in a configuration with <em>${project.build.resources[0].directory}</em></p>
</div>
<div class="paragraph">
<p>The performance are almost the same as 3.5.0/3.5.3.</p>
</div>
<div class="paragraph">
<p>Good job Apache Maven Team</p>
</div>
</div>
</div>]]></description><link>https://tcollignon.github.io/2018/10/28/Test-Maven-360.html</link><guid isPermaLink="true">https://tcollignon.github.io/2018/10/28/Test-Maven-360.html</guid><category><![CDATA[Maven]]></category><dc:creator><![CDATA[COLLIGNON Thomas]]></dc:creator><pubDate>Sun, 28 Oct 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[How to speed up JSP compile with Tomcat and Maven : 2.0]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>I&#8217;ve already written a blog post on this topic : <a href="https://tcollignon.github.io/2016/12/04/How-to-compile-JSP-with-Tomcat-and-Maven-faster.html" class="bare">https://tcollignon.github.io/2016/12/04/How-to-compile-JSP-with-Tomcat-and-Maven-faster.html</a>
Meanwhile, I have proposed some PR to the project <a href="https://github.com/leonardehrenfried/jspc-maven-plugin" class="bare">https://github.com/leonardehrenfried/jspc-maven-plugin</a>, and now I&#8217;m an official committer.
I use this plugin in my work every day to compile many JSP, and I always try to compile faster.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_how_to_compile_jsp">How to compile JSP</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Like I said in my other blog post this is my current Maven configuration :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;plugin&gt;
   &lt;groupId&gt;io.leonard.maven.plugins&lt;/groupId&gt;
   &lt;artifactId&gt;jspc-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;2.4.1&lt;/version&gt;
   &lt;configuration&gt;
      &lt;webAppSourceDirectory&gt;${project.build.directory}/${project.artifactId}-${project.version}&lt;/webAppSourceDirectory&gt;
      &lt;webXml&gt;${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/web.xml&lt;/webXml&gt;
      &lt;generatedClasses&gt;${project.build.directory}/jspc&lt;/generatedClasses&gt;
   &lt;/configuration&gt;
   &lt;dependencies&gt;
      &lt;dependency&gt;
         &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
         &lt;artifactId&gt;tomcat-jasper&lt;/artifactId&gt;
         &lt;version&gt;8.5.4&lt;/version&gt;
         &lt;exclusions&gt;
            &lt;exclusion&gt;
               &lt;groupId&gt;org.eclipse.jdt.core.compiler&lt;/groupId&gt;
               &lt;artifactId&gt;ecj&lt;/artifactId&gt;
            &lt;/exclusion&gt;
         &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
         &lt;groupId&gt;org.eclipse.jdt.core.compiler&lt;/groupId&gt;
         &lt;artifactId&gt;ecj&lt;/artifactId&gt;
         &lt;version&gt;4.6.1&lt;/version&gt;
      &lt;/dependency&gt;
   &lt;/dependencies&gt;
&lt;/plugin&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note : I override tomcat-jasper in this configuration in order to use version 8.5.4  (by default it&#8217;s 8.5.8).</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_giving_more_threads">Giving more threads</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Our project includes many jsp (&gt; 3000), so the compilation take time. We can increase number of parallel threads. Usually I use 4 threads, but for now I want to improve this.
So I test with 16 threads. <strong>But surprise, the global time is not better than with 4 threads</strong>. Let&#8217;s see what happen with jvisualvm :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://tcollignon.github.io/images/threadsSynchronizedJDTCompiler.PNG" alt="threadsSynchronizedJDTCompiler">
</div>
</div>
<div class="paragraph">
<p>We can see that there are many synchronization phases for each threads. That is not good for global performance.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_trying_to_fix_synchronization">Trying to fix synchronization</h2>
<div class="sectionbody">
<div class="paragraph">
<p>I want to avoid these synchronization phases, so I take a look at the source code. The main problem is the code which call <em>java.util.jar.jarFile</em>, and it&#8217;s called by <em>sun.misc.URL.classPath.getResource(String)</em>
In the compiler the methods which called that most of the time are <em>org.apache.jasper.compiler.JDTCompiler$1.findType(String)</em> and <em>org.apache.jasper.compiler.JDTCompiler$1.isPackage(String)</em>
I try to rewrite part of it to totally avoid calling such a code, this is the case of <em>org.apache.jasper.compiler.JDTCompiler$1.isPackage(String)</em>.
But some part of code can&#8217;t be rewriting easily, so I decided to add a synchronized hash map to add cache mechanism. This is the case of <em>org.apache.jasper.compiler.JDTCompiler$1.findType(String)</em>.
With this 2 fixes I improve synchronized parts, jvisualvm confirms that :</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://tcollignon.github.io/images/threadsSynchronizedParallelJDTCompiler.PNG" alt="threadsSynchronizedParallelJDTCompiler">
</div>
</div>
<div class="paragraph">
<p>It&#8217;s better ! We see that at the beginning there are a lot of syncrhonizations, it&#8217;s a normal behavior. It&#8217;s time to put results in the cache, and after that the cache will always be used, so there will be no more synchronization phase.
But if we inspect the diagram in the last part we see that theres are other synchronizations. They are in the core of the compiler. I can&#8217;t easily add a cache map to this part of code.
I think it will take&#8217;s too much time to fix this &#8230;&#8203; So I don&#8217;t fix that, it&#8217;s still better than at the beginning.</p>
</div>
<div class="sect2">
<h3 id="_switch_compiler_class_in_maven_plugin">Switch compiler class in Maven plugin</h3>
<div class="paragraph">
<p>To use this improvement with Maven goal, I add a new option call "compilerClass" and I add a new Compiler in the plugin.
So by default compilerClass=org.apache.jasper.compiler.JDTCompiler, and it&#8217;s working perfectly with 1 thread. But when we have more than 2 threads it&#8217;s better to use the new one "org.apache.jasper.compiler.ParallelJDTCompiler".
This PR have been merged in version 2.4.3 of the plugin : <a href="https://github.com/leonardehrenfried/jspc-maven-plugin/releases/tag/jspc-maven-plugin-2.4.3" class="bare">https://github.com/leonardehrenfried/jspc-maven-plugin/releases/tag/jspc-maven-plugin-2.4.3</a></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;plugin&gt;
   &lt;groupId&gt;io.leonard.maven.plugins&lt;/groupId&gt;
   &lt;artifactId&gt;jspc-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;2.4.3&lt;/version&gt;
   &lt;configuration&gt;
      &lt;webAppSourceDirectory&gt;${project.build.directory}/${project.artifactId}-${project.version}&lt;/webAppSourceDirectory&gt;
      &lt;webXml&gt;${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/web.xml&lt;/webXml&gt;
      &lt;generatedClasses&gt;${project.build.directory}/jspc&lt;/generatedClasses&gt;
      &lt;compilerClass&gt;org.apache.jasper.compiler.ParallelJDTCompiler&lt;/compilerClass&gt;
      &lt;threads&gt;4&lt;/threads&gt;
   &lt;/configuration&gt;
&lt;/plugin&gt;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_benchmark">Benchmark</h3>
<div class="paragraph">
<p>I made a little benchmark including one project with ~3000 jsp.
I test this on HP ZBook i7 Windows 7.</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Duration</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2 threads JDTCompiler</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2min28s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2 threads ParallelJDTCompiler</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1min20s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">4 threads JDTCompiler</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1min40s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">4 threads ParallelJDTCompiler</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1min02s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">8 threads JDTCompiler</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1min40s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">8 threads ParallelJDTCompiler</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0min54s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">16 threads JDTCompiler</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1min39s</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">16 threads ParallelJDTCompiler</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0min49s</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_notes">Notes</h3>
<div class="paragraph">
<p>There is a incompatibility with maven 3.3.X and version 2.4.3 of jspc-maven-plugin. If you use maven 3.3.X you must take version 2.4.4 of the plugin.</p>
</div>
</div>
</div>
</div>]]></description><link>https://tcollignon.github.io/2018/02/19/How-to-speed-up-JSP-compile-with-Tomcat-and-Maven-20.html</link><guid isPermaLink="true">https://tcollignon.github.io/2018/02/19/How-to-speed-up-JSP-compile-with-Tomcat-and-Maven-20.html</guid><category><![CDATA[Tomcat]]></category><category><![CDATA[JSP]]></category><category><![CDATA[Maven]]></category><dc:creator><![CDATA[COLLIGNON Thomas]]></dc:creator><pubDate>Mon, 19 Feb 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[How-To Use third party libraries in Jenkins Pipeline]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://jenkins.io/doc/book/pipeline/">Jenkins Pipeline</a> has so many features and this new way of using Jenkins it&#8217;s very powerfull.
I use a lot of pipeline, and in some case I need to use a third party jar. There a many options to do that, let&#8217;s see!</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_the_use_case">The use case</h2>
<div class="sectionbody">
<div class="paragraph">
<p>My principal use case is establish a JDBC connection in Jenkins Pipeline. To do this I need the JDBC driver in the system classloader. By default it&#8217;s not the case obviously.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_old_way_with_groovy">Old way with Groovy</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In my first implementation, I wrote this groovy code to do the job :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-groovy" data-lang="groovy">	import groovy.sql.Sql;

 	def classLoader = ClassLoader.systemClassLoader
    while (classLoader.parent) {
        classLoader = classLoader.parent
    }
    classLoader.addURL(new File("/opt/oracle/product/11.2.0/client/jdbc/lib/ojdbc6.jar").toURL())
    def sql = Sql.newInstance('jdbc:oracle:thin:@SERVER:2483/INSTANCE', 'USER', 'PASSWORD', 'oracle.jdbc.OracleDriver')
    sql.execute 'select 1 from dual'
    sql.close()</code></pre>
</div>
</div>
<div class="paragraph">
<p>In this solution there is half the code that is technical. It is not very readable and understandable, but it works.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_new_way_groovy_grab">New way : Groovy Grab</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Thanks to <a href="https://twitter.com/aheritier">@aheritier</a> I found that we can use <a href="http://docs.groovy-lang.org/latest/html/documentation/grape.html#_quick_start">Groovy Grab</a> in Jenkins to <a href="https://jenkins.io/doc/book/pipeline/shared-libraries/#using-third-party-libraries">add third pary libraries</a>.
At first glance this can be a very good way to achieve this use case.
The new code could be this :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-groovy" data-lang="groovy">	@Grab('com.oracle:ojdbc6:11.2.0.4')
	import groovy.sql.Sql;

    def sql = Sql.newInstance('jdbc:oracle:thin:@SERVER:2483/INSTANCE', 'USER', 'PASSWORD', 'oracle.jdbc.OracleDriver')
    sql.execute 'select 1 from dual'
    sql.close()</code></pre>
</div>
</div>
<div class="paragraph">
<p>This is better than the first one : less code, no more technical code, more readable.
But in fact it doesn&#8217;t work. At least in my case.
Let see why.</p>
</div>
<div class="sect2">
<h3 id="_1st_problem_get_jar">1st problem : Get Jar</h3>
<div class="paragraph">
<p><a href="http://docs.groovy-lang.org/latest/html/documentation/grape.html#_quick_start">Groovy Grab</a> use <a href="http://ant.apache.org/ivy/">Ivy</a> to manage the recovery of jars.
You need to add <a href="https://wiki.jenkins.io/display/JENKINS/Pipeline+Shared+Groovy+Libraries+Plugin">Shared Groovy Libraries Plugin</a>.
By default it get jars from <a href="https://search.maven.org/">maven central</a>, but you can specify other repositories with the annotation @GrabResolver
If you are familiar with this repo, you know that Oracle Driver will not be present. Of course it commercial part etc&#8230;&#8203;
So the previous code doesn&#8217;t work and we get this kind of error :</p>
</div>
<div class="literalblock">
<div class="content">
<pre>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes -- [unresolved dependency: com.oracle#ojdbc6;11.2.0.4: not found]
java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: com.oracle#ojdbc6;11.2.0.4: not found]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)</pre>
</div>
</div>
<div class="paragraph">
<p>There are other problem if Maven central is not accessible, like in enterprise with http proxy for example.
If you have a binary repository like <a href="https://www.jfrog.com/artifactory/">artifactory</a>, you must add a Ivy configuration to let Grab get jar from this repository.
To do this add a <em>grapeConfig.xml</em> in your jenkins MASTER installation, in the $JENKINS_HOME/.groovy directory.
You can generate Ivy config from the artifactory instance.
An example can be :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;ivy-settings
  &lt;settings defaultResolver="downloadGrapes" /&gt;
  &lt;credentials host="artifactoryHostname" realm="Artifactory Realm" username="user" passwd="password" /&gt;
  &lt;resolvers&gt;
    &lt;chain name="downloadGrapes"&gt;
      &lt;ibiblio name="public" m2compatible="true" root="http://artifactoryHostname/artifactory/libs-release" /&gt;
    &lt;/chain&gt;
  &lt;/resolvers&gt;
&lt;/ivy-settings&gt;</code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
You need to restart Jenkins MASTER to load new _grapeConfig.xml" file.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>With this config, the jars we be downloading correctly and will be in the grape cache under $JENKINS_HOME/.groovy/grapes directory.</p>
</div>
</div>
<div class="sect2">
<h3 id="_2nd_problem_jdbc">2nd problem : JDBC</h3>
<div class="paragraph">
<p>Now we have a good configuration of Grape (and Ivy) in Jenkins, but this example still does not work.
The new error is :</p>
</div>
<div class="literalblock">
<div class="content">
<pre>java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@SERVER:2483/INSTANCE
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at groovy.sql.Sql.newInstance(Sql.java:402)
at groovy.sql.Sql.newInstance(Sql.java:446)
at groovy.sql.Sql$newInstance.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)</pre>
</div>
</div>
<div class="paragraph">
<p>The problem is JDBC itself, it need to be loading by the system classloader to work correctly.</p>
</div>
<div class="paragraph">
<p>First idea : <a href="http://docs.groovy-lang.org/latest/html/documentation/grape.html#Grape-JDBCDrivers">@GrabConfig(systemClassLoader=true)</a>.</p>
</div>
<div class="paragraph">
<p>It&#8217;s the Groovy way to deal with JDBC driver.
I try it, but actually Jenkins does not support this solution and raise this error :</p>
</div>
<div class="literalblock">
<div class="content">
<pre>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: No suitable ClassLoader found for grab
java.lang.RuntimeException: No suitable ClassLoader found for grab
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
at groovy.grape.GrapeIvy.chooseClassLoader(GrapeIvy.groovy:182)
at groovy.grape.GrapeIvy$chooseClassLoader.callCurrent(Unknown Source)
at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:249)
at groovy.grape.Grape.grab(Grape.java:167)</pre>
</div>
</div>
<div class="paragraph">
<p>So another solution is to register the driver before instantiating the connection, thanks to <a href="https://twitter.com/GroGro57">@GroGro57</a> and <a href="https://twitter.com/evildethow">@evildethow</a> for their help.</p>
</div>
<div class="literalblock">
<div class="content">
<pre>DriverManager.registerDriver(new oracle.jdbc.OracleDriver())</pre>
</div>
</div>
<div class="paragraph">
<p>Edit : <a href="https://twitter.com/josepaumard">@JosePaumard</a> give another solution to load the driver, the final code use this one.
This solution actually works in Jenkins 2.60.1, but I hope @GrabConfig will be added in a future release of the Shared Groovy Plugin.</p>
</div>
</div>
<div class="sect2">
<h3 id="_final_code">Final Code</h3>
<div class="paragraph">
<p>In the end the pipeline code will be :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-groovy" data-lang="groovy">	@Grab('com.oracle:ojdbc6:11.2.0.4')
	import groovy.sql.Sql;
    import java.util.ServiceLoader;
    import java.sql.Driver;

    ServiceLoader&lt;Driver&gt; loader = ServiceLoader.load(Driver.class);
    def sql = Sql.newInstance('jdbc:oracle:thin:@SERVER:2483/INSTANCE', 'USER', 'PASSWORD', 'oracle.jdbc.OracleDriver')
    sql.execute 'select 1 from dual'
    sql.close()</code></pre>
</div>
</div>
</div>
</div>
</div>]]></description><link>https://tcollignon.github.io/2017/07/10/How-To-Use-third-party-libraries-in-Jenkins-Pipeline.html</link><guid isPermaLink="true">https://tcollignon.github.io/2017/07/10/How-To-Use-third-party-libraries-in-Jenkins-Pipeline.html</guid><category><![CDATA[Jenkins]]></category><category><![CDATA[Groovy]]></category><dc:creator><![CDATA[COLLIGNON Thomas]]></dc:creator><pubDate>Mon, 10 Jul 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Test Maven 3.5.0-alpha-1]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>A new version of Maven (3.5.0-alpha-1) is currently in Apache [VOTE].</p>
</div>
<div class="paragraph">
<p>Binaries can be found here : <a href="https://repository.apache.org/content/repositories/maven-1324/org/apache/maven/apache-maven/3.5.0-alpha-1/" class="bare">https://repository.apache.org/content/repositories/maven-1324/org/apache/maven/apache-maven/3.5.0-alpha-1/</a></p>
</div>
<div class="paragraph">
<p>This is the result of my tests with this version.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configurations">Configurations</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_macosx_dev">MacOsX Dev</h3>
<div class="literalblock">
<div class="content">
<pre>mvn -v
Apache Maven 3.5.0-alpha-1 (8e6bbc4d4aa7cdc837625a05358c98ca15f72698; 2017-02-23T16:04:43+01:00)
Maven home: /Applications/apache-maven-3.5.0-alpha-1
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.3", arch: "x86_64", family: "mac"</pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_jenkins_continous_integration_2_19_x_on_rhel7">Jenkins Continous Integration (2.19.X) On RHEL7</h3>
<div class="literalblock">
<div class="content">
<pre>mvn -v
Apache Maven 3.5.0-alpha-1 (8e6bbc4d4aa7cdc837625a05358c98ca15f72698; 2017-02-23T16:04:43+01:00)
Maven home: /opt/apache-maven-3.3.9
Java version: 1.8.0_112, vendor: Oracle Corporation
Java home: /opt/jdk1.8.0_112/jre
Default locale: fr_FR, platform encoding: Cp1252
OS name: "linux", version: "3.10.0-327.28.2.el7.x86_64", arch: "amd64", family: "unix"</pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_1st_project_takari_way">1st project : Takari way</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this little multi-module project, I have the following plugins :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>takari-lifecycle-plugin:1.12.1</p>
</li>
<li>
<p>maven-surefire-plugin:2.18.1</p>
</li>
<li>
<p>maven-compiler-plugin:3.1</p>
</li>
<li>
<p>maven-resources-plugin:2.6</p>
</li>
<li>
<p>maven-enforcer-plugin:1.3.1</p>
</li>
<li>
<p>maven-war-plugin:2.3</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In addition, I have the following extensions (describe in a .mvn folder) :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>takari-local-repository:0.11.2</p>
</li>
<li>
<p>takari-filemanager:0.8.3</p>
</li>
<li>
<p>aether-connector-okhttp:0.16.0</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>I run mvn commands with takari smart builder and 6 threads.</p>
</div>
<div class="sect2">
<h3 id="_compile_and_tests">Compile and Tests</h3>
<div class="literalblock">
<div class="content">
<pre>mvn clean install</pre>
</div>
</div>
<div class="paragraph">
<p>Build is SUCCESS with both version 3.3.9 and 3.5.0-alpha-1.</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.3.9 (MacOs)</th>
<th class="tableblock halign-left valign-top">Maven 3.5.0-alpha-1 (MacOs)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 44.581 s (Wall Clock)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 43.968 s (Wall Clock)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2nd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 47.276 s (Wall Clock)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 43.678 s (Wall Clock)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3rd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 44.256 s (Wall Clock)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 43.660 s (Wall Clock)</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><em>NOTE</em>: in Maven 3.3.9 I have not warning parallel execution, but I have in Maven 3.5.0-alpha-1</p>
</div>
<div class="literalblock">
<div class="content">
<pre>[WARNING] *****************************************************************
[WARNING] * Your build is requesting parallel execution, but project      *
[WARNING] * contains the following plugin(s) that have goals not marked   *
[WARNING] * as @threadSafe to support parallel building.                  *
[WARNING] * While this /may/ work fine, please look for plugin updates    *
[WARNING] * and/or request plugins be made thread-safe.                   *
[WARNING] * If reporting an issue, report it against the plugin in        *
[WARNING] * question, not against maven-core                              *
[WARNING] *****************************************************************
[WARNING] The following plugins are not marked @threadSafe in neo routeur:
[WARNING] io.takari.maven.plugins:takari-lifecycle-plugin:1.12.1
[WARNING] Enable debug to see more precisely which goals are not marked @threadSafe.
[WARNING] *****************************************************************</pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_compile_only_no_tests">Compile ONLY (no Tests)</h3>
<div class="literalblock">
<div class="content">
<pre>mvn clean install -DskipTests</pre>
</div>
</div>
<div class="paragraph">
<p>Build is SUCCESS with both version 3.3.9 and 3.5.0-alpha-1.</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.3.9 (MacOs)</th>
<th class="tableblock halign-left valign-top">Maven 3.5.0-alpha-1 (MacOs)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 8.453 s (Wall Clock)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 8.057 s (Wall Clock)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2nd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 8.764 s (Wall Clock)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 8.292 s (Wall Clock)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3rd run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 8.293 s (Wall Clock)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total time: 8.326 s (Wall Clock)</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_in_eclipse_ide">In Eclipse IDE</h3>
<div class="paragraph">
<p>I have Eclipse NEON standard edition with m2e.
I have switch Maven settings to take my 3.5.0-alpha-1 local installation.
Everything works good, maven update/compilation/tests/Tomcat launch.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_2nd_project_classic_way">2nd project : Classic way</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this bigger multi-module project (10 000 classes), I have the following plugins :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>maven-surefire-plugin:2.16</p>
</li>
<li>
<p>maven-compiler-plugin:3.3</p>
</li>
<li>
<p>maven-resources-plugin:3.0.1</p>
</li>
<li>
<p>maven-war-plugin:3.0.0</p>
</li>
<li>
<p>maven-jar-plugin:2.4</p>
</li>
<li>
<p>maven-install-plugin:2.5.1</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>I have no takari.</p>
</div>
<div class="sect2">
<h3 id="_compile_and_tests_no_threading">Compile and Tests, no Threading</h3>
<div class="literalblock">
<div class="content">
<pre>mvn clean install</pre>
</div>
</div>
<div class="paragraph">
<p>Build is SUCCESS with both version 3.3.9 and 3.5.0-alpha-1.</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.3.9 (Jenkins)</th>
<th class="tableblock halign-left valign-top">Maven 3.5.0-alpha-1 (Jenkins)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">28min</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">27min</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><em>NOTE</em>: in Jenkins by default the console output is ugly with maven 3.5.0-alpha-1 (see next). To fix this the <a href="https://wiki.jenkins-ci.org/display/JENKINS/AnsiColor+Plugin">Ansi Color Plugin</a> is necessary !</p>
</div>
<div class="literalblock">
<div class="content">
<pre>[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;32mBUILD SUCCESS[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m</pre>
</div>
</div>
<div class="paragraph">
<p><em>EDIT</em> : After reading this, <a href="https://twitter.com/rfscholte">@rfscholte</a> said it&#8217;s weird because Jenkins use -B option (Maven batch mode) by default, and in this case ANSI color is not enable, so the output console should be good.</p>
</div>
<div class="paragraph">
<p>So I have test another cases :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Jenkins Maven Job</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Output command is :</p>
</div>
<div class="literalblock">
<div class="content">
<pre>&lt;===[JENKINS REMOTING CAPACITY]===&gt;channel started
Executing Maven:  -B -f /data/blabla/pom.xml -s /opt/apache-maven-3.5.0-alpha-1/conf/settings.xml -gs /opt/apache-maven-3.5.0-alpha-1/conf/settings.xml clean install -Dmaven.test.failure.ignore=true -T 4</pre>
</div>
</div>
<div class="paragraph">
<p>And I have  ugly output</p>
</div>
<div class="literalblock">
<div class="content">
<pre>[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1mReactor Build Order:[m
[[1;34mINF[m]</pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Jenkins Freestyle Job with maven step</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Output command is :</p>
</div>
<div class="literalblock">
<div class="content">
<pre>$ /opt/apache-maven-3.5.0-alpha-1/bin/mvn -f pom.xml -s /opt/apache-maven-3.5.0-alpha-1/conf/settings.xml -gs /opt/apache-maven-3.5.0-alpha-1/conf/settings.xml clean install -Dmaven.test.failure.ignore=true -T 4</pre>
</div>
</div>
<div class="paragraph">
<p>And in this case output is ok</p>
</div>
<div class="literalblock">
<div class="content">
<pre>[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]</pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Jenkins Pipeline</p>
<div class="literalblock">
<div class="content">
<pre>node {
  checkout(blabla)
  env.MAVEN_HOME=tool name: 'Maven 3.5.0-alpha-1', type: 'maven'
  sh 'mvn clean install -B -Dmaven.test.failure.ignore=true -T 4'
}</pre>
</div>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>And in this case output is ok too</p>
</div>
<div class="paragraph">
<p><strong>Conclusion</strong> : do not use Jenkins Maven project, or using with <a href="https://wiki.jenkins-ci.org/display/JENKINS/AnsiColor+Plugin">Ansi Color Plugin</a></p>
</div>
</div>
<div class="sect2">
<h3 id="_compile_only_no_tests_no_threading">Compile ONLY (no tests), no Threading</h3>
<div class="literalblock">
<div class="content">
<pre>mvn clean install -DskipTests</pre>
</div>
</div>
<div class="paragraph">
<p>Build is SUCCESS with both version 3.3.9 and 3.5.0-alpha-1.</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.3.9 (Jenkins)</th>
<th class="tableblock halign-left valign-top">Maven 3.5.0-alpha-1 (Jenkins)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">6min29s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">6min27s</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_compile_only_no_tests_and_4_threads">Compile ONLY (no tests) and 4 Threads</h3>
<div class="literalblock">
<div class="content">
<pre>mvn clean install -T 4</pre>
</div>
</div>
<div class="paragraph">
<p>Build is SUCCESS with both version 3.3.9 and 3.5.0-alpha-1.</p>
</div>
<div class="paragraph">
<p>This is the performance test :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Maven 3.3.9 (Jenkins)</th>
<th class="tableblock halign-left valign-top">Maven 3.5.0-alpha-1 (Jenkins)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1st run</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">4min10s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">4min13s</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For now I haven&#8217;t see any blocker to this new version of Apache Maven!</p>
</div>
<div class="paragraph">
<p>The performance are almost the same as 3.3.9.</p>
</div>
<div class="paragraph">
<p>New color output console of Maven is nice.</p>
</div>
<div class="paragraph">
<p>Good job Apache Maven Team</p>
</div>
</div>
</div>]]></description><link>https://tcollignon.github.io/2017/02/27/Test-Maven-350-alpha-1.html</link><guid isPermaLink="true">https://tcollignon.github.io/2017/02/27/Test-Maven-350-alpha-1.html</guid><category><![CDATA[Maven]]></category><dc:creator><![CDATA[COLLIGNON Thomas]]></dc:creator><pubDate>Mon, 27 Feb 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[How to compile JSP with Tomcat and Maven faster]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>When I must pre-compile JSP with tomcat, it&#8217;s usually pain because it takes a lot of time.
Let&#8217;s see How compile this faster.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_how_to_compile_jsp">How to compile JSP</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If I must compile for tomcat, I usually take this Maven plugin : <a href="https://github.com/leonardehrenfried/jspc-maven-plugin" class="bare">https://github.com/leonardehrenfried/jspc-maven-plugin</a>
I take this plugin because I think it&#8217;s pretty simple, and it give availabilty to add includes/excludes of jsp.
This is the Maven config to do the job in my War project (we see that I have a tomcat 8 project) :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;plugin&gt;
   &lt;groupId&gt;de.mytoys.maven.plugins&lt;/groupId&gt;
   &lt;artifactId&gt;jspc-maven-plugin&lt;/artifactId&gt;
   &lt;version&gt;1.1.0&lt;/version&gt;
   &lt;configuration&gt;
      &lt;webAppSourceDirectory&gt;${project.build.directory}/${project.artifactId}-${project.version}&lt;/webAppSourceDirectory&gt;
      &lt;webXml&gt;${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/web.xml&lt;/webXml&gt;
      &lt;generatedClasses&gt;${project.build.directory}/jspc&lt;/generatedClasses&gt;
   &lt;/configuration&gt;
   &lt;dependencies&gt;
      &lt;dependency&gt;
         &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
         &lt;artifactId&gt;tomcat-jasper&lt;/artifactId&gt;
         &lt;version&gt;8.5.4&lt;/version&gt;
         &lt;exclusions&gt;
            &lt;exclusion&gt;
               &lt;groupId&gt;org.eclipse.jdt.core.compiler&lt;/groupId&gt;
               &lt;artifactId&gt;ecj&lt;/artifactId&gt;
            &lt;/exclusion&gt;
         &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
         &lt;groupId&gt;org.eclipse.jdt.core.compiler&lt;/groupId&gt;
         &lt;artifactId&gt;ecj&lt;/artifactId&gt;
         &lt;version&gt;4.6.1&lt;/version&gt;
      &lt;/dependency&gt;
   &lt;/dependencies&gt;
&lt;/plugin&gt;</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_some_problems_of_this_plugin">Some problems of this plugin</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If we have many jsp (&gt; 500) the plugin can take lot of time to compile all files. (see the benchmark after)
The other problem is this plugin will stop and fail at the first jsp who contains error.
And even at the first error in the jsp! If a jsp contains 5 errors, we must run 5 times the plugin to discover all.
So if a big project contains multiples errors, we must run may times the plugin and so many times the full compilation of all jsp.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_first_fix_performance">First fix : performance</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In order to compile a big project faster, I propose different things</p>
</div>
<div class="sect2">
<h3 id="_give_all_jsp_to_jasper_jspc">Give all jsp to Jasper JSPC</h3>
<div class="paragraph">
<p>In version 1.1.0 of the plugin, it takes all of the jsp and call execute JSPC for each of them.
This is the code :</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-java" data-lang="java">for (String fileName : jspFiles) {
	jspc.setJspFiles(fileName);
	getLog().info("Compiling " + fileName);
	jspc.execute();
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Maybe it&#8217;s an optimization for Tomcat 6.X, but I think with Tomcat 8.X it&#8217;s slower than giving all JSP directly to JSPC.execute();
See pull request <a href="https://github.com/leonardehrenfried/jspc-maven-plugin/pull/1" class="bare">https://github.com/leonardehrenfried/jspc-maven-plugin/pull/1</a> to fix this.</p>
</div>
</div>
<div class="sect2">
<h3 id="_execute_compilation_in_parallel">Execute compilation in parallel</h3>
<div class="paragraph">
<p>To compile faster we need to compile in parallel.
Indeed when we launch JavaMissionControl for example, we see the CPU is 20%-30% usage when compiling.
To increase CPU usage, we need to execute jspc in different thread.
See pull request <a href="https://github.com/leonardehrenfried/jspc-maven-plugin/pull/2" class="bare">https://github.com/leonardehrenfried/jspc-maven-plugin/pull/2</a> to add this feature.</p>
</div>
</div>
<div class="sect2">
<h3 id="_benchmark">Benchmark</h3>
<div class="paragraph">
<p>I made a little benchmark with two projects : one with 400 jsp and one with 2700 jsp.
I test this on HP ZBook i7 Windows 7.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>400 jsp</p>
</li>
</ul>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Time</th>
<th class="tableblock halign-left valign-top">Java Heap</th>
<th class="tableblock halign-left valign-top">CPU</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">out of the box 1.1.0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">50s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.3Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">20%-30%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Giving all jsp to jspc.execute</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">30sec</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.1Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">20%-30%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">With 2 threads</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">21s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">60%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">With 4 threads</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">17s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">90%</p></td>
</tr>
</tbody>
</table>
<div class="ulist">
<ul>
<li>
<p>2700 jsp</p>
</li>
</ul>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Time</th>
<th class="tableblock halign-left valign-top">Java Heap</th>
<th class="tableblock halign-left valign-top">CPU</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">out of the box 1.1.0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">18min18s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">20%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Giving all jsp to jspc.execute</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3min43s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">20%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">With 2 threads</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2min5s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">40%-60%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">With 4 threads</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1min25</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">80%</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_second_fix_stop_at_first_error">Second fix : stop at first error</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To avoid this behavior, I add new parameter : stopAtFirstError (true by default for retro-compatibility).
Indeed Jasper JSPC provide a parameter "failOnError" wich allow to continue even if error were raised.
This feature works only if we gave all the jsp to jspc. (see first fix).
But we need to fail maven build if we have jsp error, but when we call jspc with "failOnError=false", it raise no exception.
So the only way I found right now is to add a Log handler who tell the Mojo if jspc raise a SEVERE error in his log (this is a little be tricky&#8230;&#8203;).
If we take multiple threads, this parameter works only if it&#8217;s "false".
If it&#8217;s true, each thread with stop at first error.
See pull request <a href="https://github.com/leonardehrenfried/jspc-maven-plugin/pull/2" class="bare">https://github.com/leonardehrenfried/jspc-maven-plugin/pull/2</a> to add this feature.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_comparing_to_other_maven_plugins">Comparing to other Maven plugins</h2>
<div class="sectionbody">
<div class="paragraph">
<p>During this case I search other Maven plugins who compile JSP with Tomcat. It&#8217;s not easy because JSP it&#8217;s very fashionable&#8230;&#8203;
I found this major ones :</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://github.com/leonardehrenfried/jspc-maven-plugin" class="bare">https://github.com/leonardehrenfried/jspc-maven-plugin</a></p>
<div class="ulist">
<ul>
<li>
<p>no recent upgrade</p>
</li>
<li>
<p>provide includes/excludes parameters</p>
</li>
<li>
<p>trace all jsp in log when compiling</p>
</li>
<li>
<p>fork of jetty-jspc-maven-plugin</p>
</li>
</ul>
</div>
</li>
<li>
<p><a href="https://github.com/Jasig/jspc-maven-plugin" class="bare">https://github.com/Jasig/jspc-maven-plugin</a></p>
<div class="ulist">
<ul>
<li>
<p>1 recent upgrade</p>
</li>
<li>
<p>allow different version of tomcat compiler (by design)</p>
</li>
<li>
<p>fork of the Codehaus jspc-maven-plugin</p>
</li>
<li>
<p>does not provide stopAtFirstError=false for now (but there are current PR for that)</p>
</li>
<li>
<p>does not provide includes/excludes parameters</p>
</li>
<li>
<p>trace all jsp in log when compiling</p>
</li>
</ul>
</div>
</li>
<li>
<p>jspc-maven-plugin from codehaus</p>
<div class="ulist">
<ul>
<li>
<p>no more maintained</p>
</li>
<li>
<p>does not provide stopAtFirstError=false</p>
</li>
<li>
<p>does not provide tomcat 8 compiler (only tomcat 6)</p>
</li>
</ul>
</div>
</li>
<li>
<p><a href="https://www.eclipse.org/jetty/documentation/current/jetty-jspc-maven-plugin.html" class="bare">https://www.eclipse.org/jetty/documentation/current/jetty-jspc-maven-plugin.html</a></p>
<div class="ulist">
<ul>
<li>
<p>design by and for jetty</p>
</li>
<li>
<p>if we give jasper dependency we can use this for tomcat</p>
</li>
<li>
<p>does not provide stopAtFirstError=false for now</p>
</li>
<li>
<p>trace all jsp in log at startup</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>And this is a little benchmark of this plugins with my project (2700 jsp).</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Time</th>
<th class="tableblock halign-left valign-top">Java Heap</th>
<th class="tableblock halign-left valign-top">CPU</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">leonardehrenfried/jspc-maven-plugin 1.1.0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">18min18s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">20%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">leonardehrenfried/jspc-maven-plugin with my PR (4 threads)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1min25</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">80%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Jasig/jspc-maven-plugin</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3min22s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.35Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">20%</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">jspc-maven-plugin from codehaus</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">not possible because not support tomcat 8</p></td>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">jetty-jspc-maven-plugin</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3min50s</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.37Gb</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">20%</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If the wholes PR are accepted, the plugin will be much faster and will permit to not stop at the first error.
I think this maybe start a "version 2.X" of this plugin because one PR need java 7.
I think this plugin can give Tomcat 8 by default now (especially if it start 2.X version).
If you want to use this plugin with this fix and features see this : <a href="https://github.com/leonardehrenfried/jspc-maven-plugin/pull/2" class="bare">https://github.com/leonardehrenfried/jspc-maven-plugin/pull/2</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_annex">Annex</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_jasig_jspc_maven_plugin_config">Jasig JSPC maven plugin config</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;plugin&gt;
	&lt;groupId&gt;org.jasig.mojo.jspc&lt;/groupId&gt;
	&lt;artifactId&gt;jspc-maven-plugin&lt;/artifactId&gt;
	&lt;version&gt;2.0.2&lt;/version&gt;
	&lt;executions&gt;
		&lt;execution&gt;
		&lt;id&gt;jspc&lt;/id&gt;
		&lt;phase&gt;package&lt;/phase&gt;
		&lt;goals&gt;
			&lt;goal&gt;compile&lt;/goal&gt;
		&lt;/goals&gt;
		&lt;configuration&gt;
        	&lt;inputWebXml&gt;${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/web.xml&lt;/inputWebXml&gt;
            &lt;defaultSourcesDirectory&gt;${project.build.directory}/${project.artifactId}-${project.version}&lt;/defaultSourcesDirectory&gt;
		&lt;/configuration&gt;
		&lt;/execution&gt;
	&lt;/executions&gt;

	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.jasig.mojo.jspc&lt;/groupId&gt;
			&lt;artifactId&gt;jspc-compiler-tomcat8&lt;/artifactId&gt;
			&lt;version&gt;2.0.2&lt;/version&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;
&lt;/plugin&gt;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_jetty_jspc_maven_plugin_config">jetty JSPC maven plugin config</h3>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-xml" data-lang="xml">&lt;plugin&gt;
	&lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
	&lt;artifactId&gt;jetty-jspc-maven-plugin&lt;/artifactId&gt;
	&lt;version&gt;9.3.14.v20161028&lt;/version&gt;
	&lt;executions&gt;
		&lt;execution&gt;
		&lt;id&gt;jspc&lt;/id&gt;
		&lt;phase&gt;package&lt;/phase&gt;
		&lt;goals&gt;
			&lt;goal&gt;jspc&lt;/goal&gt;
		&lt;/goals&gt;
			&lt;configuration&gt;
            	&lt;webXml&gt;${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/web.xml&lt;/webXml&gt;
				&lt;webAppSourceDirectory&gt;${project.build.directory}/${project.artifactId}-${project.version}&lt;/webAppSourceDirectory&gt;
			&lt;/configuration&gt;
		&lt;/execution&gt;
	&lt;/executions&gt;
     &lt;dependencies&gt;
      &lt;dependency&gt;
         &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
         &lt;artifactId&gt;tomcat-jasper&lt;/artifactId&gt;
         &lt;version&gt;${tomcatVersion}&lt;/version&gt;
         &lt;exclusions&gt;
            &lt;exclusion&gt;
               &lt;groupId&gt;org.eclipse.jdt.core.compiler&lt;/groupId&gt;
               &lt;artifactId&gt;ecj&lt;/artifactId&gt;
            &lt;/exclusion&gt;
         &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
         &lt;groupId&gt;org.eclipse.jdt.core.compiler&lt;/groupId&gt;
         &lt;artifactId&gt;ecj&lt;/artifactId&gt;
         &lt;version&gt;${eclipse.jdt.core.compiler.ecj.version}&lt;/version&gt;
      &lt;/dependency&gt;
   &lt;/dependencies&gt;
&lt;/plugin&gt;</code></pre>
</div>
</div>
</div>
</div>
</div>]]></description><link>https://tcollignon.github.io/2016/12/04/How-to-compile-JSP-with-Tomcat-and-Maven-faster.html</link><guid isPermaLink="true">https://tcollignon.github.io/2016/12/04/How-to-compile-JSP-with-Tomcat-and-Maven-faster.html</guid><category><![CDATA[Tomcat]]></category><category><![CDATA[JSP]]></category><category><![CDATA[Maven]]></category><dc:creator><![CDATA[COLLIGNON Thomas]]></dc:creator><pubDate>Sun, 04 Dec 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Unable to locate site descriptor : maven-site-plugin problem]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>If you run maven-site-plugin in project with inheritance, you may be confronted to this error :</p>
</div>
<div class="listingblock">
<div class="content">
<pre>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.4:site (default-site) on project XXXXX: SiteToolException: The site descriptor cannot be resolved from the repository:
ArtifactResolutionException: Unable to locate site descriptor: Could not transfer artifact [PARENT-PROJECT]:xml:site_en:&lt;version&gt;</pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_explanations">Explanations</h2>
<div class="sectionbody">
<div class="paragraph">
<p>When maven-site-plugin is located in project with inheritence, it search the parent projet descriptor in order to manage optionnal inheritence in descriptor file (<em>site.xml</em>). So it search in the repository this kind of file : <strong>&lt;parent.artifactId&gt;-&lt;parent.version&gt;-site_&lt;lang&gt;.xml</strong></p>
</div>
<div class="paragraph">
<p>Since Maven 3.X in project of type pom, the site descriptor is no longer attached to the project. So it will not be installed or deployed by Maven. So by default, you will never find parent descriptor in the repository. However you don&#8217;t get always the previous error.</p>
</div>
<div class="paragraph">
<p>Indeed, maven-site-plugin will try to search the parent descriptor in every repository you defined in maven configuration (<em>settings.xml</em>), and if it don&#8217;t find, it will exit without error.</p>
</div>
<div class="paragraph">
<p>So now, what&#8217;s the problem ?</p>
</div>
<div class="paragraph">
<p>When maven-site-plugin search in every repository, it happen that some repository is not accessible (credentials problem!), and it that case, it will fail with previous error. And the fact is, this error don&#8217;t happened on every customers of the same project. That&#8217;s because maybe are directly with Maven central for example, others are maybe with Artifactory/Nexus proxy, or something else.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_problems">Problems</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The main problem is : If I don&#8217;t want or use inheritence in descriptor why I have got this error, and what are the solutions?</p>
</div>
<div class="paragraph">
<p>The first thing is that maven-site-plugin by default don&#8217;t know if descriptor need inheritence or not. So by default if the project have a parent pom, it will search parent descriptor. Theres is no options in maven-site-plugin for now to desactivate this.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_solutions">Solutions</h2>
<div class="sectionbody">
<div class="paragraph">
<p>After reading many article of this problem and read the maven-site and descriptor documentation, I found (at least) 3 options to deal with this "feature" :</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Add parent (and parent.parent recursively if necessary) descriptor in the repository</p>
</li>
<li>
<p>Avoid repository credentials issue</p>
</li>
<li>
<p>Tell maven-site-plugin to not using inheritence in descriptor</p>
</li>
</ol>
</div>
<div class="sect2">
<h3 id="_add_parent_descriptor_in_the_repository">Add parent descriptor in the repository</h3>
<div class="paragraph">
<p>To do this with Maven 3.X, you need to attach the descriptor in the parent projet, in order to deploy it. You need to add a site descriptor (even empty) in the parent project (src/site/site.xml). And after that you need to call <strong>attach-descriptor</strong> goal. You can bind this goal in the parent pom by default. See this documentation if you need more informations : <a href="https://maven.apache.org/plugins/maven-site-plugin/attach-descriptor-mojo.html" class="bare">https://maven.apache.org/plugins/maven-site-plugin/attach-descriptor-mojo.html</a></p>
</div>
<div class="paragraph">
<p>If you need or will need descriptor inheritence, this is the best option.</p>
</div>
</div>
<div class="sect2">
<h3 id="_avoid_repository_credentials_issue">Avoid repository credentials issue</h3>
<div class="paragraph">
<p>In fact, the main problem here is the credentials issue when maven-site-plugin try to find parent descriptor in the repositories. So to avoid the problem, you can add permissions in all of the declared repositories and all will be fine.</p>
</div>
<div class="paragraph">
<p>This is not my favourite option because sometimes you can&#8217;t or don&#8217;t want to change repository permissions. This is only a hack to get around this problem.</p>
</div>
</div>
<div class="sect2">
<h3 id="_tell_maven_site_plugin_to_not_using_inheritence">Tell maven-site-plugin to not using inheritence</h3>
<div class="paragraph">
<p>The solution I found in maven site documentation is telling to the descriptor to not use inheritence. With this option maven-site-plugin will not search parent descriptor in every repositories.
This option is <strong>combine.self</strong> with value <strong>override</strong> in project tag. See the example below :</p>
</div>
<div class="listingblock">
<div class="content">
<pre>&lt;project name="test" combine.self="override"&gt;</pre>
</div>
</div>
<div class="paragraph">
<p>This is my favourite option if you don&#8217;t need inheritence, because you don&#8217;t touch to the repository configuration and you don&#8217;t add parent descriptor with nothing inside because you don&#8217;t need it.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_links">Links</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="http://stackoverflow.com/questions/23597456/how-to-avoid-checking-parent-project-in-maven-site-plugin" class="bare">http://stackoverflow.com/questions/23597456/how-to-avoid-checking-parent-project-in-maven-site-plugin</a></p>
</li>
<li>
<p><a href="http://stackoverflow.com/questions/22215831/how-do-i-get-maven-site-descriptors-to-deploy-to-artifactory" class="bare">http://stackoverflow.com/questions/22215831/how-do-i-get-maven-site-descriptors-to-deploy-to-artifactory</a></p>
</li>
</ul>
</div>
</div>
</div>]]></description><link>https://tcollignon.github.io/2016/10/24/Unable-to-locate-site-descriptor-maven-site-plugin-problem.html</link><guid isPermaLink="true">https://tcollignon.github.io/2016/10/24/Unable-to-locate-site-descriptor-maven-site-plugin-problem.html</guid><category><![CDATA[Maven]]></category><dc:creator><![CDATA[COLLIGNON Thomas]]></dc:creator><pubDate>Mon, 24 Oct 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Accelerate tomcat 7/8 start-up]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>As it mentionned in this excellent article : <a href="https://wiki.apache.org/tomcat/HowTo/FasterStartUp" class="bare">https://wiki.apache.org/tomcat/HowTo/FasterStartUp</a>, tomcat will be very faster to start-up if you add some parameter to the out-of-the-box version.</p>
</div>
<div class="paragraph">
<p>This table show How-To accomplished each case in Tomcat 7 or Tomcat 8 :</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Tomcat 7</th>
<th class="tableblock halign-left valign-top">Tomcat 8</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Disable scanning webapp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">web.xml</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">web.xml</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Disable scanning web-fragment jar</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">web.xml</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">web.xml</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Excludes jars for scanning</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">system properties only</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">system properties or element in context</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Disable WebSocket support</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">element in context</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">element in context</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Disable JSP support</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">not available</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">element in context</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Reduce SecureRandom instance</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">jvm option</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">jvm option</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Now see some examples to each case</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configure_web_xml">Configure web.xml</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_disable_scanning_the_web_application">Disable scanning the web application</h3>
<div class="paragraph">
<p>Put metadata-complete attribute to web-app tag.</p>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>&lt;web-app <strong>metadata-complete="true"</strong>&gt;</p>
</div>
<div class="paragraph">
<p>&#8230;&#8203;</p>
</div>
<div class="paragraph">
<p>&lt;/web-app&gt;</p>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_disable_scanning_web_fragment_jar">Disable scanning web-fragment jar</h3>
<div class="paragraph">
<p>Add absolute-ordering tag</p>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>&lt;web-app&gt;</p>
</div>
<div class="paragraph">
<p><strong>&lt;absolute-ordering /&gt;</strong></p>
</div>
<div class="paragraph">
<p>&lt;/web-app&gt;</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configure_context">Configure context</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There is 2 way to do this, regarding how the application is deployed :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>If the application is packaging with the classic way (WAR for example)</p>
<div class="ulist">
<ul>
<li>
<p>this can be in META-INF/context.xml of the application</p>
</li>
</ul>
</div>
</li>
<li>
<p>If the application is deployed with Tomcat 7 VirtualWebApp concept or Tomcat 8 Resources mecanism (see <a href="https://tcollignon.github.io/2015/05/08/How-to-use-tomcat-8-Resources-to-setup-web-application.html">this article</a> for more explanations)</p>
<div class="ulist">
<ul>
<li>
<p>this can be in server.xml file under the <em>&lt;Host&gt;</em> who defined the application</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_excludes_jars_for_scanning">Excludes jars for scanning</h3>
<div class="paragraph">
<p>Add JarScanner tag</p>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>&lt;Context&gt;</p>
</div>
<div class="paragraph">
<p><strong>&lt;JarScanner&gt;</strong></p>
</div>
<div class="paragraph">
<p><strong>&lt;JarScanFilter defaultTldScan="false"/&gt;</strong></p>
</div>
<div class="paragraph">
<p><strong>&lt;/JarScanner&gt;</strong></p>
</div>
<div class="paragraph">
<p>&lt;/Context&gt;</p>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_disable_websocket_support">Disable WebSocket support</h3>
<div class="paragraph">
<p>Put containerSciFilter attribute to Context tag</p>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>&lt;Context <strong>containerSciFilter="org.apache.tomcat.websocket.server.WsSci"</strong>&gt;</p>
</div>
<div class="paragraph">
<p>&#8230;&#8203;</p>
</div>
<div class="paragraph">
<p>&lt;/Context&gt;</p>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_disable_jsp_support_only_tomcat_8">Disable JSP support (only tomcat 8)</h3>
<div class="paragraph">
<p>Put containerSciFilter attribute to Context tag</p>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>&lt;Context <strong>containerSciFilter="org.apache.jasper.servlet.JasperInitializer"</strong>&gt;</p>
</div>
<div class="paragraph">
<p>&#8230;&#8203;</p>
</div>
<div class="paragraph">
<p>&lt;/Context&gt;</p>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_disable_both_websocket_and_jsp_support_only_tomcat_8">Disable both WebSocket and JSP support (only tomcat 8)</h3>
<div class="paragraph">
<p>Put containerSciFilter attribute to Context tag with RegExp</p>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>&lt;Context <strong>containerSciFilter="org.apache.tomcat.websocket.server.WsSci|org.apache.jasper.servlet.JasperInitializer"</strong>&gt;</p>
</div>
<div class="paragraph">
<p>&#8230;&#8203;</p>
</div>
<div class="paragraph">
<p>&lt;/Context&gt;</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configure_jvm">Configure JVM</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_reduce_securerandom_instance_to_generate_random">Reduce SecureRandom instance to generate random</h3>
<div class="paragraph">
<p>Set this option in the JVM who launch Tomcat (e.g. in <em>JAVA_OPTS</em> or <em>CATALINA_OPTS</em> environnment variable)</p>
</div>
<div class="listingblock">
<div class="content">
<pre>-Djava.security.egd=file:/dev/./urandom</pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_some_performance_tests_examples">Some performance tests examples</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This tests are being executed on a simple web application with one REST service based on CXF and Spring.</p>
</div>
<div class="paragraph">
<p>This is not a real benchmark, it&#8217;s just for illustrate each options.</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"></th>
<th class="tableblock halign-left valign-top">Tomcat 8 with WAR</th>
<th class="tableblock halign-left valign-top">Tomcat 8 with Resources</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">out of the box</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">4647ms</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">7036ms</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Disable scanning webapp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">4611ms</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">6968ms</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Disable scanning web-fragment jar</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3898ms</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">5493ms</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Excludes jars for scanning</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3827ms</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">5343ms</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Disable WebSocket support</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3782ms</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3777ms</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Disable JSP support</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Not tested</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3760ms</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Reduce SecureRandom instance</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Not tested</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Not tested</p></td>
</tr>
</tbody>
</table>
<div class="ulist">
<ul>
<li>
<p>Tomcat 8 WAR</p>
<div class="ulist">
<ul>
<li>
<p>Start at <strong>4647ms</strong> to <strong>3782ms</strong></p>
</li>
</ul>
</div>
</li>
<li>
<p>Tomcat 8 Resources</p>
<div class="ulist">
<ul>
<li>
<p>Start at <strong>7036ms</strong> to <strong>3760ms</strong></p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>]]></description><link>https://tcollignon.github.io/2016/02/09/Accelerate-tomcat-78-start-up.html</link><guid isPermaLink="true">https://tcollignon.github.io/2016/02/09/Accelerate-tomcat-78-start-up.html</guid><category><![CDATA[Tomcat]]></category><dc:creator><![CDATA[COLLIGNON Thomas]]></dc:creator><pubDate>Tue, 09 Feb 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[How-to use tomcat 8 Resources to setup web application]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>This mecanism allow user to start webapp in tomcat 8 without packaging (like WAR).</p>
</div>
<div class="paragraph">
<p>This is interesting in development, to run application as fast as possible.</p>
</div>
<div class="paragraph">
<p>In Tomcat 6x, 7x this is called <em>Virtual Web App</em>, in Tomcat 8x there is a new way to do this : Resources</p>
</div>
<div class="paragraph">
<p>Documentation about Tomcat Resources is here : <a href="https://tomcat.apache.org/tomcat-8.0-doc/config/resources.html" class="bare">https://tomcat.apache.org/tomcat-8.0-doc/config/resources.html</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_write_the_configuration">Write the configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To use this, it&#8217;s necessary to write webapp configuration in tomcat <em>server.xml</em> file.</p>
</div>
<div class="paragraph">
<p>This is an example for an application with some jars, java classes and web parts (jsp and web.xml).</p>
</div>
<div class="paragraph">
<p>The structure of application in the repository is :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>testWebapp</p>
<div class="ulist">
<ul>
<li>
<p>src/main/java</p>
<div class="ulist">
<ul>
<li>
<p>some java files</p>
</li>
</ul>
</div>
</li>
<li>
<p>src/main/webapp</p>
<div class="ulist">
<ul>
<li>
<p>somes jsp</p>
</li>
<li>
<p>WEB-INF/web.xml</p>
</li>
</ul>
</div>
</li>
<li>
<p>pom.xml <em>with jar dependencies</em> (hibernate for example)</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>Classic way will packaging a WAR file with this structure :</p>
</div>
<div class="ulist">
<ul>
<li>
<p>META-INF</p>
</li>
<li>
<p>WEB-INF</p>
<div class="ulist">
<ul>
<li>
<p>classes <em>(contains .class files)</em></p>
</li>
<li>
<p>lib <em>(contains .jar files)</em></p>
</li>
<li>
<p>web.xml</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>With tomcat resources, we package nothing, and just write into server.xml file :</p>
</div>
<div class="listingblock">
<div class="content">
<pre>&lt;Context docBase="/tmp/testWebapp/src/main/webapp" path="/testWebapp" reloadable="false"&gt;
 &lt;Resources&gt;
  &lt;PostResources base="/tmp/testWebapp/target/classes"
                className="org.apache.catalina.webresources.DirResourceSet"
                webAppMount="/WEB-INF/classes"/&gt;
  &lt;PostResources base="/Work/mavenRepository/org/hibernate/hibernate-core/4.3.7.Final/hibernate-core-4.3.7.Final.jar"
                className="org.apache.catalina.webresources.JarResourceSet"
                webAppMount="/WEB-INF/classes"/&gt;
 &lt;/Resources&gt;
&lt;/Context&gt;</pre>
</div>
</div>
<div class="paragraph">
<p>The order of each <em>Resources</em> declaration is important for the tomcat classloader.</p>
</div>
<div class="paragraph">
<p>It&#8217;s surprising to mount jar in <em>WEB-INF/classes</em> instead of <em>WEB-INF/lib</em>, but this is the only way I found to make it work correctly with <em>JarResourceSet</em>. The next configuration is dangerous, because it&#8217;s not link the right jar, and cause wrong loading in application, I suggest to not using this :</p>
</div>
<div class="listingblock">
<div class="content">
<pre>&lt;Context docBase="/tmp/testWebapp/src/main/webapp" path="/testWebapp" reloadable="false"&gt;
 &lt;Resources&gt;
  &lt;PostResources base="/tmp/testWebapp/target/classes"
                className="org.apache.catalina.webresources.DirResourceSet"
                webAppMount="/WEB-INF/classes"/&gt;
  &lt;PostResources base="/Work/mavenRepository/org/hibernate/hibernate-core/4.3.7.Final"
                className="org.apache.catalina.webresources.DirResourceSet"
                webAppMount="/WEB-INF/lib"/&gt;
 &lt;/Resources&gt;
&lt;/Context&gt;</pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_who_use_this">Who use this ?</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://github.com/tesla/m2eclipse-webby">Webby</a> use <a href="https://codehaus-cargo.github.io/cargo/Home.html">cargo</a> with Virtual Web App concept to run application in eclipse.</p>
</div>
<div class="paragraph">
<p>This is pretty faster than other way (like WTP), because it pick-up jars in Maven local repository, and will not paste each jar in temporay folder. Each jar is declared in tomcat <em>server.xml</em> configuration file.</p>
</div>
</div>
</div>]]></description><link>https://tcollignon.github.io/2015/05/08/How-to-use-tomcat-8-Resources-to-setup-web-application.html</link><guid isPermaLink="true">https://tcollignon.github.io/2015/05/08/How-to-use-tomcat-8-Resources-to-setup-web-application.html</guid><category><![CDATA[Tomcat]]></category><dc:creator><![CDATA[COLLIGNON Thomas]]></dc:creator><pubDate>Fri, 08 May 2015 00:00:00 GMT</pubDate></item></channel></rss>