<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Java User Group (Malta) - Medium]]></title>
        <description><![CDATA[Discussing all things Java/Scala/Groovy in both startups and enterprise alike. Have a great article you would like to share? Get in touch with us! - Medium]]></description>
        <link>https://medium.com/java-user-group-malta?source=rss----f092b98ddebb---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Java User Group (Malta) - Medium</title>
            <link>https://medium.com/java-user-group-malta?source=rss----f092b98ddebb---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:43:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/java-user-group-malta" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Java Persistence’s TABLE_PER_CLASS Is Evil]]></title>
            <link>https://medium.com/java-user-group-malta/java-persistences-table-per-class-is-evil-a186d184dc3b?source=rss----f092b98ddebb---4</link>
            <guid isPermaLink="false">https://medium.com/p/a186d184dc3b</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[jpa]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[hibernate]]></category>
            <dc:creator><![CDATA[Matthew Cachia]]></dc:creator>
            <pubDate>Thu, 16 Mar 2017 20:38:08 GMT</pubDate>
            <atom:updated>2017-03-16T21:06:03.402Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>TL;DR – <a href="http://docs.oracle.com/javaee/5/api/javax/persistence/InheritanceType.html#TABLE_PER_CLASS">TABLE_PER_CLASS</a> inheritance strategy uses some of the most inefficient ways to query. Your database performance will be dragged down as the data grows — consider switching to <a href="http://docs.oracle.com/javaee/5/api/javax/persistence/InheritanceType.html#JOINED">JOINED</a>.</p><h4>Slow performance explained</h4><p>Consider a simple entity hierarchy: <em>ParentClass</em>, <em>ChildClassA</em> and <em>ChildClassB</em>.</p><pre>@Entity<br>@InheritanceStrategy(TABLE_PER_CLASS)<br>public class ParentClass {</pre><pre>  @Id<br>  public Int id;</pre><pre>  /* excluding extra code for verbosity */</pre><pre>}</pre><pre>@Entity<br>@Table(“child_a”)<br>public class ChildClassA { … }</pre><pre>@Entity<br>@Table(“child_b”)<br>public class ChildClassB { … }</pre><p>Calling a simple <strong>em.find(ParentClass.class, id)</strong> would make Hibernate generate the following native query:</p><pre>(SELECT _a.id, … FROM child_a AS _a<br> UNION<br> SELECT _b.id, … FROM AS _b) <br>WHERE id = ‘…’;</pre><p>You might have realized there are two fundamental flaws with this query:</p><ol><li><em>All</em> of the table’s data is loaded-absolutely critical to keep in mind, especially when tables have millions of records or when there is a more complex hierarchy at play.</li><li>Since the criteria is done on the <em>absolute collective</em> of the tables, all of the indices which the tables have are completely unused. Even worse, the criteria are now working against no indices!</li></ol><h4>Using JOINED as a solution</h4><p>One way to go around this is by changing the inheritance strategy to JOINED, which essentially introduces the third, parent table: <em>parent.</em></p><p>Calling <strong>em.find(ParentClass.class, id)</strong> generates a far more optimized query:</p><pre>SELECT _p.id, ..., <br>       _a.id, ..., <br>       _b.id, ... <br>  FROM parent AS _p <br>  INNER JOIN child_a AS _a on _p.id=_a.id <br>  INNER JOIN child_b AS _b on _p.id=_b.id <br>WHERE _p.id= &#39;...&#39;;</pre><p>Joining on the table’s own primary keys would link the tables together more optimal, allowing for faster querying.</p><p><strong><em>That’s all I have to say!</em></strong><em> Do you have another alternative you would like to share, or a justification on when to use TABLE_PER_CLASS? We’d be happy to know in the comments below!</em></p><p><em>No one likes another outdated article. If you feel it can be improved or keep it up-to-date, I would very much appreciate getting in touch with me over twitter </em><a href="http://www.twitter.com/mcac0006"><em>@mcac0006</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a186d184dc3b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-user-group-malta/java-persistences-table-per-class-is-evil-a186d184dc3b">Java Persistence’s TABLE_PER_CLASS Is Evil</a> was originally published in <a href="https://medium.com/java-user-group-malta">Java User Group (Malta)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Safer, Faster End-to-End Testing Using … Docker?]]></title>
            <link>https://medium.com/java-user-group-malta/safer-faster-end-to-end-testing-using-docker-ea45ac536971?source=rss----f092b98ddebb---4</link>
            <guid isPermaLink="false">https://medium.com/p/ea45ac536971</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[selenium]]></category>
            <dc:creator><![CDATA[Matthew Cachia]]></dc:creator>
            <pubDate>Wed, 02 Nov 2016 10:06:45 GMT</pubDate>
            <atom:updated>2016-11-07T12:47:19.566Z</atom:updated>
            <content:encoded><![CDATA[<p>Data garbage left by tests is arguably one of the biggest pains of End-to-End testing. One test might configure the system to exhibit a specific behaviour which might be fatal for another test case. Cleaning the data up, besides being a huge development overhead, is messy and sometimes impossible to revert</p><p>“Reset the database after each test,” one might say–but what if reinstating the database is too expensive to execute after every test? Assuming reinstating the database takes 30 seconds to complete and have roughly 200 test cases, 100 minutes of those are spent on useless database operations. <em>Can we find a faster way?</em></p><p><strong>In this article, we will see how one could use Docker to reinstate the database in every test in near-zero time.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJE8JlXlKIZp3OEgl6gzdw.jpeg" /><figcaption>Docker could get rid of your (data) garbage easily and efficiently.</figcaption></figure><h4>Your Database As A Docker Image</h4><p><em>For the purpose of this article, let’s assume that your database is a MySQL instance and your data is stored as a database dump, </em><strong><em>dump.sql</em></strong><em>.</em></p><p>We’ll need to create an image which contains your database pre-loaded and ready to be used. We start by writing the <strong>Dockerfile</strong>:</p><pre>FROM ubuntu:14.04</pre><pre>RUN apt-get update<br>RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server<br>RUN DEBIAN_FRONTEND=noninteractive apt-get -y install default-jre</pre><pre>RUN mkdir -p /tmp<br>ADD dump.sql /tmp<br>ADD init.sh /tmp</pre><pre>RUN init.sh</pre><pre>ENTRYPOINT [&quot;mysqld&quot;, &quot;--bind-address=0.0.0.0&quot;, &quot;--lower_case_table_names=1&quot;]</pre><p><strong>init.sh</strong> would help us enable the server and dump the data:</p><pre>#!bin/bash</pre><pre>echo &quot;Enabling MySQL instance ...&quot; <br>mysqld_safe &amp;</pre><pre>echo &quot;Waiting on MySQL to boot up ...&quot;<br>sleep 5</pre><pre>echo &quot;Dumping data to instance ...&quot;<br>mysql -u root &lt; dump.sql</pre><pre>echo &quot;Complete.&quot;</pre><p>So that is practically what it involves into creating the image. Just build the image …</p><pre>$ docker build -t mcac0006/testdatabase .</pre><p>… run it …</p><pre>$ docker run -it -d -p 3306:3306 --name=testdatabase mcac0006/testdatabase</pre><p>… and your database is ready to run and listen on port 3306. <strong>Of course, make sure no other service is listening on that port!</strong></p><p><em>We have built an image which contains our data, pre-loaded and ready to run instantly. Typically, it only takes a second or two for MySQL to start listening on the port. This kind of behaviour allows us to kill and re-spawn the image countless of times, super quick.</em></p><h4>Using the Image In Selenium</h4><p>Once we’re done compiling the image, we’re ready to use it. Using the image is very simple–much like how we would reset the database with each test, ‘resetting’ the database in the docker image is only a matter of killing …</p><pre>$ docker rm -f testdatabase</pre><p>… and re-spawning.</p><pre>$ docker run -it -d -p 3306:3306 --name=testdatabase mcac0006/testdatabase</pre><p>You might have figured out how to integrate this with your Selenium test. We’ll need reset the database before each test!</p><pre>public class MySeleniumTest {</pre><pre>@Before<br>   public static void init() {<br>      </pre><pre>      // let&#39;s kill the existing running container ...<br>      Runtime.<em>getRuntime</em>().exec(&quot;cmd /C start /wait docker rm -f testdatabase&quot;).waitFor();</pre><pre>      // ... and re-spawn<br>      Runtime.<em>getRuntime</em>().exec(&quot;cmd /C start /wait docker run -d -p 3336:3306 --name=testdatabase mcac0006/testdatabase&quot;).waitFor();<br>   <br>   }</pre><pre>   @Test<br>   public void test1() {<br>      ...<br>   }</pre><pre>}</pre><p><strong>That should be it</strong>! You are now able to write tests with no side-effects from other tests.</p><p><em>(Note that the following code snippet was programmed to invoke Windows commands from Java — you might want to change the syntax a little bit, depending on your OS of choice).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-1bPZ9jxtoMTElVQBiDbtA.jpeg" /></figure><p><em>No one likes another outdated article. If you feel it can be improved or keep it up-to-date, I would very much appreciate getting in touch with me over twitter @mcac0006.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea45ac536971" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-user-group-malta/safer-faster-end-to-end-testing-using-docker-ea45ac536971">Safer, Faster End-to-End Testing Using … Docker?</a> was originally published in <a href="https://medium.com/java-user-group-malta">Java User Group (Malta)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving Your MySQL Database — The Clever Way]]></title>
            <link>https://medium.com/java-user-group-malta/moving-your-mysql-database-the-clever-way-4b9fd67ffd1e?source=rss----f092b98ddebb---4</link>
            <guid isPermaLink="false">https://medium.com/p/4b9fd67ffd1e</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Matthew Cachia]]></dc:creator>
            <pubDate>Thu, 21 Apr 2016 14:59:33 GMT</pubDate>
            <atom:updated>2016-04-21T18:32:57.154Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<p>Moving Your MySQL Database — The Clever Way</p><p><em>This article explains how one could migrate a MySQL database of any size from one remote server to another in the most efficient and simplest way.</em></p><p>So efficient, even I still cannot believe how an <em>850 gigabyte</em> database has shrunk to an ultra-compressed 7<em>0 gigabytes</em> (that’s almost 92% less), without any intermediary files! And while there are myriad of techniques on how you could transfer the same data from one server to another, none of them came close to the technique explained below.</p><p><strong>Prerequisites:</strong> You’ll need SSH and MySQL access on both servers.</p><p>Starting from the source server, run the <em>mysqldump</em> process and pipe the output over to <em>gzip</em>, which ultra-compresses the data before dumping it into a file <em>dump.sql.gz</em>.</p><pre>$ mysqldump -u &lt;user&gt; --password=&lt;password&gt; &lt;database&gt; | \ <br>  gzip -9 &gt; dump.sql.gz</pre><p>Next: let’s upload! <em>rsync</em> is easy, super fast, and resumable–just in case something goes wrong. The <strong>P </strong>flag is optional, but helps you see the upload’s progress.</p><pre>$ rsync -P dump.sql.gz &lt;username&gt;@&lt;destination IP&gt;:&lt;target directory&gt;</pre><p>Once the upload is complete you are ready to access the destination server and run the below. It’s a reciprocal of the first command: uncompress the data and pass the output over to mysql to evaluate (and store your data).</p><pre>$ gunzip -c dump.sql.gz | \<br>  mysql -u &lt;user&gt; --password=&lt;password&gt; &lt;database&gt;</pre><p>And you’re done–you can now pat yourself on the back.</p><p><em>No one likes another outdated article. If you feel it can be improved or keep it up-to-date, I would very much appreciate getting in touch with me over twitter @mcac0006.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b9fd67ffd1e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-user-group-malta/moving-your-mysql-database-the-clever-way-4b9fd67ffd1e">Moving Your MySQL Database — The Clever Way</a> was originally published in <a href="https://medium.com/java-user-group-malta">Java User Group (Malta)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Yet another Spring Boot Application (Part 1)]]></title>
            <link>https://medium.com/java-user-group-malta/yet-another-spring-boot-application-part-1-a6a26d7c036d?source=rss----f092b98ddebb---4</link>
            <guid isPermaLink="false">https://medium.com/p/a6a26d7c036d</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Joseph Masini]]></dc:creator>
            <pubDate>Tue, 16 Feb 2016 21:39:33 GMT</pubDate>
            <atom:updated>2016-02-16T21:39:32.993Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Spring Boot applications seem to be gaining traction with the increase popularity of microservices. In this post, we will be covering a basic skeleton project for a Spring Boot application that simply runs with a number of default endpoints.</em></p><p>For starters, I opted for Spring’s introduction to Spring Boot as it is as concise as they get:</p><blockquote>Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. <em>[</em><a href="http://projects.spring.io/spring-boot/"><em>Source</em></a><em>]</em></blockquote><p>This is possible due to the out-of-the box support of several features from a number of modules. The latter include the ability to easily add embedded servlet containers like Tomcat and Jetty, opinionated starter POMs, possibility of configuration by Java (instead of the XML) and a number of analytics such as health checks and metrics. For more information, check out the <a href="http://projects.spring.io/spring-boot/">project website</a>.</p><h4>What will we be doing?</h4><p>In this and upcoming posts, we will create a Spring Boot application, initially an “empty” application that simply starts with some readily-available endpoints and gradually developing a fully fledged application with its own REST-based API.<em> </em>However, in this particular post we will explain the base skeleton project required, which source code can be found <a href="https://github.com/josephmasini/medium">here</a>. Briefly, we will cover:</p><ul><li>the necessary dependencies</li><li>specifying the runnable class</li><li>running the server</li><li>checking that the server works correctly</li><li>teaching a group of monkeys to play The Who’s Baba O’riley</li></ul><p>Well, maybe not the last one, but we will be covering the rest! Note that a basic understanding of Maven is assumed (if not, go to the their <a href="https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html">tutorial</a>, it is pretty straight forward for what we need here!).</p><h4>Let’s start!</h4><p>After cloning the repository for the skeleton project, we are presented with the following project structure:</p><pre>+- tutorials-springboot<br>   +- src<br>      +- main<br>         +- java<br>           +- com<br>              +- tutorials<br>                 +- springboot<br>                    -- Application.java<br>   -- pom.xml</pre><p>Starting with the project’s POM file, Spring Boot offers a parent project (<em>spring-boot-starter-parent</em>) for application to kick start development. In order to mitigate this reduced flexibility in project structure (as we might want to extend our own project parent eventually), we decide to make use of Spring Boot’s Bill of Materials or BOM for short:</p><pre>&lt;properties&gt;<br>    &lt;spring.boot.version&gt;1.3.2.RELEASE&lt;/spring.boot.version&gt;<br>&lt;/properties&gt;</pre><pre>&lt;dependencyManagement&gt;<br>    &lt;dependencies&gt;<br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-boot-dependencies&lt;/artifactId&gt;<br>            &lt;version&gt;${spring.boot.version}&lt;/version&gt;<br>            &lt;type&gt;pom&lt;/type&gt;<br>            &lt;scope&gt;import&lt;/scope&gt;<br>        &lt;/dependency&gt;<br>    &lt;/dependencies&gt;<br>&lt;/dependencyManagement&gt;</pre><p>The usage of a BOM allows the correct version dependencies in a number of opinionated POMs to be used. Further insight on Maven’s BOM concept can be found in <a href="https://medium.com/java-user-group-malta/maven-s-bill-of-materials-bom-b430ede60599#.enji817w6">this article</a>.</p><p>Now, for the Spring Boot application to run we employ three main modules:</p><ul><li><em>actuator </em>— provides a number of production-ready features, such as health verification, metrics and graceful shutdown. More extensive information can be found <a href="https://spring.io/guides/gs/actuator-service/">here</a>.</li><li><em>web </em>— includes a number of modules for the creation of a web application, Spring MVC and amongst others, handling and mapping of HTTP requests.</li><li><em>tomcat </em>—enables the usage of an embedded tomcat instance with no requirement for deployment of WAR files.</li></ul><pre>&lt;dependencies&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;<br>        &lt;scope&gt;provided&lt;/scope&gt;<br>    &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><p>Finally, we set the build to use the spring boot maven plugin, which simplifies application execution by:</p><ul><li>grouping all the jars on the classpath into one jar;</li><li>flags the runnable class by searching for the main method (public static void main); and</li><li>provides a built-in dependency resolver. [<a href="https://spring.io/guides/gs/actuator-service/">Source</a>]</li></ul><pre>&lt;build&gt;<br>    &lt;plugins&gt;<br>        &lt;plugin&gt;<br>            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;<br>        &lt;/plugin&gt;<br>    &lt;/plugins&gt;<br>&lt;/build&gt;</pre><h4>Specifying the runnable class</h4><p>Now that we have included the required dependencies, we can specify the runnable class for our Spring Boot application, specifically in <em>Application.java</em>.</p><pre>package com.tutorials.springboot;</pre><pre>...</pre><pre><strong>@SpringBootApplication</strong><br>public class <strong>Application </strong>{<br><br>    public static void main(final <strong>String</strong>[] args) {<br>        <strong>SpringApplication</strong>.<em>run</em>(<strong>Application</strong>.class, args);<br>    }<br><br>}</pre><p>We annotate our Application class with the convenience annotation <em>@SpringBootApplication, </em>which is essentially a collection of annotations that:</p><ul><li>flag the class as a source for bean definitions (<em>@Configuration</em>);</li><li>enables the addition and configuration of beans specified in the classpath and other locations to be loaded, and other property settings (<em>@EnableAutoConfiguration</em>);</li><li>and adds scanning for the current package (in our case <em>com.tutorials.springboot</em>) for other components, configurations and services (<em>@ComponentScan</em>). [<a href="https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-using-springbootapplication-annotation.html">Source</a>]</li></ul><p>Albeit empty (as we defined no custom endpoints apart from the ones provided by the actuator), we now have our Spring Boot application! We can launch the web application by running:</p><pre>mvn spring-boot:run</pre><p>Once the server has started, open the browser and go to <a href="http://localhost:8080/">localhost:8080</a>, and depending on the browser, we are “welcomed” with some form of 404 message. This is perfectly understandable, since we have not defined any business endpoints, and hence, this is handled by a default JSON response as specified by the actuator /error endpoint.</p><p>Amongst the endpoints suppled by the actuator, we can send a request to the health endpoint, <a href="http://localhost:8080/health">/health</a>, where we are greeted with minor analytics message in JSON format:</p><pre>{&quot;status&quot;:&quot;UP&quot;,&quot;diskSpace&quot;:{&quot;status&quot;:&quot;UP&quot;,&quot;total&quot;:254656139264,&quot;free&quot;:53423796224,&quot;threshold&quot;:10485760}}</pre><h4>And we’re done… from the first part!</h4><p>Well, that pretty much concludes our initial overview of Spring Boot and the first part of our application! There will be additional parts to this, and hopefully in the next part, I should be covering a basic endpoint implementation and a proper web integration test for it.</p><p>If you have any questions or requests, feel free to leave them in the comment section below!<strong>☺</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6a26d7c036d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-user-group-malta/yet-another-spring-boot-application-part-1-a6a26d7c036d">Yet another Spring Boot Application (Part 1)</a> was originally published in <a href="https://medium.com/java-user-group-malta">Java User Group (Malta)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Importing Existing Certificates Into a KeyStore Using openssl]]></title>
            <link>https://medium.com/java-user-group-malta/importing-existing-certificates-into-a-keystore-using-openssl-905d9e0b7175?source=rss----f092b98ddebb---4</link>
            <guid isPermaLink="false">https://medium.com/p/905d9e0b7175</guid>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[certificate]]></category>
            <dc:creator><![CDATA[Matthew Cachia]]></dc:creator>
            <pubDate>Sun, 31 Jan 2016 20:50:05 GMT</pubDate>
            <atom:updated>2019-02-01T07:40:34.967Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>UPDATE</strong>: I have recently come across this great article: <a href="http://www.robinhowlett.com/blog/2016/01/05/everything-you-ever-wanted-to-know-about-ssl-but-were-afraid-to-ask/">Everything You Ever Wanted to Know About SSL (but Were Afraid to Ask</a>). It is very well written–I highly recommend you give it a proper read as well.</p><p><em>If you’re like me–unfamiliar with nitty gritty details that goes on in setting up a server–and having problems importing an existing certificate to your web container, then this article might be just for you.</em></p><p><em>This article is an all-in-one which show us how to convert certificates into a Java KeyStore (JKS) from A to Z</em>, ready to be imported to your web container of choice (Tomcat, JBoss, Glassfish, and more).</p><ul><li>Certificates are typically issued by <em>Certificates Authorities (like GoSSL and COMODO)</em>, issuing bodies which are trusted and relied on by leading web browsers to verify that your website is really who it claims to be.</li><li>Certificate Authorities provide you with a <em>chain of certificates</em> to download: you would certainly have a <em>root certificate </em>and possibly one or more <em>intermediate certificate†.</em></li><li>The root certificate needs the intermediate certificates to work, and in a particular order! We’ll dive more in depth about this in the coming section(s).</li><li>Furthermore, the root certificate is typically encrypted by a KeyStore (.keystore/.jks). This is usually generated by the owner buying the certificate and is NOT stored on the issuer’s side nor recoverable if it gets lost. You may need to ask for this file.</li></ul><p><em>† The difference between root and intermediate certificates is beyond the scope of this how-to. There are great articles on the web which fully explain certificates in depth.</em></p><p>For the purpose of this article, let’s assume we have been provided the following chain certificate:</p><ul><li><strong>int1.crt</strong> and <strong>int2.crt</strong>: the two intermediate certificates,</li><li><strong>domain.crt</strong>: the root certificate, and</li><li><strong>priv.keystore</strong>: the KeyStore bearing the encryption key for domain.crt.</li></ul><h4>Verifying the Files</h4><p><em>This section helps you verify your certificates are correct. You can proceed to the next section if you’re confident the certificates are correct.</em></p><p>You can verify if a certificate is correct using <em>openssl</em>. The first intermediate certificate <em>int1.crt </em>can be easily verified:</p><pre>$ openssl verify int1.crt<br>int1.crt: OK</pre><p>‘OK’ means your certificate is valid! Now, if we were to attempt the same thing to <em>int2.crt</em>:</p><pre>$ openssl verify int2.crt<br>error 20 at 0 depth lookup:unable to get local issuer certificate</pre><p>Uh-oh, something is wrong! This generally means that <em>int2.crt</em> requires a preceding certificate (in our case, that’s <em>int1.crt</em>). However, <em>int2.crt</em> depends on <em>int1.crt</em> to be valid.</p><pre>$ openssl verify -CAfile int1.crt int2.crt<br>int2.crt: OK</pre><p>That is much better.</p><p>Now for the tricky part: your root certificate <em>domain.crt</em> depends on both intermediate certificates. We would therefore need to append both …</p><pre>$ cat int1.crt in2.crt &gt; int1int2.crt</pre><p>… and then verify the root certificate:</p><pre>$ openssl verify -CAfile int1int2.crt domain.crt<br>domain.crt: OK</pre><p>Great—your certificates are correct and you’re ready to convert the certificate into a keystore in the next section!</p><h4>Converting the certificate into a KeyStore.</h4><p>We’re almost there! You’ll need to run <em>openssl</em> to convert the certificate into a KeyStore:</p><pre>openssl pkcs12 -export -chain -CAfile int1int2.crt -in domain.crt -inkey priv.keystore -out &lt;certificate&gt;.keystore -name ssl -passout pass:&lt;password&gt;</pre><p>In laymen’s terms, the above statement is requesting to export <strong>domain.crt </strong>into a keystore <strong>&lt;cerificate&gt;.keystore</strong> by chaining with the preceding two intermediate certificates <strong>int1int2.crt</strong>.</p><p><em>Not sure from where int1int2.crt has emerged? You might want to give the previous section —Verifying the Files — a quick read.</em></p><p>Of course, change the <em>&lt;certificate&gt;</em> and the <em>&lt;password&gt;</em> placeholders to your liking. Keep the password handy as you will need it later in your web container.</p><p>That’s it — I hope that helps! You can now use your KeyStore in your web container. There are plenty of articles on how to do this online, but the following are fine examples of the two leading web containers:</p><ul><li>Apache Tomcat 8: <a href="https://tomcat.apache.org/tomcat-8.0-doc/ssl-howto.html">SSL/TLS Configuration HOW-TO</a></li><li>Wildfly 8.x/9.x: <a href="https://docs.jboss.org/author/display/WFLY8/Detailed+Configuration">Security Reams, Detailed Configuration</a></li></ul><p><em>No one likes another outdated article. If you feel it can be improved or keep it up-to-date, I would very much appreciate getting in touch with me over twitter @mcac0006.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=905d9e0b7175" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-user-group-malta/importing-existing-certificates-into-a-keystore-using-openssl-905d9e0b7175">Importing Existing Certificates Into a KeyStore Using openssl</a> was originally published in <a href="https://medium.com/java-user-group-malta">Java User Group (Malta)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maven’s Bill of Materials (BOM)]]></title>
            <link>https://medium.com/java-user-group-malta/maven-s-bill-of-materials-bom-b430ede60599?source=rss----f092b98ddebb---4</link>
            <guid isPermaLink="false">https://medium.com/p/b430ede60599</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[dependencies]]></category>
            <dc:creator><![CDATA[Matthew Cachia]]></dc:creator>
            <pubDate>Mon, 08 Jun 2015 19:58:47 GMT</pubDate>
            <atom:updated>2015-06-09T06:49:24.806Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are a regular user of Maven you might have come across a very common issue — <em>version control</em>.</p><p>Let me set some example which would probably hits closer to home (or work ☺):</p><blockquote>I’m using Spring as my app core framework — how can I keep every module in check as to which version of Spring should it use?</blockquote><p>or perhaps …</p><blockquote>We’re using JBoss 6.x as our app server — how would I know which version of hibernate is this container bundled with? Am I expected to sift through the guts of the server to find the version?</blockquote><p>Of course not. Serious tech and libraries provide you with something better: Jersey, RESTeasy, JBoss, Spring — they all provide their own BOM you could use.</p><h4>Maven is the BOMb</h4><p>That’s where <strong>Maven’s BOM (or Bill of Materials)</strong> come in. BOMs’ provides you the flexibility to add dependencies to your module without worrying on which version should you depend on.</p><p><em>Then how does it work?</em></p><blockquote>A <strong>bill of materials</strong> (<strong>BoM</strong>) is a list of the parts or components that are required to build a product.†</blockquote><p>First of all, BOMs are ordinary <em>pom.xml</em> files — they contain no source code and their only purpose is to declare their bundled modules. Think of it as a list of ingredients one would need to use in order to use that tech. Red Hat RnD would have probably said something along the lines of:</p><blockquote>We have just released JBoss EAP 6.4 for public use. These are the tech that we have provided with the app container — add the BOM to your app and you’re good to go.</blockquote><p>And indeed they did in their JBoss development guide (specifically in the <em>JBoss EAP BOMs and Quickstarts</em> section):</p><p><a href="https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Development_Guide/sect-Use_the_Maven_Repository.html#Configure_the_JBoss_Enterprise_Application_Platform_Maven_Repository_Using_the_Project_POM">2.3. Use the Maven Repository</a></p><p>What do you need to do? Declare the BOM in your <em>pom.xml</em> file (typically in your parent POM) …</p><pre>&lt;dependencyManagement&gt;</pre><pre>    ...</pre><pre>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.jboss.bom.eap&lt;/groupId&gt;<br>        &lt;artifactId&gt;jboss-javaee-6.0-with-hibernate&lt;/artifactId&gt;<br>        &lt;version&gt;6.4.0.GA&lt;/version&gt;<br>        &lt;scope&gt;import&lt;/scope&gt;<br>    &lt;/dependency&gt;<br>    <br>    ...</pre><pre>&lt;/dependencyManagement&gt;</pre><p>… and you will have all the tech within your reach.</p><p>Would you need hibernate in one of your app modules? Simples — add the following as a dependency:</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.hibernate&lt;/groupId&gt;<br>    &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;<br>    &lt;scope&gt;provided&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><p><strong>Tah dah!</strong> You will never have to worry about another version ever again. Isn’t it a little piece of heaven?</p><h4>Taking it a step further: creating your own BOM!</h4><p>Perhaps it doesn’t make much sense for small web applications, but for enterprise applications which span over hundreds of modules — you could imagine the version chaos that would ensue.</p><p>You could easily create your own BOM flavour by creating a fresh <em>pom.xml</em></p><pre>&lt;project ...&gt;<br>    ...<br>    &lt;groupId&gt;x.y.z&lt;/groupId&gt;<br>    &lt;artifactId&gt;yourapp-bom&lt;/artifactId&gt;<br>    &lt;version&gt;x.x.x&lt;/version&gt;<br>    &lt;packaging&gt;pom&lt;/packaging&gt;</pre><pre>    &lt;dependencyManagement&gt;<br>        &lt;dependencies&gt;<br>            <strong><em>&lt;!-- add your module declarations here! --&gt;</em></strong><br>        &lt;/dependencies&gt;<br>    &lt;/dependencyManagement&gt;<br>&lt;/project&gt;</pre><p>and declare the BOM in your app.</p><p>†<a href="http://searchmanufacturingerp.techtarget.com/definition/bill-of-materials-BoM">What is bill of materials (BOM) — definition from WhatIs.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b430ede60599" width="1" height="1" alt=""><hr><p><a href="https://medium.com/java-user-group-malta/maven-s-bill-of-materials-bom-b430ede60599">Maven’s Bill of Materials (BOM)</a> was originally published in <a href="https://medium.com/java-user-group-malta">Java User Group (Malta)</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>