Search This Blog

Monday 16 February 2015

Spring Boot JPA Thymeleaf application deployed to IBM Bluemix

IBM Bluemix is an open-standards, cloud-based platform for building, managing, and running apps of all types, such as web, mobile, big data, and smart devices. Capabilities include Java, mobile back-end development, and application monitoring, as well as features from ecosystem partners and open source—all provided as-a-service in the cloud.

The example below shows how to deploy an spring boot JPA application to IBM Bluemix. The example is based on the code below.

https://github.com/papicella/BluemixSpringBootJPA

1. Target the IBM Bluemix

cf api https://api.ng.bluemix.net

2. Log in as follows

cf login -u pasapi@au1.ibm.com -p ******-o pasapi@au1.ibm.com -s dev

3. Create a MYSQL service as shown below.

pas.apicella@IBM-XD082415H ~/bluemix-apps/spring-data-jpa-thymeleaf/mysql
$ cf create-service mysql 100 dev-mysql
Creating service dev-mysql in org pasapi@au1.ibm.com / space dev as pasapi@au1.ibm.com...
OK


4.  At this point lets run the application using an embedded tomcat server as shown below.

pas.apicella@IBM-XD082415H ~/bluemix-apps/spring-data-jpa-thymeleaf/mysql
$ java -jar BluemixSpringBootJPA-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.2.0.RELEASE)

2015-02-16 20:12:18.289  INFO 15824 --- [           main] p.cloud.webapp.ApplesCfDemoApplication   : Starting ApplesCfDemoApplication on IBM-XD082415H with PID 15824 (C:\ibm\bluemix\apps\spring-data-jpa-thymeleaf\mysql\BluemixSpringBootJPA-0.0.1-SNAPSHOT.jar started by pas.apicella in C:\ibm\bluemix\apps\spring-data-jpa-thymeleaf\mysql)
2015-02-16 20:12:18.356  INFO 15824 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6b51dbf6: startup date [Mon Feb 16 20:12:18 AEDT 2015]; root of context hierarchy
2015-02-16 20:12:20.679  INFO 15824 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration' of type [class org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-02-16 20:12:20.779  INFO 15824 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$15fe846f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-02-16 20:12:20.831  INFO 15824 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-02-16 20:12:20.853  INFO 15824 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

.....

class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-02-16 20:12:27.710  INFO 15824 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-02-16 20:12:28.385  INFO 15824 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2015-02-16 20:12:28.510  INFO 15824 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http
2015-02-16 20:12:28.513  INFO 15824 --- [           main] p.cloud.webapp.ApplesCfDemoApplication   : Started ApplesCfDemoApplication in 10.626 seconds (JVM running for 11.481)


5. Now using a manifest.yml as follows deploy the application to bluemix as shown below.

manifest.yml

applications:
- name: pas-mj-albums
  memory: 512M
  instances: 1
  host: pas-albums
  domain: mybluemix.net
  path: ./BluemixSpringBootJPA-0.0.1-SNAPSHOT.jar
  buildpack: https://github.com/cloudfoundry/java-buildpack.git
  services:
    - dev-mysql


Deployment output

pas.apicella@IBM-XD082415H ~/bluemix-apps/spring-data-jpa-thymeleaf/mysql
$ cf push -f manifest.yml
Using manifest file manifest.yml

Creating app pas-mj-albums in org pasapi@au1.ibm.com / space dev as pasapi@au1.ibm.com...
OK

Creating route pas-mj-albums.mybluemix.net...
OK

Binding pas-mj-albums.mybluemix.net to pas-mj-albums...
OK

Uploading pas-mj-albums...
Uploading app files from: BluemixSpringBootJPA-0.0.1-SNAPSHOT.jar
Uploading 837.2K, 135 files
Done uploading
OK
Binding service dev-mysql to app pas-mj-albums in org pasapi@au1.ibm.com / space dev as pasapi@au1.ibm.com...
OK

Starting app pas-mj-albums in org pasapi@au1.ibm.com / space dev as pasapi@au1.ibm.com...
-----> Java Buildpack Version: 303bda3 | https://github.com/cloudfoundry/java-buildpack.git#303bda3
-----> Uploading droplet (64M)

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running

App started


OK

App pas-mj-albums was started using this command `SERVER_PORT=$PORT $PWD/.java-buildpack/open_jdk_jre/bin/java -cp $PWD/.:$PWD/.java-buildpack/spring_auto_reconfiguration/spring_auto_reconfiguration-1.7.0_RELEASE.jar -Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh -Xmx382293K -Xms382293K -XX:MaxMetaspaceSize=64M -XX:MetaspaceSize=64M -Xss995K org.springframework.boot.loader.JarLauncher`

Showing health and status for app pas-mj-albums in org pasapi@au1.ibm.com / space dev as pasapi@au1.ibm.com...
OK

requested state: started
instances: ?/1
usage: 512M x 1 instances
urls: pas-mj-albums.mybluemix.net
last uploaded: Mon Feb 16 09:18:28 +0000 2015

     state     since                    cpu    memory           disk
#0   running   2015-02-16 08:20:04 PM   0.0%   393.4M of 512M   129.3M of 1G


6. Once deployed the Bluemix Console page shows it deployed as follows


7. Finally invoking the application using the unique route as follows

http://pas-mj-albums.mybluemix.net/albums





More Information

https://www.ng.bluemix.net/docs/#

1 comment:

Unknown said...

Examples in steps with coding is very useful to understand how to use an spring boot JPA app to IBM Bluemix. Best one! Best Event Apps iPhone