<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jvm Archives | Clever Cloud</title>
	<atom:link href="https://stagingv6.cleverapps.io/blog/tag/jvm/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>From Code to Product</description>
	<lastBuildDate>Mon, 15 Apr 2019 18:45:00 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2023/03/cropped-cropped-favicon-32x32.png</url>
	<title>jvm Archives | Clever Cloud</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>GraalVM is here!</title>
		<link>https://stagingv6.cleverapps.io/blog/features/2019/04/15/release-graalvm/</link>
		
		<dc:creator><![CDATA[Laurent Doguin]]></dc:creator>
		<pubDate>Mon, 15 Apr 2019 18:45:00 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[cloud native]]></category>
		<category><![CDATA[graalvm]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[openjdk]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2019/04/15/release-graalvm/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" fetchpriority="high" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><p>Good news everone, we are all super happy to tell you our JVM image has been updated substantialy. We now support OpenJDK 12 and GraalVM CE!</p>
<span id="more-2956"></span>

<p>If you follow what&#39;s going on in the JVM space you have seen there is more and more choices available when it comes to running JVM-based applications. And we now support GraalVM CE. If you have no idea what it is, the best, simple explaination can be found on Julien Ponge&#39;s medium: <a href="https://medium.com/@jponge/the-graalvm-frenzy-f54257f5932c">https://medium.com/@jponge/the-graalvm-frenzy-f54257f5932c</a></p>
<p>And as he explains that way better than I, I will jump into the how to run a GraalVM application on Clever Cloud.</p>
<p>We first need to find an appropriate Hello world project. Being a Ratpack fan I looked on Github and found this: <a href="https://github.com/wololock/ratpack-graalvm-demo">https://github.com/wololock/ratpack-graalvm-demo</a></p>
<p>This is a gradle project with a script to build a native image, basically a binary with everything needed to run the application. No need for a JVM. So this is what we are going to build.</p>
<p>First to create the application, if you have clever-tools you can run: <code>clever create --type gradle --plan M graalPack</code> Now we need to setup the right environment variables.</p>
<pre><code class="language-bash">clever env set CC_JAVA_VERSION graalvm-ce  # Select GraalVN CE as Java Version
clever env set GRADLE_DEPLOY_GOAL shadowJar # Specify the gradle goal, here we want to build a full jar.
clever env set CC_PRE_RUN_HOOK ./build-native-image.sh # run the native image build
clever env set CC_RUN_COMMAND ./ratpack-graalvm-demo # specify the path of the native executable
</code></pre>
<p>I have modified a couple of things to make sure it would work smoothly on Clever Cloud. First thing, always define a rootProject name because gradle will pick the containing folder, which in our case the random application id, and generate the jar name with it. So you can&#39;t really use it in a script. Here&#39;s one liner to do it: <code>echo &#39;rootProject.name = &quot;ratpack-graalvm-demo&quot;&#39; &gt; settings.gradle</code></p>
<p>The script already run <code>gradlew shadowJar</code>. I have removed it since this step is already made by Clever Cloud. Of course you could run it locally and only push the executable. This would also work.</p>
<p>Don&#39;t forget to add these changes to your git repository: <code>git add settings.gradle build-native-image.sh &amp;&amp; git commit -m&quot;cleverify&quot;</code></p>
<p>We are building a native image and this can be a super greedy process in terms of memory. To make sure we have some headroom we are going to use a bigger scaler. Run <code>clever scale --flavor L</code> to get the proper size. This might depend on the build you are running. Static analysis is not cheap. Later this week we&#39;ll show you how to proceed differently with a new CI project :) But for now we&#39;ll stick to a bigger scaler.</p>
<p>Now all you have to do is run <code>clever deploy</code> and you will have your native image running on Clever Cloud. Benefits are mostly a reduced memory footprint and better performances at cold start. You can find more informations about this on the following blog post <a href="https://e.printstacktrace.blog/ratpack-graalvm-how-to-start/">Ratpack on GraalVM - how to start?</a>.</p>
<p>In the next days you can expect support for cool GraalVM features like the support for <a href="https://github.com/oracle/truffleruby">TruffelRuby</a> or <a href="https://github.com/oracle/fastr">FastR</a>). Let us know if you have any questions in the comments below!</p>
]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/graalvm-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><p>Good news everone, we are all super happy to tell you our JVM image has been updated substantialy. We now support OpenJDK 12 and GraalVM CE!</p>
<span id="more-2956"></span>

