Posts

Showing posts from 2013

AWS Parameters

Configuration for the Beanstalk Application AWS  Environmental properties for beanstalk environment can be defined in AWS Environment properties under Configuration this is very important since based on this we can point the application to different DB or we get the flexibility to change configuration without a redeployment or release.  We need to point the application to the database and provide other configuration parameters. Defining these here makes it possible for us to deploy the same "war" application file in Production as well as Test environments. These properties are used in xml files as ${PROPERTY_NAME} and in the code using "System.getProperty("PROPERTY_NAME") The following configurations contain general configurations which needs to be available for all modules and specific configuration for each module. We need to define new Property Names and include these when creating an AWS beanstalk instance. Using Custom Environment Prope...

Sales Force Integration

Problem: I need to connect to Sales Force REST API and fetch data for another application Solution: 1. Create a new remote access application in Sales Force 2. Create OAuth token and secret from Sales Force 3. Use the token and secret in your application The  http://wiki.developerforce.com/page/Getting_Started_with_the_Force.com_REST_API   provides how this is done but its not the latest and things have changed a lot. 1. Create a new remote access application in Sales Force         Log in to Salesforce.com with your developer account,          navigate to Setup ➤ Develop ➤ Remote Access,          Click New to create a new remote access application     Once you click Remote Access it will say      Remote Access Objects have been moved to Applications.      You'll be redirected to that page in five seconds, or you can click Take Me There to go now....

Git

How to use Git bash with keys for Bit Bucket  open a git bash prompt   type 'ssh-keygen' accept default location   choose a passphrase  copy to server the key If you have already created the keys and need to use it in GitBash you need to do the following Open a git bash prompt type ssh-keygen and note the location it is pointing to ( in window it is c/Users/<User Name>/.ssh/id_rsa ) - id_rsa is the file name If you have the ppk file use the following steps to create a OpensSH key open PuTTygen and open the ppk key  once key is open select Conversions -> Expore OpenSSH key and save it to the previous default location where it was going to create the key After you have the key at that location Git bash will recognize the key and use it. For Tortoisegit   Open windows Explorer  Open the Contextmenu and go to TortoiseGit -> Settings  In the opened window navigator go to Git -> Remote ...

Reading Excel Sheet on client side and processing it

Image
If you ever want to process excel sheets on the client side (on the browser) then this will be useful for you.  This uses  http://oss.sheetjs.com  coed and the source files are in ( https://github.com/SheetJS/js-xls ,  https://github.com/SheetJS/js-xlsx ) it is licensed under Apache Licence, Version 2.0 (refer attached licence in the libraries in github) Steps to Follow, JS Files required: Copy the code for following files and make corresponding files locally, or download them from github,                 https://raw.github.com/SheetJS/js-xlsx/master/xlsx.js                 https://raw.github.com/SheetJS/js-xls/master/xls.js                 http://stuk.github.io/jszip/ We will be taking some javascript already in oss.sheetjs.com for our example particularly on the main page of oss.sheetjs.com. Sample Excel Sheet: Our exce...

DB Connection Issues

1. Application gives "1c86bdf0 SharedPool I J2CA0086W: Shareable connection MCWrapper id 686bbdf9 Managed connection com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl@6156bdf9 State:STATE_TRAN_WRAPPER_INUSE" message when trying to do a db update within loop which is querying a view and carrying out some operations. In IBM this problem is documented under the topic " Application hangs with prior J2CA0086W warning messages" The solutions are  1. The application must be modified to use serial reuse or 2. The connection pool can be changed to unshareable. Shareable connections are not allowed within a local transaction containment boundary. The above scenario suggests a possible problem in the application logic and how it is using the connection code. The J2CA0086 message is telling you that your application is using a shared connection in a LocalTransaction. Since the connection is enlisted in a Local Transaction, and not a Global Transaction, di...

