Jump to content

[Solved] Deploy War App Request


xitix

Recommended Posts

Create a Java Spring Boot powered by Thymeleaf to be deployed on heliohost.org

 

 

One of the examples I have enjoyed is the great videos of Spring app-demo of Dan Geabunea , with his pseudonym RomanianCoder.

You can download part of the sources from Github, but keep in mind that have to adapt in order to deploy on heliohost.

 

I will make a small summary of the most important steps on how to make such project ready to be deployed on heliohost.

 

Creating a Spring Boot project with Eclipse WST. This is done in Eclipse, like this: File-> New -> Eclipse Starter Project
You may give the name to the project; in this case BookingDemo, then the group id user_demo and package is indicated to be org.heliohost. The best option is to set the version of Java 1.8 because the comfort that Maven gives, and the convenient to choose.

 

user is your login user @ heliohost

 

I will explain below why is important to have the user_ as prefix, in front of the app, while I will not insist on how to build the MVC Spring Boot part or the Thymeleaf templates. You can download the sources from Github and follow the video tutorial from youtube

 

If you chose to create the project and not import form github, it is better chose for below options; they will not appear with "Frequently Used", but you will have to look for them in each of their categories:

 

1. Actuator which is an informator of the application with multiple indicators
2. Thymeleaf which is a system of web templates
3. H2 as BD. You could choose any other
4. Web to generate web environments
5. JPA for persistence
6. Lombok to avoid the verbosity of getters and setters

 

 

You may follow the explanation from tutorial, but have to consider the necessary configuration in order to deploy the app on heliohost.org

It is mandatory to enter in the file application.properties of the folder src / main / resources , the following entries:

spring.datasource.url: jdbc:mysql://servername.heliohost.org/user_bookings?verifyServerCertificate=false&useSSL=false&requireSSL=false
spring.datasource.username = user_name
spring.datasource.password = password
spring.datasource.driverClassName = com.mysql.jdbc.Driver

spring.datasource.tomcat.max-active=2

server.contextPath=/user_demo
server.port=8080

spring.template.cache: false
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
#spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false

 

Pay attention in which PATH is the context_path that is used and in which java package is the class to use.

 

 

Any deployment in heliohost is done with an user_ in front of the WAR app. If you choose to have the server.contextPath with the correct deployment name, your app will not have any issue to run. On contrary, if your app have not such context from settings, you may need to change the context path from Thymeleaf if decide to use use Spring Security you may choose to disable the CSRF coockie path in order to use with Thymeleaf Server-relative URLs.

 

However, if you choose to bring from beginning an user_ in front of your name app, it will be more convenient for you.

 

Other important thing is: if you decide to use the heliohost database, you have to limit the max connection from your configuration, while spring.datasource.tomcat.max-active=50; pay attention, this is very important: spring.datasource.tomcat.max-active=2

 

As the licenses are payed per no# of connections, and the number impicit in Spring is about 50! You will not get access from heliohost, even when configure

from cpanel.

 

You have to configure carefully: Current Databases -> MySQL Users -> Add New User -> Add User To Database

 

Also, from RemoteMySQL you have to introduce your local IP (in case you need to test the app deployment on localhost, while connected to heliohost mysql database)

 

 

You may also like to check the mysql on heliohost with a simple php script.

 

 

To make it works, you also have to configure the proper rigths after upload the php file into public_html folder.

Do not forget to close the database connection at the end of the file, as you need to limit the number of coonections otherwise you may face some errors when test your remote connection: "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: User user_name already has more than 'max_user_connections' active connections"

 

 

On the Java application template viewer part, chose to deploy with Thymeleaf Server-relative URLs.

 

You may check and double-check the app on your computer, before upload the WAR.

 

The best way is to deploy and test your app locally, and after you are shure that it works, you can upload to heliohost.

Please, be patient and pay respect on the communication with the admin.

 

Success & happy coding !

Link to comment
Share on other sites

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...

Thanks again, you're great!

 

My last changes into the code is not needed anymore.

Now the app deployment it works perfectly with your script modification. :)

 

On my side will be one more re-deployment in a week or two, for changing the method of avatar image uploading to mysql with the /tmp path.

 

I will prepare a how-to post for the users that want to build Java apps with Spring and Thymelef.

 

 

 

Dear,

 

Finally have solved the update for the avatar image uploading method. Please re-deploy the app.

 

WAR package is uploaded on /home/xitix/xitix_blog.war

 

Thanks

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...