<p>If you follow what&#39;s going on in the JVM space you have seen there is more and more choices available when it comes to running JVM-based applications. And we now support GraalVM CE. If you have no idea what it is, the best, simple explaination can be found on Julien Ponge&#39;s medium: <a href="https://medium.com/@jponge/the-graalvm-frenzy-f54257f5932c">https://medium.com/@jponge/the-graalvm-frenzy-f54257f5932c</a></p>
<p>And as he explains that way better than I, I will jump into the how to run a GraalVM application on Clever Cloud.</p>
<p>We first need to find an appropriate Hello world project. Being a Ratpack fan I looked on Github and found this: <a href="https://github.com/wololock/ratpack-graalvm-demo">https://github.com/wololock/ratpack-graalvm-demo</a></p>
<p>This is a gradle project with a script to build a native image, basically a binary with everything needed to run the application. No need for a JVM. So this is what we are going to build.</p>
<p>First to create the application, if you have clever-tools you can run: <code>clever create --type gradle --plan M graalPack</code> Now we need to setup the right environment variables.</p>
<pre><code class="language-bash">clever env set CC_JAVA_VERSION graalvm-ce  # Select GraalVN CE as Java Version
clever env set GRADLE_DEPLOY_GOAL shadowJar # Specify the gradle goal, here we want to build a full jar.
clever env set CC_PRE_RUN_HOOK ./build-native-image.sh # run the native image build
clever env set CC_RUN_COMMAND ./ratpack-graalvm-demo # specify the path of the native executable
</code></pre>
<p>I have modified a couple of things to make sure it would work smoothly on Clever Cloud. First thing, always define a rootProject name because gradle will pick the containing folder, which in our case the random application id, and generate the jar name with it. So you can&#39;t really use it in a script. Here&#39;s one liner to do it: <code>echo &#39;rootProject.name = &quot;ratpack-graalvm-demo&quot;&#39; &gt; settings.gradle</code></p>
<p>The script already run <code>gradlew shadowJar</code>. I have removed it since this step is already made by Clever Cloud. Of course you could run it locally and only push the executable. This would also work.</p>
<p>Don&#39;t forget to add these changes to your git repository: <code>git add settings.gradle build-native-image.sh &amp;&amp; git commit -m&quot;cleverify&quot;</code></p>
<p>We are building a native image and this can be a super greedy process in terms of memory. To make sure we have some headroom we are going to use a bigger scaler. Run <code>clever scale --flavor L</code> to get the proper size. This might depend on the build you are running. Static analysis is not cheap. Later this week we&#39;ll show you how to proceed differently with a new CI project :) But for now we&#39;ll stick to a bigger scaler.</p>
<p>Now all you have to do is run <code>clever deploy</code> and you will have your native image running on Clever Cloud. Benefits are mostly a reduced memory footprint and better performances at cold start. You can find more informations about this on the following blog post <a href="https://e.printstacktrace.blog/ratpack-graalvm-how-to-start/">Ratpack on GraalVM - how to start?</a>.</p>
<p>In the next days you can expect support for cool GraalVM features like the support for <a href="https://github.com/oracle/truffleruby">TruffelRuby</a> or <a href="https://github.com/oracle/fastr">FastR</a>). Let us know if you have any questions in the comments below!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>One Framework a Day keeps the Boredom Away: Vert-X Golo</title>
		<link>https://stagingv6.cleverapps.io/blog/features/2017/10/17/1fdba-vertx-golo/</link>
		
		<dc:creator><![CDATA[Laurent Doguin]]></dc:creator>
		<pubDate>Tue, 17 Oct 2017 17:15:00 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[1fdba]]></category>
		<category><![CDATA[golo]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[vertx]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2017/10/17/1fdba-vertx-golo/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><p>Welcome to this new edition of <a href="/blog/features/2017/10/09/1fdba-step0/">One Framework a Day keeps the Boredom Away</a>. In this series I will show you how to deploy a particular framework on Clever Cloud every day until I want to go back to boredom. Today it&#39;s about Vert-x and Golo.</p>
<span id="more-2911"></span>

<p>In each post of this series we&#39;ll see how to deploy a particular framework on Clever Cloud. Today we are taking a look at <a href="http://vertx.io/">Vert-x</a> and <a href="http://golo-lang.org/">Golo</a>.</p>
<p>If you want to tag along, make sure you have git, a Clever Cloud account and that you have installed our CLI <a href="https://github.com/CleverCloud/clever-tools">Clever-Tools</a>.</p>
<h2 id="what-is-vert-x">What is Vert-x?</h2>
<p>Eclipse Vert.x is a tool-kit for building reactive applications on the JVM.</p>
<p>And when they write JVM, they mean it. You can use any JVM language. Beyond the polyglot statement, you will find out that it&#39;s also <em>event driven</em> and <em>non blocking</em>. Which means it&#39;s ready to scale and will use your hardware as much as possible. It&#39;s reactive. I invite you to read the <a href="https://www.reactivemanifesto.org/">Reactive Manifesto</a> if you have no idea what it is. Vert-x is unopinionated and as such is a good fit for any kind of application or microservice. Here we will use it to build an API.  </p>
<h2 id="what-is-golo">What is Golo</h2>
<p>A lightweight dynamic language for the JVM.</p>
<p>You can install Golo with a standalone binary available on <a href="http://golo-lang.org/download/">their website</a>. It&#39;s important because today we will also look at how to create a Golo project from scrach instead of using an existing one. All of this is happening thanks to our CSO Philippe Charrière who previously blogged on this subject, check out <a href="https://medium.com/@k33g_org/">his blog</a>!</p>
<h2 id="create-a-golo-project">Create a Golo Project</h2>
<p>In a terminal, type these commands:</p>
<pre><code class="language-bash">golo new vertx.golo.demo --type maven
cd vertx.golo.demo
</code></pre>
<p>The Golo CLI has generated a Golo project:</p>
<pre><code class="language-bash">.
├── pom.xml
├── src
│   └── main
│       └── golo
│           └── main.golo
</code></pre>
<p>To make sure you can compile the project, you have to update the pom.xml file: Change the Golo version by replacing</p>
<pre><code class="language-xml">  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;golo.version&gt;3.2.0-SNAPSHOT&lt;/golo.version&gt;
  &lt;/properties&gt;
</code></pre>
<p>with:</p>
<pre><code class="language-xml">  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;golo.version&gt;3.2.0&lt;/golo.version&gt;
    &lt;vertx.version&gt;3.4.1&lt;/vertx.version&gt;
  &lt;/properties&gt;
</code></pre>
<p>Add some dependencies and the bintray repository:</p>
<pre><code class="language-xml">  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.eclipse.golo&lt;/groupId&gt;
      &lt;artifactId&gt;golo&lt;/artifactId&gt;
      &lt;version&gt;${golo.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;com.googlecode.json-simple&lt;/groupId&gt;
      &lt;artifactId&gt;json-simple&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;io.vertx&lt;/groupId&gt;
      &lt;artifactId&gt;vertx-core&lt;/artifactId&gt;
      &lt;version&gt;${vertx.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;io.vertx&lt;/groupId&gt;
      &lt;artifactId&gt;vertx-web&lt;/artifactId&gt;
      &lt;version&gt;${vertx.version}&lt;/version&gt;
    &lt;/dependency&gt;

  &lt;/dependencies&gt;

  &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;bintray&lt;/id&gt;
      &lt;name&gt;Bintray&lt;/name&gt;
      &lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
    &lt;/repository&gt;
  &lt;/repositories&gt;

  &lt;pluginRepositories&gt;
    &lt;pluginRepository&gt;
      &lt;id&gt;bintray&lt;/id&gt;
      &lt;name&gt;Bintray&lt;/name&gt;
      &lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
    &lt;/pluginRepository&gt;
  &lt;/pluginRepositories&gt;
</code></pre>
<p>We are going to write a very simple Vert-x web application with Golo. For that, replace the content of <code>/src/main/golo/main.golo</code> with this:</p>
<pre><code class="language-go">module vertx.golo.demo

import io.vertx.core.Vertx
import io.vertx.core.http.HttpServer
import io.vertx.ext.web.Router
import io.vertx.ext.web.handler

import gololang.JSON

let vertx = Vertx.vertx()

function main = |args| {

  let server = vertx: createHttpServer()
  let router = Router.router(vertx)
  router: route(): handler(BodyHandler.create())

  let port =  Integer.parseInt(System.getenv(): get(&quot;PORT&quot;) orIfNull &quot;8080&quot;)

  router: get(&quot;/&quot;): handler(|context| {
    context: response(): putHeader(&quot;content-type&quot;, &quot;text/html;charset=UTF-8&quot;)
    context: response(): end(&quot;&lt;h1&gt;Hello 🌍&lt;/h1&gt;&quot;, &quot;UTF-8&quot;)
  })

  router: get(&quot;/hi&quot;): handler(|context| {
    context: response(): putHeader(&quot;content-type&quot;, &quot;application/json;charset=UTF-8&quot;)
    context: response(): end(JSON.stringify(DynamicObject(): message(&quot;Hi 😛&quot;)), &quot;UTF-8&quot;)
  })

  server: requestHandler(|httpRequest| -&gt; router: accept(httpRequest)): listen(port)

  println(&quot;listening on &quot; + port)
}
</code></pre>
<p>To test the application:</p>
<ul>
<li>Built it with: <code>mvn package</code></li>
<li>Run it with: <code>mvn exec:java</code></li>
<li>Test your web application by opening <code>http://localhost:8080</code> and <code>http://localhost:8080/hi</code></li>
</ul>
<p>If it works locally then you are ready for the next step. Set it up for Clever Cloud.</p>
<h2 id="setup">Setup</h2>
<p>Clever Cloud can run any JVM code packaged as a <em>.war</em> or <em>.jar</em>. You can either checkout those files directly in your Github repository or have them built with Maven or Gradle. In this case it&#39;s a Maven build that generates a <em>.jar</em> file from some Golo code. So when we create the application we have to select maven as type: <code>clever create --type maven vertx-golo-sample</code></p>
<p>The only configurable thing is the port of the server. It defaults to 8080 in the code. It&#39;s also the case for each application running on Clever Cloud as it is required. So nothing to change here, we are ready to deploy.</p>
<h2 id="deploy">Deploy</h2>
<p>To make our Maven buikd work we need to state which build goal is needed and where is the <em>.jar</em> file to run. To do so create in your project directory a <code>clevercloud</code> directory with a <code>jar.json</code> file containing:</p>
<pre><code class="language-json">{
  &quot;build&quot;: {
    &quot;type&quot;: &quot;maven&quot;,
    &quot;goal&quot;: &quot;package&quot;
  },
  &quot;deploy&quot;: {
    &quot;jarName&quot;: &quot;target/vertx.golo.demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar&quot;
  }
}
</code></pre>
<p>It configures your application to run <code>mvn package</code> then <code>java -jar target/vertx.golo.demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar</code>.</p>
<p>The last step to deploy it is to initiate an empty git repository, add and commit your code, then deploy it:</p>
<pre><code class="language-bash">git init
git add src/ pom.xml clevercloud/
git commit -m &quot;first version&quot;
clever deploy
</code></pre>
<p>What <code>clever deploy</code> does is pushing your code to a remote git branch that was created when you created the application in the setup step. Right now you should start seeing build logs in the console. If everything worked well run <code>clever open</code>. It will take you straight to your web application and display Hello 🌍!</p>
]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-golo-vertx-1-1368x528.png 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p><p>Welcome to this new edition of <a href="/blog/features/2017/10/09/1fdba-step0/">One Framework a Day keeps the Boredom Away</a>. In this series I will show you how to deploy a particular framework on Clever Cloud every day until I want to go back to boredom. Today it&#39;s about Vert-x and Golo.</p>
<span id="more-2911"></span>

<p>In each post of this series we&#39;ll see how to deploy a particular framework on Clever Cloud. Today we are taking a look at <a href="http://vertx.io/">Vert-x</a> and <a href="http://golo-lang.org/">Golo</a>.</p>
<p>If you want to tag along, make sure you have git, a Clever Cloud account and that you have installed our CLI <a href="https://github.com/CleverCloud/clever-tools">Clever-Tools</a>.</p>
<h2 id="what-is-vert-x">What is Vert-x?</h2>
<p>Eclipse Vert.x is a tool-kit for building reactive applications on the JVM.</p>
<p>And when they write JVM, they mean it. You can use any JVM language. Beyond the polyglot statement, you will find out that it&#39;s also <em>event driven</em> and <em>non blocking</em>. Which means it&#39;s ready to scale and will use your hardware as much as possible. It&#39;s reactive. I invite you to read the <a href="https://www.reactivemanifesto.org/">Reactive Manifesto</a> if you have no idea what it is. Vert-x is unopinionated and as such is a good fit for any kind of application or microservice. Here we will use it to build an API.  </p>
<h2 id="what-is-golo">What is Golo</h2>
<p>A lightweight dynamic language for the JVM.</p>
<p>You can install Golo with a standalone binary available on <a href="http://golo-lang.org/download/">their website</a>. It&#39;s important because today we will also look at how to create a Golo project from scrach instead of using an existing one. All of this is happening thanks to our CSO Philippe Charrière who previously blogged on this subject, check out <a href="https://medium.com/@k33g_org/">his blog</a>!</p>
<h2 id="create-a-golo-project">Create a Golo Project</h2>
<p>In a terminal, type these commands:</p>
<pre><code class="language-bash">golo new vertx.golo.demo --type maven
cd vertx.golo.demo
</code></pre>
<p>The Golo CLI has generated a Golo project:</p>
<pre><code class="language-bash">.
├── pom.xml
├── src
│   └── main
│       └── golo
│           └── main.golo
</code></pre>
<p>To make sure you can compile the project, you have to update the pom.xml file: Change the Golo version by replacing</p>
<pre><code class="language-xml">  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;golo.version&gt;3.2.0-SNAPSHOT&lt;/golo.version&gt;
  &lt;/properties&gt;
</code></pre>
<p>with:</p>
<pre><code class="language-xml">  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;golo.version&gt;3.2.0&lt;/golo.version&gt;
    &lt;vertx.version&gt;3.4.1&lt;/vertx.version&gt;
  &lt;/properties&gt;
</code></pre>
<p>Add some dependencies and the bintray repository:</p>
<pre><code class="language-xml">  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.eclipse.golo&lt;/groupId&gt;
      &lt;artifactId&gt;golo&lt;/artifactId&gt;
      &lt;version&gt;${golo.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;com.googlecode.json-simple&lt;/groupId&gt;
      &lt;artifactId&gt;json-simple&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;io.vertx&lt;/groupId&gt;
      &lt;artifactId&gt;vertx-core&lt;/artifactId&gt;
      &lt;version&gt;${vertx.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;io.vertx&lt;/groupId&gt;
      &lt;artifactId&gt;vertx-web&lt;/artifactId&gt;
      &lt;version&gt;${vertx.version}&lt;/version&gt;
    &lt;/dependency&gt;

  &lt;/dependencies&gt;

  &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;bintray&lt;/id&gt;
      &lt;name&gt;Bintray&lt;/name&gt;
      &lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
    &lt;/repository&gt;
  &lt;/repositories&gt;

  &lt;pluginRepositories&gt;
    &lt;pluginRepository&gt;
      &lt;id&gt;bintray&lt;/id&gt;
      &lt;name&gt;Bintray&lt;/name&gt;
      &lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
    &lt;/pluginRepository&gt;
  &lt;/pluginRepositories&gt;
</code></pre>
<p>We are going to write a very simple Vert-x web application with Golo. For that, replace the content of <code>/src/main/golo/main.golo</code> with this:</p>
<pre><code class="language-go">module vertx.golo.demo

import io.vertx.core.Vertx
import io.vertx.core.http.HttpServer
import io.vertx.ext.web.Router
import io.vertx.ext.web.handler

import gololang.JSON

let vertx = Vertx.vertx()

function main = |args| {

  let server = vertx: createHttpServer()
  let router = Router.router(vertx)
  router: route(): handler(BodyHandler.create())

  let port =  Integer.parseInt(System.getenv(): get(&quot;PORT&quot;) orIfNull &quot;8080&quot;)

  router: get(&quot;/&quot;): handler(|context| {
    context: response(): putHeader(&quot;content-type&quot;, &quot;text/html;charset=UTF-8&quot;)
    context: response(): end(&quot;&lt;h1&gt;Hello 🌍&lt;/h1&gt;&quot;, &quot;UTF-8&quot;)
  })

  router: get(&quot;/hi&quot;): handler(|context| {
    context: response(): putHeader(&quot;content-type&quot;, &quot;application/json;charset=UTF-8&quot;)
    context: response(): end(JSON.stringify(DynamicObject(): message(&quot;Hi 😛&quot;)), &quot;UTF-8&quot;)
  })

  server: requestHandler(|httpRequest| -&gt; router: accept(httpRequest)): listen(port)

  println(&quot;listening on &quot; + port)
}
</code></pre>
<p>To test the application:</p>
<ul>
<li>Built it with: <code>mvn package</code></li>
<li>Run it with: <code>mvn exec:java</code></li>
<li>Test your web application by opening <code>http://localhost:8080</code> and <code>http://localhost:8080/hi</code></li>
</ul>
<p>If it works locally then you are ready for the next step. Set it up for Clever Cloud.</p>
<h2 id="setup">Setup</h2>
<p>Clever Cloud can run any JVM code packaged as a <em>.war</em> or <em>.jar</em>. You can either checkout those files directly in your Github repository or have them built with Maven or Gradle. In this case it&#39;s a Maven build that generates a <em>.jar</em> file from some Golo code. So when we create the application we have to select maven as type: <code>clever create --type maven vertx-golo-sample</code></p>
<p>The only configurable thing is the port of the server. It defaults to 8080 in the code. It&#39;s also the case for each application running on Clever Cloud as it is required. So nothing to change here, we are ready to deploy.</p>
<h2 id="deploy">Deploy</h2>
<p>To make our Maven buikd work we need to state which build goal is needed and where is the <em>.jar</em> file to run. To do so create in your project directory a <code>clevercloud</code> directory with a <code>jar.json</code> file containing:</p>
<pre><code class="language-json">{
  &quot;build&quot;: {
    &quot;type&quot;: &quot;maven&quot;,
    &quot;goal&quot;: &quot;package&quot;
  },
  &quot;deploy&quot;: {
    &quot;jarName&quot;: &quot;target/vertx.golo.demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar&quot;
  }
}
</code></pre>
<p>It configures your application to run <code>mvn package</code> then <code>java -jar target/vertx.golo.demo-0.0.1-SNAPSHOT-jar-with-dependencies.jar</code>.</p>
<p>The last step to deploy it is to initiate an empty git repository, add and commit your code, then deploy it:</p>
<pre><code class="language-bash">git init
git add src/ pom.xml clevercloud/
git commit -m &quot;first version&quot;
clever deploy
</code></pre>
<p>What <code>clever deploy</code> does is pushing your code to a remote git branch that was created when you created the application in the setup step. Right now you should start seeing build logs in the console. If everything worked well run <code>clever open</code>. It will take you straight to your web application and display Hello 🌍!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>One Framework a Day keeps the Boredom Away: Ratpack</title>
		<link>https://stagingv6.cleverapps.io/blog/features/2017/10/12/ratpack/</link>
		
		<dc:creator><![CDATA[Laurent Doguin]]></dc:creator>
		<pubDate>Thu, 12 Oct 2017 17:15:00 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[1fdba]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[ratpack]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2017/10/12/ratpack/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1-1368x528.png 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p>Welcome to this new edition of <a href="/blog/features/2017/10/09/1fdba-step0/">One Framework a Day keeps the Boredom Away</a>. In this series I will show you how to deploy a particular framework on Clever Cloud every day until I want to go back to boredom. Today it's about Ratpack.

<span id="more-2908"></span>

In each post of this series we'll see how to deploy a particular framework on Clever Cloud. Today we are taking a look at <a href="http://ratpack.io/">Ratpack</a>.

If you want to tag along, make sure you have git, a Clever Cloud account and that you have installed our CLI <a href="https://github.com/CleverCloud/clever-tools">Clever-Tools</a>.
<h2 id="what-is-ratpack">What is Ratpack?</h2>
<blockquote>
<ul>
 	<li>Ratpack is a set of Java libraries for building modern HTTP applications.</li>
 	<li>It provides just enough for writing practical, high performance, apps.</li>
 	<li>It is built on Java 8, Netty and reactive principles.</li>
</ul>
</blockquote>
I am personally a big Ratpack fan for its simplicity. If you want to try it there are many projects already on Github. I have chosen to test one from <a href="https://github.com/danveloper">Dan Woods</a>. He wrote the book <a href="https://www.oreilly.com/library/view/learning-ratpack/9781491921654/">Learning Ratpack</a>. I encourage you to read it if you like what you see here.

He started a performance test project: <a href="https://github.com/danveloper/s1p-high-perf-microservices/">s1p-high-perf-microservices</a>. It's a microservice that includes a connection to Postgres. So let's look at how to deploy it.
<h2 id="setup">Setup</h2>
Fist step is to clone the project:<code>git clone https://github.com/danveloper/s1p-high-perf-microservices/</code>

Open it with your favorite editor. You will see it's a gradle based project, which is one of the build tool supported by Clever Cloud. Open the DBConfig class. You will see it declares the configuraiton prefix 'db'. Let's assume it's to configure PostgreSQL. Now open <code>application.yml</code>. This is where the configuration is stored in this project. So this is where we configure the DB connection. Let's create our database. You can either log to the console, use the API or use the CLI like this: <code>clever addon create postgresql-addon --plan dev --region eu ratpackPG</code>

Here I have created a Postgre instance with the dev plan in the eu region called ratpackPG. If you run <code>clever addon</code> you will see it on the list. You can also see it in the console. A database is an add-on and as such can be linked to an application. Here linking <code>ratpackPG</code> means that the configuration environment variables provided by the add-on will be injected in the linked application. We have two things left to do.
<ul>
 	<li>Create the application: <code>clever create --type gradle ratpackTest --region par</code></li>
 	<li>Link the add-on: <code>clever service link-addon ratpackPG</code></li>
</ul>
If you are following closely you'll notice that region names are different for add-ons and applications. This has to do with our will to keep our Add-ons API compatible with Heroku.

Anyway now you have an application. And if you take a look at its environment variable with <code>clever env</code>, you should see relevant variables like <code>POSTGRESQL_ADDON_DB</code>, <code>POSTGRESQL_ADDON_HOST</code>, etc… There are different ways to use them in our project.

We can edit <code>application.yml</code> so it looks like this:
<pre><code class="language-yaml">db:
  username: ${POSTGRESQL_ADDON_USER}
  password: ${POSTGRESQL_ADDON_PASSWORD}
  database: ${POSTGRESQL_ADDON_DB}
  poolSize: 4
  hostname: ${POSTGRESQL_ADDON_HOST}
  port: ${POSTGRESQL_ADDON_PORT}
</code></pre>
Using the <code>${}</code> allows us to use existing environment variables and assigned them directly to our properties. That's because this Ratpack project includes Spring and uses it to manage part of its configuration. If you do this you can easily reuse that same code base for different applications for staging, preprod, etc…

We can also directly setup new environment variables that will be picked up by Ratpack. Take a look at their <a href="https://ratpack.io/manual/current/config.html#environment_variables">documentation</a> on the matter. To setup variables with the CLI it works like this:
<pre><code class="language-bash">clever env set RATPACK_PORT 8080
clever env set db_database \${POSTGRESQL_ADDON_DB}
clever env set db_hostname \${POSTGRESQL_ADDON_HOST}
clever env set db_password \${POSTGRESQL_ADDON_PASSWORD}
clever env set db_port \${POSTGRESQL_ADDON_PORT}
clever env set db_username \${POSTGRESQL_ADDON_USER}
clever env set db_poolSize 4
</code></pre>
Since the application is doing the following SQL query:
<pre><code class="language-java">public Observable&lt;Product&gt; getProducts() {
  return pool.queryRows("select * from product").map(row -&gt; {
    Long id = row.getLong("product_id");
    String name = row.getString("name");
    String description = row.getString("description");
    Boolean available = row.getBoolean("is_available");
    BigDecimal price = row.getBigDecimal("price");
    return new Product(id, name, description, available, price);
  }).doOnError(Throwable::printStackTrace);
}
</code></pre>
We need to load data in there. Let's create a <code>data.sql</code> file with this content:
<pre><code class="language-sql">CREATE TABLE public.product (
   product_id   bigint,
   name   text,
   description   text,
   is_available   boolean,
   price   double precision
);
INSERT INTO product(product_id, name, description, is_available, price)
       VALUES (1, 'product name','product description', true, 20.00);
</code></pre>
Or run:
<pre><code class="language-bash">touch data.sql
echo "CREATE TABLE public.product (product_id   bigint,   name   text,   description   text,   is_available   boolean,   price   double precision); INSERT INTO product(product_id, name, description, is_available, price) VALUES (1, 'product name','product description', true, 20.00);" &gt; data.sql
</code></pre>
To insert it in the DB, you can do something like <code>psql -h baug3gcfk7kx1ui-postgresql.services.clever-cloud.com -p 5432 -U ukh3kcp2me9oc1rqtw7i -d baug3gcfk7kx1ui &lt; data.sql</code>. You will be prompted for the password. This command is available in the 'add-on information' page of your Postgres instance in the console.

You can also retrieve all the variables from the CLI by typing <code>clever env</code>. If you are an awk fan here's a one liner: <code>psql `clever env | awk  -F = '/POSTGRESQL_ADDON_URI/ { print $2}'` &lt; data.sql</code>
<h2 id="deploy">Deploy</h2>
You have a configured application and add-on. Time to figure out how to run it. If you run <code>gradle tasks</code> you will get the list of gradle goals you can run. One of them is <code>run</code>, which is exactly what we want to do. To configure this, you need to create a <code>clevercloud</code> folder at the root of your project and inside it create a <code>gradle.json</code> file with the following content:
<pre><code class="language-json">{
  "deploy": {
    "goal": "run"
  }
}
</code></pre>
What is left to do is to commit your pending change:
<pre><code class="language-bash">git add clevercloud/gradle.json src/main/resources/application.yml
git commit -m"add clever cloud specifics"
</code></pre>
And then deploy your project: <code>clever deploy</code>

Once the deployment is done type <code>clever open</code> to open the application in your default browser.

If you are satisfied there's a couple of other things you can do like adding a custom domain name with <code>clever domain yourcustomdomain.com</code>. scale up <code>clever scale --flavor &lt;flavor&gt;</code> or out <code>clever scale --min-instances &lt;min-instances&gt; --max-instances &lt;max-instances&gt;</code>, even setup automatic scale out <code>clever scale --min-instances &lt;min-instances&gt; --max-instances &lt;max-instances&gt;</code>. How cool is that?]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" srcset="https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1.png 1400w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1-300x116.png 300w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1-1024x395.png 1024w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1-768x296.png 768w, https://staging-cc-assetsv6.cellar-c2.services.clever-cloud.com/uploads/2021/08/1fdba-ratpack-1-1368x528.png 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p>Welcome to this new edition of <a href="/blog/features/2017/10/09/1fdba-step0/">One Framework a Day keeps the Boredom Away</a>. In this series I will show you how to deploy a particular framework on Clever Cloud every day until I want to go back to boredom. Today it's about Ratpack.

<span id="more-2908"></span>

In each post of this series we'll see how to deploy a particular framework on Clever Cloud. Today we are taking a look at <a href="http://ratpack.io/">Ratpack</a>.

If you want to tag along, make sure you have git, a Clever Cloud account and that you have installed our CLI <a href="https://github.com/CleverCloud/clever-tools">Clever-Tools</a>.
<h2 id="what-is-ratpack">What is Ratpack?</h2>
<blockquote>
<ul>
 	<li>Ratpack is a set of Java libraries for building modern HTTP applications.</li>
 	<li>It provides just enough for writing practical, high performance, apps.</li>
 	<li>It is built on Java 8, Netty and reactive principles.</li>
</ul>
</blockquote>
I am personally a big Ratpack fan for its simplicity. If you want to try it there are many projects already on Github. I have chosen to test one from <a href="https://github.com/danveloper">Dan Woods</a>. He wrote the book <a href="https://www.oreilly.com/library/view/learning-ratpack/9781491921654/">Learning Ratpack</a>. I encourage you to read it if you like what you see here.

He started a performance test project: <a href="https://github.com/danveloper/s1p-high-perf-microservices/">s1p-high-perf-microservices</a>. It's a microservice that includes a connection to Postgres. So let's look at how to deploy it.
<h2 id="setup">Setup</h2>
Fist step is to clone the project:<code>git clone https://github.com/danveloper/s1p-high-perf-microservices/</code>

Open it with your favorite editor. You will see it's a gradle based project, which is one of the build tool supported by Clever Cloud. Open the DBConfig class. You will see it declares the configuraiton prefix 'db'. Let's assume it's to configure PostgreSQL. Now open <code>application.yml</code>. This is where the configuration is stored in this project. So this is where we configure the DB connection. Let's create our database. You can either log to the console, use the API or use the CLI like this: <code>clever addon create postgresql-addon --plan dev --region eu ratpackPG</code>

Here I have created a Postgre instance with the dev plan in the eu region called ratpackPG. If you run <code>clever addon</code> you will see it on the list. You can also see it in the console. A database is an add-on and as such can be linked to an application. Here linking <code>ratpackPG</code> means that the configuration environment variables provided by the add-on will be injected in the linked application. We have two things left to do.
<ul>
 	<li>Create the application: <code>clever create --type gradle ratpackTest --region par</code></li>
 	<li>Link the add-on: <code>clever service link-addon ratpackPG</code></li>
</ul>
If you are following closely you'll notice that region names are different for add-ons and applications. This has to do with our will to keep our Add-ons API compatible with Heroku.

Anyway now you have an application. And if you take a look at its environment variable with <code>clever env</code>, you should see relevant variables like <code>POSTGRESQL_ADDON_DB</code>, <code>POSTGRESQL_ADDON_HOST</code>, etc… There are different ways to use them in our project.

We can edit <code>application.yml</code> so it looks like this:
<pre><code class="language-yaml">db:
  username: ${POSTGRESQL_ADDON_USER}
  password: ${POSTGRESQL_ADDON_PASSWORD}
  database: ${POSTGRESQL_ADDON_DB}
  poolSize: 4
  hostname: ${POSTGRESQL_ADDON_HOST}
  port: ${POSTGRESQL_ADDON_PORT}
</code></pre>
Using the <code>${}</code> allows us to use existing environment variables and assigned them directly to our properties. That's because this Ratpack project includes Spring and uses it to manage part of its configuration. If you do this you can easily reuse that same code base for different applications for staging, preprod, etc…

We can also directly setup new environment variables that will be picked up by Ratpack. Take a look at their <a href="https://ratpack.io/manual/current/config.html#environment_variables">documentation</a> on the matter. To setup variables with the CLI it works like this:
<pre><code class="language-bash">clever env set RATPACK_PORT 8080
clever env set db_database \${POSTGRESQL_ADDON_DB}
clever env set db_hostname \${POSTGRESQL_ADDON_HOST}
clever env set db_password \${POSTGRESQL_ADDON_PASSWORD}
clever env set db_port \${POSTGRESQL_ADDON_PORT}
clever env set db_username \${POSTGRESQL_ADDON_USER}
clever env set db_poolSize 4
</code></pre>
Since the application is doing the following SQL query:
<pre><code class="language-java">public Observable&lt;Product&gt; getProducts() {
  return pool.queryRows("select * from product").map(row -&gt; {
    Long id = row.getLong("product_id");
    String name = row.getString("name");
    String description = row.getString("description");
    Boolean available = row.getBoolean("is_available");
    BigDecimal price = row.getBigDecimal("price");
    return new Product(id, name, description, available, price);
  }).doOnError(Throwable::printStackTrace);
}
</code></pre>
We need to load data in there. Let's create a <code>data.sql</code> file with this content:
<pre><code class="language-sql">CREATE TABLE public.product (
   product_id   bigint,
   name   text,
   description   text,
   is_available   boolean,
   price   double precision
);
INSERT INTO product(product_id, name, description, is_available, price)
       VALUES (1, 'product name','product description', true, 20.00);
</code></pre>
Or run:
<pre><code class="language-bash">touch data.sql
echo "CREATE TABLE public.product (product_id   bigint,   name   text,   description   text,   is_available   boolean,   price   double precision); INSERT INTO product(product_id, name, description, is_available, price) VALUES (1, 'product name','product description', true, 20.00);" &gt; data.sql
</code></pre>
To insert it in the DB, you can do something like <code>psql -h baug3gcfk7kx1ui-postgresql.services.clever-cloud.com -p 5432 -U ukh3kcp2me9oc1rqtw7i -d baug3gcfk7kx1ui &lt; data.sql</code>. You will be prompted for the password. This command is available in the 'add-on information' page of your Postgres instance in the console.

You can also retrieve all the variables from the CLI by typing <code>clever env</code>. If you are an awk fan here's a one liner: <code>psql `clever env | awk  -F = '/POSTGRESQL_ADDON_URI/ { print $2}'` &lt; data.sql</code>
<h2 id="deploy">Deploy</h2>
You have a configured application and add-on. Time to figure out how to run it. If you run <code>gradle tasks</code> you will get the list of gradle goals you can run. One of them is <code>run</code>, which is exactly what we want to do. To configure this, you need to create a <code>clevercloud</code> folder at the root of your project and inside it create a <code>gradle.json</code> file with the following content:
<pre><code class="language-json">{
  "deploy": {
    "goal": "run"
  }
}
</code></pre>
What is left to do is to commit your pending change:
<pre><code class="language-bash">git add clevercloud/gradle.json src/main/resources/application.yml
git commit -m"add clever cloud specifics"
</code></pre>
And then deploy your project: <code>clever deploy</code>

Once the deployment is done type <code>clever open</code> to open the application in your default browser.

If you are satisfied there's a couple of other things you can do like adding a custom domain name with <code>clever domain yourcustomdomain.com</code>. scale up <code>clever scale --flavor &lt;flavor&gt;</code> or out <code>clever scale --min-instances &lt;min-instances&gt; --max-instances &lt;max-instances&gt;</code>, even setup automatic scale out <code>clever scale --min-instances &lt;min-instances&gt; --max-instances &lt;max-instances&gt;</code>. How cool is that?]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