Scheduling AWS Autoscaling to create Instance and run your tasks

        Introduction       The purpose of this exercise is to not have a instance running for one off tasks but create the               instance dynamically using a pre configured AMI image.       We use this insance to create reports and upload the reports to S3 bucket. The below details are           provided for configuring the instance and creating  autoscaling groups which will fire up an AMI                image and run at a specified time to achieve the goal.     Download and Configure Auto Scaling Command Line Tool              Google or use (http://ec2-downloads.s3.amazonaws.com/AutoScaling-2011-01-01.zip)       Follow instruction in the Auto scaling tool "Readme.txt" which indicates to set the,                Env...

Change timezone in EC2 instance

Change time Timezone Check the time of the ec2 instance by > date. Normally it has 14 hours difference cat /etc/sysconfig/clock ZONE="UTC" UTC=true cp /etc/localtime /etc/localtime.backup ln -sf /usr/share/zoneinfo/Australia/Sydney /etc/localtime Make the change permanent by adding the following line to the "/etc/sysconfig/clock" file:  ZONE="Australia/Sydney" After this this will show the correct Sydney time

Spring Interceptors

applicationContext-dispatcher.xml we can configure the interceptors as follows in this. < bean id = "visitedPageInterceptor" class = "au.com.vvv.oes.ui.controller.interceptor.VisitedPageInterceptor" /> < bean id = "trailingSlashInterceptor" class = "au.com.vvv.oes.ui.controller.interceptor.TrailingSlashInterceptor" /> < bean id = "breadcrumbInterceptor" class = "au.com.vvv.oes.ui.controller.interceptor.BreadcrumbInterceptor" /> < bean id = "ie6Interceptor" class = "au.com.vvv.oes.ui.controller.interceptor.IE6Interceptor" /> < bean id = "SEOInterceptor" class = "au.com.vvv.oes.ui.controller.interceptor.SEOInterceptor" /> These interceptors can be post interceptors or preinterceptors. example visitedPageInterceptor will be as follows, package au.com.vvv.oes.ui.controller.interceptor; public class VisitedPag...

How to Define a Property in xml files and use it in JSP

Files To Modify :  build.xml / env.properties /a_config.xml / main.jsp ServiceLocator.xml - has some stuff build.xml ---------------------------------- <filter token="omniture.sCodeJsFile" value="${omniture.sCodeJsFile}"/> env.properties ---------------------------------- omniture.sCodeJsFile=s_code_dev.js aldous_css_oes_config.xml ----------------------------------  <omniture>   <sCodeJsFile>@omniture.sCodeJsFile@</sCodeJsFile>  </omniture> main.jsp ---------------------------------- <script type="text/javascript" src="${pageContext.servletContext.contextPath}/javascript/<tag:xmlConfigProperty key="omniture.sCodeJsFile"/>?@js_css.version@"></script>  <%@ taglib prefix="tag" tagdir="/WEB-INF/tags" %> ServiceLocator.xml ----------------------------------  <bean id="xmlConfiguration" class="org.apache.commons.configu...

Session State – it’s not complicated, but options are limited

Web apps have numerous choices for storing stateful data in between requests. For example, when a user goes through a multi-step wizard, he or she might make choices on page one that need to be propagated to page three. That data could be stored in http session. (It also could get stored into some backend persistence and skip session altogether). So where does session get stored? There are basically four choices here. Store state on one app serve r, i.e. for java in HttpSession. Subsequent requests need to be pinned to that particular app server via your load balancer. If you hit another app server, you will not have that data in session. Store state in session , and then replicate that session to all or many other app servers. This means you don’t need a load balancer to anchor a user to one app server; multiple requests can either hit any app server (full replication). Or use the load balancer to pin to particular cluster (themselves replicating sessions, and giving higher avail...

Optimistic Locking in Hibernate and JPA

When writing applications that are going to be accessed by more than one user at a time, you run the risk of the underlying data being corrupted. One solution to this problem is to implement row locks on the data being modified. However, should a process or a user be modifying several rows, this lock can lead to performance degradation as the DB begins to wait for locks to be released. A better solution is to use Optimistic Locking. This is where we monitor the row being modified and allow other users to access it. No lock is being applied here. However, once the row has been saved back to the database, all the rows that are still being viewed become out-of-date, or stale. The simplest method by which the row can be monitored is to employ a “version” column. This is a simple counter that increments every time an update is performed on the row. In JPA annotations this is represented by the @Version annotation. @Version @Column(name = "version", nullable = false, leng...