Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Vaadin on Heroku
Hi,
Heroku is one of those Cloud platform where you can host your Java web application.
It's free if you have small needs, like for an application that only require one "dyno" and no database or a very small database.
I've made an "Hello wolrd" application that use the add-on Embed for Vaadin and run it on Heroku, with sessions stored in memcached.
Details and source code can be found in the github repository.
The deployed application can be reached at http://hello-vaadin-heroku.herokuapp.com/
Nicolas.
This was exactly what I was looking for. Thank you for the awesome tutorial! I ran into a few problems myself trying to recreate from scratch. For some reason, per Heroku logs, Heroku was not able to detect my web process. I added the Procfile and was able to build/run locally. However, Heroku was unable to detect the web process.
Procfile:
web: java -cp target/classes:target/dependency/* com.helloworld.HerokuTester.Tester
Java main():
EmbedVaadin.forApplication(MyVaadinApplication.class).openBrowser(false).withContextRootDirectory("src/main/webapp").withHttpPort(8080).start();
Thanks again for the awesome post. I am looking at utilizing this as a template for my Vaadin + Heroku projects.
+1.
Thanks again,
Clay
Hi Clay,
Sorry for the late answer, just saw your post.
If you want to test your Procfile locally, install ruby if it's not there yet, then
[indent]gem install foreman[/indent]
Then you can run "foreman start" where your Procfile is.
Also, to run on Heroku, you shouldn't specify the port yourself. Heroku, and foreman, provide the port to use in the PORT system property.
Heroku does not allow to use any other port than the one provided.
After making a few small applications, I ended up rolling out my customized embed for vaadin as a maven artifact available from maven central.
It's called vaadin-for-heroku.
I've made a blog post explaining what it does and how to use it: Deploy a Vaadin application on Heroku.
And the code is available on github.
Hi Nicolas,
Thank you for the excellent tutorial, thanks to you I was able to deploy my app.
I am only having one issue. After having pushed my app to Heroku, I run heroku logs -t and I see this ConnectException: Connection refused. I have searched on internet but could not find out how to solve it. My Vaadin project is on Github.
2015-08-28T12:10:14.552820+00:00 app[web.1]: java.net.ConnectException: Connection refused
2015-08-28T12:10:14.552927+00:00 app[web.1]: at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
2015-08-28T12:10:14.553058+00:00 app[web.1]: at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
2015-08-28T12:10:14.553198+00:00 app[web.1]: at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:399)
2015-08-28T12:10:14.553348+00:00 app[web.1]: at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:247)
2015-08-28T12:10:14.554002+00:00 app[web.1]: 2015-08-28 12:10:14.552 WARN net.spy.memcached.MemcachedConnection: Closing, and reopening {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=48, #iq=0, topRop=null, topWop=Cmd: 1 Opaque: 1 Key: 29F675258D35DC2450A240989666E7A5 Cas: 0 Exp: 3600 Flags: 2048 Data Length: 4711, toWrite=0, interested=0}, attempt 79.
2015-08-28T12:10:14.553473+00:00 app[web.1]: at net.spy.memcached.MemcachedConnection.run(MemcachedConnection.java:915)
2015-08-28T12:10:44.585258+00:00 app[web.1]: 2015-08-28 12:10:44.583 INFO net.spy.memcached.MemcachedConnection: Reconnecting {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=48, #iq=0, topRop=null, topWop=Cmd: 1 Opaque: 1 Key: 29F675258D35DC2450A240989666E7A5 Cas: 0 Exp: 3600 Flags: 2048 Data Length: 4711, toWrite=0, interested=0}
My Launcher.java class has only the main method:
public static void main(final String[] args) {
herokuServer(forApplication(SudokuforfunUI.class)).start();
}
Could you help me, please?
I recently took a look at Heroku deployment for my add-on online demo. I managed to do it relatively easily with a GitHub autodeploy and a Procfile with some changes to my main pom.xml . You can see my functioning example at http://github.com/tsuoanttila/sidemenu-addon and the live demo at http://sidemenu.herokuapp.com
Teemu Suo-Anttila: I recently took a look at Heroku deployment for my add-on online demo. I managed to do it relatively easily with a GitHub autodeploy and a Procfile with some changes to my main pom.xml . You can see my functioning example at http://github.com/tsuoanttila/sidemenu-addon and the live demo at http://sidemenu.herokuapp.com
Any chance you could write a small guide or record a video?
Hello Teemu Suo-Anttila,
Could you please tell me how you managed to get it work with Heroku?
What kind of change was needed regarding ProcFile,...,...
Many thanks
Hans Muff:
Hello Teemu Suo-Anttila,Could you please tell me how you managed to get it work with Heroku?
What kind of change was needed regarding ProcFile,...,...
Many thanks
i try vaadin and no success on heroku i want too know what is your whole configuration
My Vaadin 14 add-demo works just fine with having
a) Having jetty-runner.jar install in pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-runner</artifactId>
<version>${jetty.plugin.version}</version>
<destFileName>jetty-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
and b) a Procfile with web process definition
web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war
Martin Vysny created a nice example how to run V14 app in Heroku. https://github.com/mvysny/vaadin14-embedded-jetty
Our team has also published an updated tutorial for Vaadin 14. You could check it at https://vaadin.com/learn/tutorials/cloud-deployment/heroku