Develop local, deploy (cloud) global - Java and CouchDB
Leaving the cosy world of Domino Designer behind, venturing into IBM Bluemix, Java and Cloudant, I'm challenged with a new set of task to master. Spoiled by Notes where
Ctrl+Ogives you instant access to any application, regardless of being stored locally or on a server I struggled a little with my usual practise of
develop local, deploy (Bluemix) globalThe task at hand is to develop a Java Liberty based application, that uses CouchDB/Cloudant as its NoSQL data store. I want to be able to develop/test the application while being completely offline and deploy it to Bluemix. I don't want any code to have conditions offline/online, but rather use configuration of the runtimes for it.
Luckily I have access to really smart developers (thx Sai), so I succeeded.
This is what I found out, I needed to do. The list serves as reference for myself and others living in a latency/bandwidth challenged environment.
- Read: There are a number of articles around, that contain bits and pieces of the information required. In no specific order:
- Install: This is a big jump forward. No more looking for older versions, but rather bleeding edge. Tools of the trade:
- GIT. When you are on Windows or Mac, try the nice GUI of SourceTree, and don't forget to learn git-flow (best explained here)
- A current version of the Eclipse IDE (Luna at the time of writing, the Java edition suffices)
- The liberty profile beta. The Beta is necessary, since it contains some of the features, notably couchdb, which are available in Bluemix by default. Use the option to drag the link onto your running Eclipse client
- Maven - the Java way to resolve dependencies (guess where bower and npm got their ideas from)
- CURL (that's my little command line ninja stuff, you can get away without it)
- Apache CouchDB
- Configure: Java loves indirection. So there are a few moving parts as well (details below)
- The Cloudant service in Bluemix
- The JNDI name in the web.xml. Bluemix will discover the Cloudant service and create the matching entries in the server.xml automagically
- A local profile for a server running the Liberty 9.0 profile
- The configuration for the local CouchDB in the local server.xml
- Replication between your local CouchDB instance and the Cloudant server database (if you want to keep the data in sync)