July 22, 2016

Tomcat - clearing cache

I was doing some works with Tomcat on my current Debian setup and this one issue keeps bugging me the whole day. Today is Friday and lucky for me, I was able to get some times away from that and cleared my mind before getting back at it.

After returning (soaked in wet rain), I came to the conclusion that Tomcat cached some of the apps that I deployed somewhere. This means that re-deploying the apps does not really load up the entirely new App properly as a whole.

Before that, I have checked and did the following, which seemingly "removed" the previous deployment.

| Remove the contents of the folder $CATALINA_HOME/work

Well, that worked for basic UI changes that I made, until I needed to re-point the apps to my local database. In my App, there is a config/properties file that handles this. I made changes to the file, and guess what?

The databases connection was unsuccessful...

It seems that Tomcat still does some cache-ing somewhere....

and then I found out the solution :

Change the content of the following file : $CATALINA_HOME/conf/context.xml

Add inside the tag
     

and that solves my issues.

July 21, 2016

PhoneGap developement on Debian Linux

A friend of mine started a colloboration to create an App which aims to help Orphanage discovery. The main tool to use is PhoneGap. Little that I know, PhoneGap Desktop is not yet supported on Linux. The wine-ported version reported crashing upon launched.

The thing is, I didn't know that PhoneGap has command line tool called PhoneGap CLI. PhoneGap CLI is actually older than the Phone Gap desktop. I have used PhoneGap desktop on Windows before and I found it quite easy to use. I didn't do much with it though. Now that I am on full-time Linux, I will need to use the PhoneGap CLI, thus tutorial below is for those who are interested to develop a PhoneGap app using PhoneGap CLI.


1. First, install Node.js
sudo apt-get update
sudo apt-get install nodejs

2. Simlink Node.js as node (this is how PhoneGap calls it - node instead of nodejs)
sudo ln -s /usr/bin/nodejs /usr/bin/node

3. Install NPM - this is package manager for PhoneGap and other similar javascript programs
sudo apt-get install npm

4. Install PhoneGap using NPM
sudo npm install -g phonegap

5. Install the PhoneGap Developer App from Google Play
https://play.google.com/store/apps/details?id=com.adobe.phonegap.app&hl=en

To get started, lets create hello world app

# create a PhoneGap project, NPM will pull simple hello world project for us to use
phonegap create myApp
# change to project directory 
cd myApp
# build and install the app to Android               
phonegap run android
# start up a local web server to host our application      
phonegap serve           

Get the ip provided and put it in the PhoneGap Developer App on your phone.
The first page displayed is stored at YourAppDirectory/www/index.html

That's it. You're good to go!

To learn what's there in hello world page, go to here :
http://docs.phonegap.com/tutorials/develop/hello-world-explained/




Some screenshots :





July 20, 2016

Git & Github

Intro

Git is the name of this software.

Github is the 'hosted' version of this software - stored in a remote server.

Git stores the project's codes and files.

Git helps programmers in Versioning the codes - each changes they make to the codes will be tagged to a running number, normally with a comment what changes has been done.

Git helps several programmers to collaborate - work together in a single project by making sure everyone can have the latest updated codes at any time and everyone is aware what changes are done to the codes - by reading their comments.



Some terms


Repository : The storage for the codes.

Trunk : Main version of the codes stored in the repository.

Branch : Codes which are derived from trunk (main version). Normally, a programmer will have their own personal branch to work on instead of working directly on trunk - this is to preserve the trunk. So, this could be the first thing they do - branched from trunk. Branched is done on the remote repository - so, basically we creates a copy of the trunk at the remote repository.

Checkout or Clone : Download the current version of the codes from the remote repository to our pc and saved them locally as "local repository". This is usually done the first time we get the codes - checkout from our personal branch.

Origin or Master : The location where codes are checked out from.

Fetch : Get the latest version of codes from remote repository but not merging to the current codes in local repository yet.

Pull : Fetch and Merge at the same time.

Commit : Save the latest changes we did on the local repository to a version. Typically done with a comment what changes have been done.

Add : Add new file for the next commit (see below)

Push : Upload current codes (which has last commit) of local repository to the remote repository, typically to the remote branch.

Merge : "Compare" and "Combine" two versions of  codes. Normally, once all changes are completed on one branch, the branch will be merged to trunk. This will typically happened at the end stage of development.

Conflicts : The differences between two versions of  codes. Occurs when one tries to merge two versions of codes together (i.e. trunk vs branch) that have some differences. Conflicts need to be "resolved"



Typical Workflow

At remote repository, branch from trunk. We get the most updated version.

Checkout the branch to a local repository at our pc.

Make some changes on the codes.

Commit with a message - versioning will be done automatically.

Make more changes on the codes.

Commit with another message - new version created.

Some more changes and commit cycles.

Work are done.

Push the branch in our local repository to the branch in remote repository.

Try to merge the remote branch to the trunk.
   
Conflicts with occurs at this point since we are updating the trunk with our changes. Resolve them.
   
Once merged to trunk, trunk will have our latest codes.
   
Another programmer will try to merge his branch to the trunk.
   
If any conflicts occurs, he need to resolve them first. Typically, if two programmers don't work at the same issues, there will be not much conflicts or conflicts can be easily resolved.



To start, install Tortoisegit below and start checking out from any Github repos :
https://tortoisegit.org/about/screenshots/#Explorer_integration