CentOS : upgrading subversion(svn) 1.6 to subversion(svn) 1.7 Script(.sh)

  1. #uninstall svn 1.6 (yum installs old versions)
  2. yum remove svn
  3. cd /usr/local/
  4. #download 1.7
  5. wget http://opensource.wandisco.com/centos/5/devel/RPMS/x86_64/subversion-1.7.14-1.src.rpm
  6. #install
  7. rpm -ivh subversion-1.7.14-1.src.rpm
  8. #remove backup(your choice)
  9. rm -f subversion-1.7.14-1.src.rpm
  10. #check installation success
  11. svn --version

CentOS : Maven install Script(.sh)

  1. #download maven tar
  2. wget http://mirror.cc.columbia.edu/pub/software/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
  3. #untar
  4. tar xzf apache-maven-3.0.5-bin.tar.gz -C /usr/local/
  5. #delete unnecessary back-up
  6. rm -f apache-maven-3.0.5-bin.tar.gz
  7. #install
  8. cd /usr/local
  9. #create symlink
  10. ln -s apache-maven-3.0.5 maven
  11. #create environment vars
  12. export M2_HOME=/usr/local/maven
  13. export PATH=${M2_HOME}/bin:${PATH}
  14. #check installation
  15. mvn -version
Download CentOS Maven Install Script(.sh) from Here.

Getting started with PhoneGap/Cordova with CentOS, First Helloworld android app using PhoneGap/Cordova

Install Cordova:

On Linux/CentOS:

To install Cordova you will first need to install the npm utility of  Node.js.
  1. yum install nodejs
  2. yum install npm
Then install cordova:
  1. npm install -g cordova

Install Android-SDK:
If you haven't yet installed Android SDK do the following:
Install prequisite libs:
  1. yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686
Download android-sdk from http://developer.android.com/sdk/index.html
(For CentOS 32bit:
Unzip it to a directory.It will be a good idea to rename it.(e.g. /usr/local/android/).Run the following commands:
  1. cd /usr/local/
  2. wget http://dl.google.com/android/adt/22.6.2/adt-bundle-linux-x86-20140321.zip
  3. unzip adt-bundle-linux-x86-20140321.zip
  4. #backup can be deleted now, your choice
  5. rm adt-bundle-linux-x86-20140321.zip
  6. mv adt-bundle-linux-x86-20140321/ android/
Browse it and make sure that the following directories exist and contain all files:
/usr/local/android/sdk/platforms
/usr/local/android/sdk/platform-tools
/usr/local/android/sdk/tools
Now add path variables to environment:
  1. echo "export PATH=$PATH:/usr/local/android/sdk/platforms" >> ~/.profile
  2. echo "export PATH=$PATH:/usr/local/android/sdk/platform-tools" >> ~/.profile
  3. echo "export PATH=$PATH:/usr/local/android/sdk/tools" >> ~/.profile
Now load them for using in current session:
  1. source ~/.profile
Now install AntAnt version 1.8+ is needed for this purpose.


Uninstall previous old ant version:
  1. #uninstall if already old versions are there
  2. yum remove ant

Run the script from here to install ant 1.9:
http://mohiplanet.blogspot.com/2014/06/centos-ant-19-install-scriptsh.html

You will also need ant apache regex utility.Install it by running :
  1. yum install ant-apache-regexp

Create Helloworld Cordova Project:
cd to a convenient directory and run:
  1. cordova create hello com.example.hello HelloWorld
This should create a hello directory in current location.Navigate to hello directory where the config.xml file is located:
  1. cd hello/ && ls
You will see something like:
config.xml  hooks  merges  platforms  plugins  www
Run the following command to prepare the helloworld project for android platform:
  1. cordova platform add android
This will generate required files for helloworld project to run in android.
Run the follwing command to see what platforms are already added in the project:
  1. cordova platforms ls
You will see something like this:
Installed platforms: android 3.5.0
Available platforms: amazon-fireos, blackberry10, firefoxos, ubuntu
Build the project:
Build the project by following command:
  1. cordova build
Run the project:
Run the following command to run the app on android emulator:
  1. cordova emulate android

Now what you just see is the html page located at:
YOUR_PROJECT_ROOT_DIR/www/index.html
You can edit the file and run 'cordova emulate android' again to see the changes.
Debugging the application (Seeing logs):
You can run:
  1. adb logcat
on a seperate window to see android logs.This will produce huge logs, so I would recommend using:
  1. adb logcat|grep Cordova
This will produce logs created by only Cordova.Sample cordova logs:
 adb logcat|grep Cordova
- waiting for device -
I/CordovaLog(  958): Changing log level to DEBUG(3)
I/CordovaLog(  958): Found start page location: index.html
D/CordovaActivity(  958): CordovaActivity.onCreate()
D/CordovaWebView(  958): CordovaWebView is running on device made by: unknown
D/CordovaActivity(  958): CordovaActivity.init()
D/CordovaWebView(  958): >>> loadUrl(file:///android_asset/www/index.html)
W/System.err(  958):  at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:457)
W/System.err(  958):  at org.apache.cordova.CordovaWebView.loadUrlIntoView(CordovaWebView.java:444)
W/System.err(  958):  at org.apache.cordova.CordovaWebView.loadUrl(CordovaWebView.java:414)
W/System.err(  958):  at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:395)
D/CordovaWebView(  958): >>> loadUrlNow()

Distributing your app(Generating .apk):

When you run:
  1. cordova build

A distributable .apk is genarated at  YOUR_PROJECT_ROOT_DIR/platforms/android/ant-build/
In this example the auto-generated .apk will  be YOUR_PROJECT_ROOT_DIR/platforms/android/ant-build/HelloWorld-debug.apk
But this a debug version.To build release version simply do:

  1. cordova build --release

This will generate an unsigned release version of your app like YOUR_PROJECT_ROOT_DIR/platforms/android/ant-build/HelloWorld-release-unsigned.apk 
To sign your app with your company profile please visit:

http://developer.android.com/tools/publishing/app-signing.html

References:-
http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html
https://wiki.echocat.org/display/ECHOCAT/2012/08/17/Configure+Android+SDK+on+CentOS+6+x86_64

Linux/CentOS : Ant 1.8 / 1.9 / install script(.sh)

Because yum will always download old versions.Let's download Ant 1.9 with .sh script.This will do the work:
  1. #make sure opt directory exists
  2. cd /opt/
  3. #download
  4. wget http://mirrors.ispros.com.bd/apache//ant/binaries/apache-ant-1.9.4-bin.zip
  5. #unzip and remove zip(you choice)
  6. unzip apache-ant-1.9.4-bin.zip && rm apache-ant-1.9.4-bin.zip
  7. cd apache-ant-1.9.4/
  8. #create symlinks
  9. ln -s /opt/apache-ant-1.9.4 /opt/ant
  10. ln -s /opt/ant/bin/ant /usr/bin/ant
  11. #add environment variable
  12. echo 'ANT_HOME=/opt/ant' >> /etc/environment
  13. #apply changes on current session
  14. source /etc/environment

Be sure to download wget before running the script
Download script Install Ant 1.9.sh

Google App Engine(GAE) : Rolling back previous incomplete deployment(running appcfg roolback)

While deploying Google App Engine web app you may face:
"GAE appcfg rollback not working: 409 Conflict Another transaction by user is already in progress for app".
To fix this got to APP_ENGINE_SDK_DIRECTORY/bin where the appcfg.sh is located:
Run this command there:
sh appcfg.sh rollback GAE_APP_DIR/
where GAE_APP_DIR: your project directory where the WEB_INF foler is located example:
sh appcfg.sh rollback GAE_APP_DIR/web/

Spring MVC + JSON : fixing error 406 (Not Acceptable)


This may happen while using Spring controllers like this:

  1. @RequestMapping(value = "/getbirds", method = RequestMethod.GET, produces = "application/json")
  2.     public @ResponseBody
  3.     List<Bird> getBirds(@RequestParam("term") String term) {
  4. List<Bird> lst;
  5. //..........
  6. return lst;
  7. }


@ResponseBody annotations don't use normal view resolvers, they use their own.Put this in your dispatcher-servlet:
  1. <bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean>
  2. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
  3. <property name="messageConverters">
  4. <list>
  5. <ref bean="jacksonMessageConverter"/>
  6. </list>
  7. </property>
  8. </bean>

You may need to put this dependency in your pom.xml:
  1. <dependency>
  2.             <groupId>org.codehaus.jackson</groupId>
  3.             <artifactId>jackson-mapper-asl</artifactId>
  4.             <version>1.8.0</version>
  5.         </dependency>

Similar Posts: