tag:blogger.com,1999:blog-18187756883329267752024-03-14T01:41:33.116+05:30Technology CentralThis is a technology blog where I share my passion with all. My interests are Machine Learning, Artificial Intelligence and Big Data. In this blog I would like to share practical facets of these technology from a design development perspectiveSrijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comBlogger37125tag:blogger.com,1999:blog-1818775688332926775.post-14240974114075034022021-11-12T01:36:00.003+05:302021-11-12T01:37:24.867+05:30Checking ports with telnet or netcat<p> Recently I was working on AWS and was deploying applications on a Fargate cluster. I wanted to make sure the application was up and running and the ports were accessible by other applications. For that purpose I created a bastion host (EC2) but because of the restrictions on my role, I could not install telnet or nc on that EC2 instance. </p><p>But I was able to connect to the ports using the below bash command</p><p><span style="background-color: white; font-family: Calibri, sans-serif; font-size: 14.6667px;"></dev/</span><span style="background-color: white; font-family: Calibri, sans-serif; font-size: 14.6667px;">tcp</span><span style="background-color: white; font-family: Calibri, sans-serif; font-size: 14.6667px;">/10.191.226.250/13133 && echo Port is open || echo Port is closed</span></p><p><br /></p>Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-84308948341250390672019-03-18T21:04:00.002+05:302019-03-18T21:04:33.935+05:30How I solved "Expected tensor for argument #1 ‘indices’ to have scalar type Long" errorToday I was trying to train my 2 layer LSTM on some long documentry extract and kept geting this irritating error<br />
Expected tensor for argument #1 ‘indices’ to have scalar type Long; but got CPUFloatTensor instead (while checking arguments for embedding)<br />
<br />
After many google searches and stackoverflow crawling, I figured out that the error was caused by the following line of code<br />
<br />
<blockquote class="tr_bq">
dataset = TensorDataset(torch.Tensor(features), torch.Tensor(target))</blockquote>
<br />
Changed it to<br />
<blockquote class="tr_bq">
dataset = TensorDataset(torch.tensor(features), torch.tensor(target))</blockquote>
<br />
and it fixed the issueSrijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-91403286725155038412017-03-30T18:19:00.001+05:302017-05-05T12:01:44.386+05:30Resolve the issue 'cannot import name multivariate_normal'The <span style="font-family: "courier new" , "courier" , monospace;">multivariate_normal</span> component in the <span style="font-family: "courier new" , "courier" , monospace;">scipy</span> stats library is a very useful component for many machine learning applications. I faced an issue while trying to import this library in my Jupyter notebook and I wanted to share how I fixed it. I am running python 2.7 on an Ubuntu 14.04 machine.<br />
<a name='more'></a><br />
As I was doing my <a href="https://goo.gl/Eq87NA" target="new">Machine Learning Specialization</a><img border="0" height="1" src="https://ad.linksynergy.com/fs-bin/show?id=RCpc/BzltMk&bids=467035.184&type=3&subid=0" width="1" /> at Coursera, in one of the programming assignments, I faced an issue while trying to use the multivariate_normal component of scipy.
<br />
I had to import<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml; gutter: false;">from scipy.stats import multivariate_normal
</pre>
which was giving the below error<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml; gutter: false;">ImportError: cannot import name multivariate_normal
</pre>
<br />
As mentioned in many online forums, I found out that the issue was, my scipy version is 0.13.3 and the multivariate_normal is supported only in 0.14 and above. Many people suggested to run the command<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml; gutter: false;">sudo pip install scipy --upgrade
</pre>
<br />
to upgrade the scipy, but for that was failing with the below error
<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml; gutter: false;">'ascii' codec can't decode byte 0xe2 in position 66: ordinal not in range(128)
</pre>
Below are the steps I followed to fix it<br />
<b>Step 1) First need to make sure all scipy dependencies are installed properly
</b>
<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml; gutter: false;">sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
</pre>
<b>Step 2) Make sure the numpy, which scipy is dependent on is up-to-date</b><br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml; gutter: false;">sudo pip install numpy --upgrade</pre>
<b>Step 3) Make sure all the build dependencies of scipy is available
</b><br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml; gutter: false;">sudo apt-get build-dep python-scipy
</pre>
<b>Step 4) Rerun the upgrade</b><br />
<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml; gutter: false;">sudo pip install scipy --upgrade
</pre>
Now when I try to import multivariate_normal it works fine
<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml;">$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy.stats import multivariate_normal
>>></pre>
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-52363703268005088272017-03-24T18:15:00.001+05:302017-03-24T18:23:16.040+05:30Solving 0.0.0.0 permission denied (publickey) error message on Hadoop name nodeFor a Hadoop cluster to work properly, all the hadoop components like NameNode, SecondaryNameNode, JobTracker and ProcessManager must be started. If you happen to create a hadoop cluster by yourself like I mentioned in <a href="http://tech.srij.it/2017/03/setting-up-hadoop-cluster-in-rhel-6.html" target="_blank">my previous blog</a>, when you start the name node by using 'start-dfs.sh', you might get the below error<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">'0.0.0.0 permission denied (publickey)'</span><br />
<br />
This is due to the fact that, by default, the hadoop core process will try to start secondary namenode on the default ip address 0.0.0.0 which by default should be pointing to localhost. In order to do that it tries to establish an SSH connection to the ip address 0.0.0.0 and as the error message states, it fails to make the connection because the passwordless SSH is not setup correctly for the host 0.0.0.0. Below steps will help you fix this<br />
<h4>
1) If you are using a config file for passwordless ssh (mostly in case of AWS servers)</h4>
In order to setup passwordless ssh, you might have created a config file in .ssh folder of your home directory with the entries for hostname, userid and the keyfile to be used while doing ssh, as shown below<br />
<br />
<a name='more'></a><br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">Host namenode
User hadoopuser
HostName namenode.xyz.com
IdentityFile ~/.ssh/hadoop_key.pem
Host localhost
HostName 127.0.0.1
User hadoopuser
IdentityFile ~/.ssh/hadoop_key.pem
Host datanode1
User hadoopuser
HostName datanode1.xyz.com
IdentityFile ~/.ssh/hadoop_key.pem
Host datanode2
User hadoopuser
HostName datanode2.xyz.com
IdentityFile ~/.ssh/hadoop_key.pem
Host datanode3
User hadoopuser
HostName datanode3.xyz.com
IdentityFile ~/.ssh/hadoop_key.pem
</pre>
<br />
<br />
just add the below entries<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">Host 0.0.0.0
User hadoopuser
IdentityFile ~/.ssh/hadoop_key.pem
</pre>
<br />
and try to connect to 0.0.0.0 via ssh as below<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">$ ssh 0.0.0.0
The authenticity of host '0.0.0.0' can't be established.
ED25519 key fingerprint is e4:ff:65:d7:be:5d:c8:44:1d:89:6b:50:f5:50:a0:ce.
Are you sure you want to continue connecting (yes/no)?
</pre>
Type 'yes' and you should be all set.<br />
<h4>
<span style="font-family: inherit;">2) If you are using ssh-keygen generated key for passwordless ssh</span></h4>
In this case, you dont need to do anything other than updating the known hosts<br />
Try to connect to 0.0.0.0 via ssh as below<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">$ ssh 0.0.0.0
The authenticity of host '0.0.0.0' can't be established.
ED25519 key fingerprint is e4:ff:65:d7:be:5d:c8:44:1d:89:6b:50:f5:50:a0:ce.
Are you sure you want to continue connecting (yes/no)?
</pre>
Type 'yes' and you should be all setSrijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-68264591120823174422017-03-24T11:07:00.002+05:302017-03-24T18:16:50.137+05:30Solving jps: command not found error messagejps is a command line utility that comes with jdk which allows you to view all the Java processes running on a host. It is extremely useful when your environment has multiple background java processes running, like it happens in a Hadoop cluster. If you happen to create a hadoop cluster by yourself as mentioned in <a href="http://tech.srij.it/2017/03/setting-up-hadoop-cluster-in-rhel-6.html" target="_blank">my previous blogs</a>, 'jps' command is very useful to diagnostic utility to make sure the NameNodes, DataNodes, ProcessManager and ResourceManager processes are running.<br />
<br />
Sometimes if you try to use 'jps' and get the error message "<span style="font-family: "courier new" , "courier" , monospace;">jps: command not found error message</span>" here is how you solve it<br />
<br />
<a name='more'></a><br />
Step 1) Make sure you have installed a JDK, not a jre. In order to do that, you have to find out the directory where the jre is present. Mostly you can find it from the JAVA_HOME environment variable. A general rule of thumb is if the Java installation directory only has a 'jre' folder , then you might not have JDK installed.<br />
<br />
Below is the output if you just have jre installed<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">$ cd $JAVA_HOME
$ cd ..
$ ls
jre LICENSE THIRD_PARTY_README
</pre>
<br />
On a linux you can install JDK by appending '-devel' to the installation package<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">$ sudo yum install java-1.7.0-openjdk-devel
</pre>
<br />
Run 'ls' command again, you should see the below output<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">$ cd $JAVA_HOME
$ cd ..
$ ls
bin include jre lib LICENSE tapset THIRD_PARTY_README
</pre>
<br />
<br />
Step 2) Make sure the <span style="font-family: "courier new" , "courier" , monospace;">JDK_INSTALL_PATH/bin</span> is in the classpath<br />
<br />
Now if you try the 'jps' command, you should see the java processes running. On a Hadoop name node, you should see the below output<br />
<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">$jps
JPS
NameNode
TaskTracker
JobTracker
</pre>
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-75709671653145331952017-03-16T11:53:00.001+05:302017-05-02T19:52:17.064+05:30Setting up a Hadoop Cluster in RHEL 6 - Preparing the servers<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq4cPEdyWGP7iveI-LOrIAYq_K6c8AGoci1Zg_0bJpTqax-gpg6XsJf8_JU2I110d13yndQxZpQEt3dYss1Qw8hCzwHhfx51goaqYjVawP5IV2QGXwnaG1vYNXbceV49Qi4QzBt_ZYxVo/s1600/hadoop.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="54" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq4cPEdyWGP7iveI-LOrIAYq_K6c8AGoci1Zg_0bJpTqax-gpg6XsJf8_JU2I110d13yndQxZpQEt3dYss1Qw8hCzwHhfx51goaqYjVawP5IV2QGXwnaG1vYNXbceV49Qi4QzBt_ZYxVo/s200/hadoop.PNG" width="200" /></a>In this two part series, we will discuss how to setup a Hadoop cluster on RHEL 6. I was inspired by my friend who did the <a href="https://goo.gl/ykFH7R" target="new">Big Data Specialization course of University of California San Diego through Coursera</a><img border="0" height="1" src="https://ad.linksynergy.com/fs-bin/show?id=RCpc/BzltMk&bids=467035.183&type=3&subid=0" width="1" /> and I thought it will be a good learning experience for me to setup a Hadoop cluster myself as well. Even though Cloudera's open source paltform is the most common distribution of Hadoop, I really wanted to understand some low-level details of Hadoop components and how they interact with each other. There fore, I thought it will be useful to install and configure the basic Apache Hadoop distribution from scratch.<br />
<br />
In this part, we will discuss the setup of Linux environment and how to install the Hadoop distribution. In Part 2 we will discuss how to configure the core components of the Hadoop ecosystem and start the server. Okay, lets get started<br />
<br />
<a name='more'></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://click.linksynergy.com/fs-bin/click?id=RCpc/BzltMk&offerid=467035.204&subid=0&type=4"><img alt="Big Data Specialization from UC San Diego" border="0" src="https://ad.linksynergy.com/fs-bin/show?id=RCpc/BzltMk&bids=467035.204&subid=0&type=4&gridnum=16" /></a>
</div>
<h3>
Configuration</h3>
<span style="font-family: inherit;">Our cluster will have 4 linux servers. 1 Name node and 3 Data nodes. I used four personal laptops to setup this cloud, but you can very well use AWS as well. Apart from the cluster, I have another windows laptop to administer the RHEL servers. For the sake of this tutorial, let us assume that the Red Hat servers are up and running and have the following parameters</span><br />
<div>
<b><br /></b><b>Namenode </b></div>
<div>
dns name: namenode.xyz.com<br />
ip address: 10.20.30.40<br />
user id: hadoopuser</div>
<div>
<b><br /></b></div>
<div>
<b>Data Node 1</b><br />
dns name: datanode1.xyz.com<br />
ip address: 10.20.30.41<br />
user id: hadoopuser</div>
<div>
<b><br /></b></div>
<div>
<b>Data Node 2</b><br />
dns name: datanode2.xyz.com<br />
ip address: 10.20.30.42<br />
user id: hadoopuser</div>
<div>
<b><br /></b></div>
<div>
<b>Data Node 3</b><br />
dns name: datanode3.xyz.com<br />
ip address: 10.20.30.43<br />
user id: hadoopuser </div>
<div>
<br /></div>
<div>
The overall configuration looks like below. The 'orange' lines indicate SSH connections for administration and 'blue' lines indicate the communication between the name node and data nodes. (We are yet to configure the SSH connections)</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipfsh21D5VVJOFpfMzZ1SYYB9sDB0eBoOKcWtMFDiDl0snq7ALU1U2Njl1SsuoF_TP2BB3Uqi9CbcM2q5ipvztKrqc6F1KPAaR2MNt_laD8W5J0DMaU7PDLwAiwfDtgtrCNYG9ui5hNA8/s1600/c1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="370" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipfsh21D5VVJOFpfMzZ1SYYB9sDB0eBoOKcWtMFDiDl0snq7ALU1U2Njl1SsuoF_TP2BB3Uqi9CbcM2q5ipvztKrqc6F1KPAaR2MNt_laD8W5J0DMaU7PDLwAiwfDtgtrCNYG9ui5hNA8/s400/c1.PNG" width="400" /></a></div>
<div>
<br /></div>
<br />
<div>
</div>
<h4>
Configuring SSH from Laptop to the Linux Servers</h4>
<div style="font-family: inherit;">
<div style="margin: 0px;">
<div style="font-family: inherit;">
We will use PuTTY tool to connect to, administer and configure the Linux servers. To install and configure PuTTY, please refer to my <a href="http://tech.srij.it/2017/03/install-and-configure-putty-for-making.html" target="_blank">previous post here</a>. We need to configure PuTTY session for the name node and each of the data nodes. </div>
<br />
<h4 style="font-family: inherit;">
Creating alias hostnames for name node and data nodes</h4>
<div>
In order to hide the real dns names of the name nodes and data nodes, we would like to create host aliases for the nodes. In linux we can do it by modifying the /etc/hosts file. </div>
<div>
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">hadoopuser@namenode $ sudo nano /etc/hosts
</pre>
Now add the below entries
<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">10.20.30.40 namenode.xyz.com namenode
10.20.30.41 datanode1.xyz.com datanode1
10.20.30.42 datanode2.xyz.com datanode2
10.20.30.43 datanode3.xyz.com datanode3</pre>
</div>
<h4 style="font-family: inherit;">
Configuring password-less SSH between name node and data nodes</h4>
<div style="font-family: inherit;">
First and foremost task we have, is to setup password-less SSH between the names node and the data nodes. It is a very important step because, name node and data nodes communicates in the background, using SSH and it is essential that this communication happens without entry of password. </div>
<div style="font-family: inherit;">
<br /></div>
<div style="font-family: inherit;">
We will achieve this by creating unique key pair in name node and each data node and then configure SSH in each server to use the corresponding key pair for making connections to any other server. We will also setup each server to "trust" each other's public key. This will be enable SSH connection from any server to any other server without the need for password. </div>
<div style="font-family: inherit;">
<br /></div>
<div class="separator" style="clear: both; font-family: inherit; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLvj1_ozkC3MkDAF9yUJPZcCD3ikRGat88vfdJ350gSiw_Sp7KccfZOx6sqL3WaFMfcqi56EpOr1Q9goIoRFcjgNcYH5sf8kfk7o9WoXhIbdK1f37vuaVJ8r9NhP1k8DxFqWZbCWA9r_I/s1600/passwordless+ssh.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="203" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLvj1_ozkC3MkDAF9yUJPZcCD3ikRGat88vfdJ350gSiw_Sp7KccfZOx6sqL3WaFMfcqi56EpOr1Q9goIoRFcjgNcYH5sf8kfk7o9WoXhIbdK1f37vuaVJ8r9NhP1k8DxFqWZbCWA9r_I/s320/passwordless+ssh.PNG" width="320" /></a></div>
<div style="font-family: inherit;">
Follow the below steps on each server to achieve the above mentioned configuration.<br />
<br />
1) SSH to Namenode<br />
<br />
2) Type the following command in the terminal</div>
<div style="font-family: inherit;">
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">ssh-keygen
</pre>
</div>
<div style="font-family: inherit;">
This will create a key pair in the ~/.ssh folder. If you examine the folder, you can see that the folder contains two files<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">hadoopuser@namenode $ cd ~/.ssh
hadoopuser@namenode .ssh $ ls
id_rsa id_rsa.pub</pre>
<div>
The id_rsa file is the private key and should not be shared with anybody. id_rsa.pub is the public key that will be used in other nodes to establish trust<br />
<br />
3) Setup the trust relationship by copying the public key to other hosts<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">hadoopuser@namenode $ ssh-copy-id hadoopuser@datanode1
hadoopuser@namenode $ ssh-copy-id hadoopuser@datanode2
hadoopuser@namenode $ ssh-copy-id hadoopuser@datanode3
</pre>
<br />
Repeat these steps for all the other nodes.<br />
<br />
<span style="font-family: inherit;">You can try ssh to each of the nodes to make sure it makes the connection without asking for password</span><br />
<br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">ssh namenode
</pre>
</div>
<br />
<br />
Now that the name node and data nodes are ready, let us continue to the <a href="http://tech.srij.it/2017/03/setting-up-hadoop-cluster-in-rhel-6_22.html" target="_blank">next part to install and configure Hadoop in these machines</a>.<br />
<br /></div>
</div>
</div>
Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-37673044019303917642017-03-15T22:42:00.004+05:302017-03-22T16:54:05.587+05:30Install and configure PuTTY for making SSH connections<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO-m-2pyP6R4E4SQjHuI4q62aYPmsm7hiXksG3v8SfEQryzDKDLcH1YROlyYf2kX6gcvcXG2dMh6nZS8EBI3zSGNzO55Pwq9Nmz6h_PMfwZ4RpIux1ybJeg5dVKhZp0B3d6FmQqZN7brY/s1600/putty+0.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO-m-2pyP6R4E4SQjHuI4q62aYPmsm7hiXksG3v8SfEQryzDKDLcH1YROlyYf2kX6gcvcXG2dMh6nZS8EBI3zSGNzO55Pwq9Nmz6h_PMfwZ4RpIux1ybJeg5dVKhZp0B3d6FmQqZN7brY/s1600/putty+0.PNG" /></a>Being able to securely connect to remote hosts from windows using SSH is a very important and common requirement, especially when you are working with remote linux servers. SSH is a high-security protocol. It uses strong encryption to shield your connection from eavesdropping. capture, and other sorts of attack. In this post we will discuss exactly how to do this using PuTTY tool. We will also show how to create and save PuTTY sessions and discuss how to configure login without password using key pair.<br />
<br />
PuTTY is a free, open source SSH client and a terminal emulator for windows. It has a very easy to use user interface and the ability to configure and store sessions, so that we can connect to configured hosts in a single click.<br />
<a name='more'></a><br />
For the sake of this illustration, let us assume that we need to connect to a remote linux host with the domain name <b><i>abc.xyz.com</i>. </b>We will assume that we the userid is <b><i>user1 </i></b>and password is <b><i>password</i></b><br />
<br />
Many times, you might have to use a keypair to logon to the remote host, instead of using userid and password. This is the case when you are using AWS. To elaborate this case, we will assume you have the key pair MyKey.pem saved to C;\temp\MyKey.pem and we will discuss how to configure that in PuTTY as well.<br />
<br />
<h4>
Step 1 - Download and install PuTTY</h4>
Let us download putty from <a href="http://www.putty.org/">http://www.putty.org/</a> and install<br />
<br />
<h4>
Step 2 - Convert .pem file to .ppk file. (You can skip this step if you are using userid and password)</h4>
If your key pair is in a .pem file, before you can use it with PuTTY to login, we should extract the private key from the .pem file, to a format that is understood by PuTTY(which is a .ppk file). This can be done using the puttygen.exe, which will be available in <b>C:\Program Files (x86)\PuTTY</b> location once you complete the PuTTY installation.<br />
<br />
Run the puttygen.exe by double clicking the file and load the .pem file by clicking the "Load" button<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTR-sQEfjDmyJ-RQ96x6JZtNaRuL8GQ2a2ShtWNqKCgfiNCpByHWQ7dKv8QmWTKB0Ncqeqn-GtSKsEN0SwUJ5ziNNmkZtkPMaHMO2Fw1R3vAUgzVJsJcNFOqeUW99cRQkhLX9Kqw77k9E/s1600/puttygen+1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="318" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTR-sQEfjDmyJ-RQ96x6JZtNaRuL8GQ2a2ShtWNqKCgfiNCpByHWQ7dKv8QmWTKB0Ncqeqn-GtSKsEN0SwUJ5ziNNmkZtkPMaHMO2Fw1R3vAUgzVJsJcNFOqeUW99cRQkhLX9Kqw77k9E/s320/puttygen+1.PNG" width="320" /></a></div>
<br />
Once you import the file, you will see something like picture below.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDqXaTc5w0E-1CBhfvijKRuJEtvqgYyUEwmsgbOAsS5tmbhlStFR6I8HdaOAjW96z1i-dN4xYzNPlnAGwSuScVvm2XsoUKvTjS7ZW-lBRAX0Syl9CF8O700LibV7kK-F6N6lJro5_4ln8/s1600/puttygen+2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDqXaTc5w0E-1CBhfvijKRuJEtvqgYyUEwmsgbOAsS5tmbhlStFR6I8HdaOAjW96z1i-dN4xYzNPlnAGwSuScVvm2XsoUKvTjS7ZW-lBRAX0Syl9CF8O700LibV7kK-F6N6lJro5_4ln8/s320/puttygen+2.PNG" width="320" /></a></div>
<br />
Now you can export the private key to a .ppk file by clickng the "Save private key" button. If you want to protect the key with a passphrase, provide the password on the prompt, else leave it blank. Let us assume you have saved the private key to "MyKey.ppk"<br />
<br />
<h4>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://click.linksynergy.com/fs-bin/click?id=RCpc/BzltMk&offerid=467035.392&subid=0&type=4" style="margin-left: 1em; margin-right: 1em;"><img alt="Step forward in 2017: Build in-demand career skills with Coursera" border="0" src="https://ad.linksynergy.com/fs-bin/show?id=RCpc/BzltMk&bids=467035.392&subid=0&type=4&gridnum=16" /></a></div>
Step 3 - Configure PuTTY session</h4>
Now open PuTTY, by searching for it in the Start menu (Windows + S). It is not a bad idea to pin PuTTY to the task bar if you need to access it very frequently. You will see the below screen.<br />
<br />
1) Enter the dns name or the IP address of the server to connect to.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw3j3iJ_wBAqMndTO3lnaWLaRhK9XfoPaPehOeiI8_IzsKHiKAgdSpshlj_5LXJiH0a8P6RF1rFp5Bs7gq_G7giq3GSmv7ZqI7-cPwAv3q5PUe9JQc0H7DuopciC1fBBJIguMXO3naOi0/s1600/putty+1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="307" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw3j3iJ_wBAqMndTO3lnaWLaRhK9XfoPaPehOeiI8_IzsKHiKAgdSpshlj_5LXJiH0a8P6RF1rFp5Bs7gq_G7giq3GSmv7ZqI7-cPwAv3q5PUe9JQc0H7DuopciC1fBBJIguMXO3naOi0/s320/putty+1.PNG" width="320" /></a></div>
<br />
<br />
2) (Optional) Let us set a window title so that we can identify the shell window, if there are multiple PuTTY sessions going on<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirdQioKR9Lmt4TeVxy22YFHKI1fh9jnbtKXoOtUk_Uj2uCA4anO8dQpObWTJn1iAb-Uo196Ba9bomeNew42uBvFsE0n46NNk_aNK8rvduelaZsctxe6yV3b-XutMd-_O8YtA542Mygis4/s1600/putty+3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="309" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirdQioKR9Lmt4TeVxy22YFHKI1fh9jnbtKXoOtUk_Uj2uCA4anO8dQpObWTJn1iAb-Uo196Ba9bomeNew42uBvFsE0n46NNk_aNK8rvduelaZsctxe6yV3b-XutMd-_O8YtA542Mygis4/s320/putty+3.PNG" width="320" /></a></div>
<br />
3) (Optional) Let us disable automatic change of window title once login is complete<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjqw1NudMFMkCQaMjl5FbfkqlEiiiDFYJHuJR3WthEy0-xi-fOuJW1WPzpROiok-w65G4i4_sLTmoFQJhdWj9WUl3ylJxC_zTSS96w21P7ZZGOL8QwrxbTtAzGjjRQR8d7okUI8LswOII/s1600/putty+2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjqw1NudMFMkCQaMjl5FbfkqlEiiiDFYJHuJR3WthEy0-xi-fOuJW1WPzpROiok-w65G4i4_sLTmoFQJhdWj9WUl3ylJxC_zTSS96w21P7ZZGOL8QwrxbTtAzGjjRQR8d7okUI8LswOII/s320/putty+2.PNG" width="320" /></a></div>
<br />
<br />
4) If using userid/password for login, you can avoid being prompted for userid, by configuring it to the session<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTZWlLn-3SbEQvQ-tili99r1hyOEzxfjAVIofsp_Mskv76_eL2R7tVsXpkm4fQvtb5fQ3TisP_4PgLtgTxn1AF0KG1RHoGkWiwJgv3pGXRCFkz0JT_kGT8LUuxKIREiFDoiJ-6HqJ1_tE/s1600/putty+4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTZWlLn-3SbEQvQ-tili99r1hyOEzxfjAVIofsp_Mskv76_eL2R7tVsXpkm4fQvtb5fQ3TisP_4PgLtgTxn1AF0KG1RHoGkWiwJgv3pGXRCFkz0JT_kGT8LUuxKIREiFDoiJ-6HqJ1_tE/s320/putty+4.PNG" width="320" /></a></div>
<br />
Else if you are using key pair to login, specify the key pair as below<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0ENVchzCZM31ykEJHGjdGtkoAOceGExeQGHnPNdutZenyCDKiBD-tK7hRDd1URsJ83_7ERjI0hyphenhyphenX4rBSelMn8H29GNRyeXG1QygtJ6JaWFYkyAH-BsT3cC3JjTw9dn1Fl271xtN606P8/s1600/putty+5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="307" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0ENVchzCZM31ykEJHGjdGtkoAOceGExeQGHnPNdutZenyCDKiBD-tK7hRDd1URsJ83_7ERjI0hyphenhyphenX4rBSelMn8H29GNRyeXG1QygtJ6JaWFYkyAH-BsT3cC3JjTw9dn1Fl271xtN606P8/s320/putty+5.PNG" width="320" /></a></div>
<br />
<br />
5) Now let us save this session configuration to a meaningful name, so that it is easy to open this session with just a single click in future<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghqn3_o77nRGeT4YEAPOsvb2gzuBPxlDfjgmiRw60HrruPatOsjzM6P1vU-A3Y7ZcxPygNisn6KgEp13lWTRUNn-TDq1JKw8AeJLYDQ_z6-gXw7gFIsCuAPbuCvUZvuOSmK7TIqNMXZc0/s1600/putty+6.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghqn3_o77nRGeT4YEAPOsvb2gzuBPxlDfjgmiRw60HrruPatOsjzM6P1vU-A3Y7ZcxPygNisn6KgEp13lWTRUNn-TDq1JKw8AeJLYDQ_z6-gXw7gFIsCuAPbuCvUZvuOSmK7TIqNMXZc0/s320/putty+6.PNG" width="320" /></a></div>
<br />
<h4>
Step 4 - Load the PuTTY session and connect </h4>
Now to open an SSH connection, all you need to do is to select the session you want to launch and click the "Load" button and then "Open" button<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxOvx1QSrbmrjR9KW5ShiClSgLcQqFCEMycyxjRpDdGqyxqEFnMQkapFai870xmd5e5-fifVwyMV1os6QO5SHkM-041HgaQJribtVXTB2_HM-uRp9rEdl8SPUgA6A2rsMJ6jihrytkQtI/s1600/putty+7.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxOvx1QSrbmrjR9KW5ShiClSgLcQqFCEMycyxjRpDdGqyxqEFnMQkapFai870xmd5e5-fifVwyMV1os6QO5SHkM-041HgaQJribtVXTB2_HM-uRp9rEdl8SPUgA6A2rsMJ6jihrytkQtI/s320/putty+7.PNG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLqnOxx2LC-rvrlAksiQWBOzwGGKsNmd-Wucr1bmWY9RLoW0B3RIqbl-Mqk-JJO7zi_eDxLgD-V_dWz6GaCgimQzg8QRvdiP5Q-PZGim6nrephd5FyFydSAsUgnjUxIp2Z2qmggdY4fO4/s1600/putty+8.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLqnOxx2LC-rvrlAksiQWBOzwGGKsNmd-Wucr1bmWY9RLoW0B3RIqbl-Mqk-JJO7zi_eDxLgD-V_dWz6GaCgimQzg8QRvdiP5Q-PZGim6nrephd5FyFydSAsUgnjUxIp2Z2qmggdY4fO4/s320/putty+8.PNG" width="320" /></a></div>
<br />
<br />
And now you should be connected to your host via SSH.<br />
<br />
<br />
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-28957704741828340732013-10-23T21:49:00.004+05:302017-03-15T23:15:56.966+05:30Resolving Unsatisfied link error in OpenNI java on WindowsIf you are getting any of the following error while trying to Run OpenNI on a windows PC, follow the below steps to rid of the errors (I am assuming you are using Eclipse)<br />
<br />
java.lang.UnsatisfiedLinkError: C:\Program Files\OpenNI2\Redist\OpenNI2.jni.dll: Can't find dependent libraries<br />
<br />
or<br />
<br />
java.lang.UnsatisfiedLinkError: no OpenNI2.jni in java.library.path<br />
<br />
<a name='more'></a><br />
<br />
I am also assuming you have installed OpenNI2 in the folder C:\Program Files\OpenNI2<br />
<br />
<ul>
<li>Make sure you have org.openni.jar in your project and added to your build path</li>
<li>Then got Run -> Run Configurations and choose the tab named "Arguments"</li>
<li>In the section "VM Arguments" add the below entry </li>
</ul>
<span style="font-family: "courier new" , "courier" , monospace;"> -Djava.library.path=C:\Progra~1\OpenNI2\Redist\</span><br />
<br />
<ul>
<li>Now we have to load the dll manually as below</li>
</ul>
<div>
<pre class="brush:css, brush:html, brush:js, brush:php, brush:sql, brush:python"> try {
System.load("C:\\Program Files\\OpenNI2\\Tools\\OpenNI2.dll");
...
.. your remaining code here
..
OpenNI.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
</pre>
</div>
Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-7221197028910540972013-02-27T16:53:00.002+05:302017-03-15T09:42:42.862+05:30Connecting MK808 device to ADB using the bridge and OEM USB Drivers<br />
MK808 is a very cheap and handy Android device to play around. Connected to an HDMI monitor, we can easily run Android applications on this device. Before starting, we need to first connect MK808 to the ADB so that we can install/run/debug applications. OEM drivers provided by Google is not sufficient to connect the MK808 device to the ADB. After installing the OEM drivers, please follow the below steps<br />
<br />
<a name='more'></a><br />
<ul>
<li>Find out the vendor id of the device from device manager</li>
<li>To do this, connect the OTG port to the USB port of your computer</li>
</ul>
<ol><ul>
<li>Goto Start menu and right click on “My Computer” and chose “Properties”</li>
<li>Select the “Devices” option which will open “Device Manager”</li>
<li>Select your device (mostly in USB devices or Other devices) and right click and chose “Properties”</li>
<li>Choose “Details” tab and select “Hardware Ids” from the property dropdown, you can see the hardware id, in my case it was x2207</li>
</ul>
</ol>
<ul>
<li>Open android_winusb.inf and add these lines </li>
</ul>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">;<Device name> in our case I gave MK808<br />%SingleAdbInterface% = USB_INSTALL, USB\VID_2207&PID_0010&MI_01<br />%CompositeAdbInterface% = USB_INSTALL, USB\VID_2207&PID_0010&REV_0222&MI_01</span><br />
<ul>
<li>Open C:\Users\<your id>\.android\adb_usb.ini and add the following entry</li>
</ul>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">0x<device id> .. in our case it is 0x2207</span><br />
<ul>
<li>Restart ADB by</li>
</ul>
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">adb kill-server</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">abd start-server</span><br />
<br />
Now ADB should recognize the deviceSrijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-51531715880185190922013-02-27T16:47:00.000+05:302017-03-28T11:02:33.033+05:30Get Bitmap image from a YUV in Android<br />
Android Camera preview image is in YUV format. The YUV byte[] will have gray image in the first width*height bytes and color information next. For processing preview image without taking picture from Camera using Camera.takePicture method, mostly we need to convert the YUV byte[] into a Bitmap. Following code will help do that<br />
<br />
<a name='more'></a><br />
<pre class="brush:css, brush:html,brush:js, brush:php, brush:sql, brush:xml">import java.io.ByteArrayOutputStream;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ImageFormat;
import android.graphics.Rect;
import android.graphics.YuvImage;
public class Utils {
public static Bitmap getBitmapImageFromYUV(byte[] data, int width, int height) {
YuvImage yuvimage = new YuvImage(data, ImageFormat.NV21, width, height, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(0, 0, width, height), 80, baos);
byte[] jdata = baos.toByteArray();
BitmapFactory.Options bitmapFatoryOptions = new BitmapFactory.Options();
bitmapFatoryOptions.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap bmp = BitmapFactory.decodeByteArray(jdata, 0, jdata.length, bitmapFatoryOptions);
return bmp;
}
}
</pre>
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-7661310074101089802012-10-27T08:18:00.001+05:302017-03-15T09:42:27.134+05:30EXCEPTION_ACCESS_VIOLATION while using JavaCV Facerecognizer class<br />
The below error while executing JavaCV code happen mostly when you try to invoke a method on a non-existing pointer.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">#</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"># A fatal error has been detected by the Java Runtime Environment:</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">#</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"># EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000007feea1adf5f, pid=10548, tid=8644</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">#</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"># JRE version: 7.0_07-b11</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"># Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode windows-amd64 compressed oops)</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"># Problematic frame:</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"># C [jniopencv_contrib.dll+0xdf5f]</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">#</span><br />
<br />
We need to understand that JavaCV is a JNI wrapper for OpenCV and other similar native libraries. The objects returned using these methods work a bit different from the normal java objects. The above error happens mainly due to trying to operate on a pointer that no longer exists.<br />
Please refer to the below class, for example<br />
<br />
<a name='more'></a><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Class Test{</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">FaceRecognizer fr = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Test(){</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">FaceRecognizerPtr ptr_binary = createLBPHFaceRecognizer(1, 8, 8, 8, binaryTreshold);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">fr = ptr_binary.get();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">}</span><br />
In this case, normal java will keep the reference to fr even if the constructor is executed. But in JNI it totally depends on the underlying implementation. Since OpenCV is implemented based on C++ and what is being returned is a pointer, the fr will be garbage collected once ptr_binary go out of scope. So invoking any method on the class level variable will cause the ACCESS_VIOLATION exception.<br />
Changing the class as shown below will resolve the issue<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Class Test{</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">FaceRecognizer fr = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">FaceRecognizerPtr ptr_binary =null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">Test(){</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">ptr_binary = createLBPHFaceRecognizer(1, 8, 8, 8, binaryTreshold);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">fr = ptr_binary.get();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">}</span><br />
So, the point is if you find this kind of exception, please make sure you are not operating on objects that has a potential to go out of scope. And keep in mind that general java rules for object relations and scope might not hold good while using JNI.<br />
<div>
<br /></div>
Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-67978684779527814512012-10-27T08:14:00.003+05:302017-03-15T09:23:14.798+05:30Creating an LBPH (Local Binary Pattern Histogram) face recognizer using FaceRecognizer class in JavaCV <br />
In this article we will discuss how to create a Java based LBP face recognizer using JavaCV. JavaCV is a wrapper to the Open CV libraries for image processing. The workflow that I am trying to implement is as below<br />
<br />
<ul>
<li>The calling program will supply a bunch of images and a person name to this class ( <span style="font-family: "courier new" , "courier" , monospace;">learnNewFace(String personName, IplImage[] images)</span></li>
<li>The class will store the images in a folder and map the person name to an integer id</li>
<li>The class will then read all the images and person names and train the model</li>
<li>Once training is complete client can invoke identifyFace method giving an image to find out the matching<span style="font-family: "courier new" , "courier" , monospace;"> personName (identifyFace(IplImage image))</span></li>
</ul>
<br />
<a name='more'></a><br />
<br />
<b>Step -1)</b><br />
Install JDK and Eclipse ( I used JDK 7 on 64 bit Windows 7 PC)<br />
<br />
<b>Step-2)</b><br />
Install OpenCV and JavaCV(details can be found at http://code.google.com/p/javacv/). One thing we need to keep in mind is that the bit-ness of JDK and JavaCV and OpenCV must match. That means for a 64 bit JDK, you have to use the javacv-linux-x86_64 jar along with the other jar files. Also, please make sure you extract the opencv to C:\ drive. Extracting anywhere else is a nightmare, to setup the correct path variables.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAvIZRBcd_hAgf9_MSs6YmGK5YiUCMC66jZUOijHWKdQvuv2ayruh1POJike87Rkd8BzB0WCFE4W5mDB1gGqK6YZMYETPBtnk2MSJashs0G6332XqLjOXpJ0rkZFZC4I8OFE4az6USFMg/s1600/image002.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAvIZRBcd_hAgf9_MSs6YmGK5YiUCMC66jZUOijHWKdQvuv2ayruh1POJike87Rkd8BzB0WCFE4W5mDB1gGqK6YZMYETPBtnk2MSJashs0G6332XqLjOXpJ0rkZFZC4I8OFE4az6USFMg/s320/image002.png" width="195" /></a></div>
<br />
<br />
<b>Step -3)</b><br />
Create a new Java project in Eclipse and add the following jar files to the class path<br />
javacv.jar, javacpp.jar and one of the javacv-linux-x86.jar,javacv-linux-x86_64.jar,javacv-macosx-x86_64.jar,javacv-windows-x86.jar,javacv-windows-x86_64.jar according to your operating system<br />
The workspace should look like this<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi20rSj0WpnAB0lJlL1u5y1JklD2mNRH1NQf8IPBzNfIzuP2Rf-7upkukIb2NFuY8uVwVlLrqhcIjXPjqp-ojDR7oiG3GZSEbTVEgSepk9bsDthlWSxz73MmWHFzR1g3lJq7Lt4BpjGD4s/s1600/image001.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi20rSj0WpnAB0lJlL1u5y1JklD2mNRH1NQf8IPBzNfIzuP2Rf-7upkukIb2NFuY8uVwVlLrqhcIjXPjqp-ojDR7oiG3GZSEbTVEgSepk9bsDthlWSxz73MmWHFzR1g3lJq7Lt4BpjGD4s/s1600/image001.png" /></a></div>
<br />
<br />
<b>Step-4)</b><br />
Create a new class LBPFaceRecognizer in a package and copy the below code<br />
The code is given below<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">package com.test.face;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_core.CV_32SC1;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_core.IPL_DEPTH_8U;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_core.cvCreateImage;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_core.cvGetSize;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_core.cvLoad;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_core.cvSetImageROI;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_highgui.cvSaveImage;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_imgproc.CV_BGR2GRAY;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_imgproc.CV_INTER_LINEAR;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_imgproc.cvCvtColor;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_imgproc.cvEqualizeHist;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_imgproc.cvResize;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import static com.googlecode.javacv.cpp.opencv_objdetect.cvHaarDetectObjects;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import java.io.File;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import java.io.FileInputStream;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import java.io.FileOutputStream;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import java.util.Iterator;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import java.util.Properties;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import java.util.Set;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacpp.Loader;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_contrib.FaceRecognizer;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_contrib.FaceRecognizerPtr;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_core.CvMat;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_core.CvMemStorage;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_core.CvRect;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_core.CvSeq;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_core.IplImage;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_core.MatVector;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_objdetect;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">import com.googlecode.javacv.cpp.opencv_objdetect.CvHaarClassifierCascade;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">public class LBPFaceRecognizer {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private static String faceDataFolder = "C:\\test\\data\\";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> public static String imageDataFolder = faceDataFolder + "images\\";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private static final String CASCADE_FILE = "C:\\opencv\\data\\haarcascades\\haarcascade_frontalface_alt.xml";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private static final String frBinary_DataFile = faceDataFolder + "frBinary.dat";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> public static final String personNameMappingFileName = faceDataFolder + "personNumberMap.properties";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> final CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(CASCADE_FILE));</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private Properties dataMap = new Properties();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private static LBPFaceRecognizer instance = new LBPFaceRecognizer();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> public static final int NUM_IMAGES_PER_PERSON =10;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> double binaryTreshold = 100;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> int highConfidenceLevel = 70;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> FaceRecognizerPtr ptr_binary = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private FaceRecognizer fr_binary = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private LBPFaceRecognizer() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> createModels();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> loadTrainingData();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> public static LBPFaceRecognizer getInstance() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> return instance;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private void createModels() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> ptr_binary = createLBPHFaceRecognizer(1, 8, 8, 8, binaryTreshold);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> fr_binary = ptr_binary.get();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> protected CvSeq detectFace(IplImage originalImage) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> CvSeq faces = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Loader.load(opencv_objdetect.class);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> try {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage grayImage = IplImage.create(originalImage.width(), originalImage.height(), IPL_DEPTH_8U, 1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> cvCvtColor(originalImage, grayImage, CV_BGR2GRAY);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> CvMemStorage storage = CvMemStorage.create();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> faces = cvHaarDetectObjects(grayImage, cascade, storage, 1.1, 1, 0);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> } catch (Exception e) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> e.printStackTrace();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> return faces;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> public String identifyFace(IplImage image) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.println("==========================================================");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> String personName = "";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Set keys = dataMap.keySet();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (keys.size() > 0) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> int[] ids = new int[1];</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> double[] distance = new double[1];</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> int result = -1;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> fr_binary.predict(image, ids, distance);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> //just deriving a confidence number against treshold</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> result = ids[0];</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (result > -1 && distance[0]<highConfidenceLevel) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> personName = (String) dataMap.get("" + result);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> return personName;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> //The logic to learn a new face is to store the recorded images to a folder and retrain the model</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> //will be replaced once update feature is available</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> public boolean learnNewFace(String personName, IplImage[] images) throws Exception {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> int memberCounter = dataMap.size();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if(dataMap.containsValue(personName)){</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Set keys = dataMap.keySet();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Iterator ite = keys.iterator();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> while (ite.hasNext()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> String personKeyForTraining = (String) ite.next();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> String personNameForTraining = (String) dataMap.getProperty(personKeyForTraining);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if(personNameForTraining.equals(personName)){</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> memberCounter = Integer.parseInt(personKeyForTraining);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.println("Person already exist.. re-learning..");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> dataMap.put("" + memberCounter, personName);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> storeTrainingImages(personName, images);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> retrainAll();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> return true;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> public IplImage preprocessImage(IplImage image, CvRect r){</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage gray = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage roi = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> CvRect r1 = new CvRect(r.x()-10, r.y()-10, r.width()+10, r.height()+10);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> cvCvtColor(image, gray, CV_BGR2GRAY);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> cvSetImageROI(gray, r1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> cvResize(gray, roi, CV_INTER_LINEAR);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> cvEqualizeHist(roi, roi);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> return roi;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private void retrainAll() throws Exception {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Set keys = dataMap.keySet();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (keys.size() > 0) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> MatVector trainImages = new MatVector(keys.size() * NUM_IMAGES_PER_PERSON);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> CvMat trainLabels = CvMat.create(keys.size() * NUM_IMAGES_PER_PERSON, 1, CV_32SC1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Iterator ite = keys.iterator();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> int count = 0;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.print("Loading images for training...");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> while (ite.hasNext()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> String personKeyForTraining = (String) ite.next();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> String personNameForTraining = (String) dataMap.getProperty(personKeyForTraining);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage[] imagesForTraining = readImages(personNameForTraining);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage grayImage = IplImage.create(imagesForTraining[0].width(), imagesForTraining[0].height(), IPL_DEPTH_8U, 1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> for (int i = 0; i < imagesForTraining.length; i++) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> trainLabels.put(count, 0, Integer.parseInt(personKeyForTraining));</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> cvCvtColor(imagesForTraining[i], grayImage, CV_BGR2GRAY);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> trainImages.put(count,grayImage);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> count++;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> //storeNormalizedImages(personNameForTraining, imagesForTraining);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.println("done.");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.print("Training Binary model ....");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> fr_binary.train(trainImages, trainLabels);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.println("done.");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> storeTrainingData();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private void loadTrainingData() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> try {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> File personNameMapFile = new File(personNameMappingFileName);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (personNameMapFile.exists()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> FileInputStream fis = new FileInputStream(personNameMappingFileName);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> dataMap.load(fis);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> fis.close();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> File binaryDataFile = new File(frBinary_DataFile);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.print("Loading Binary model ....");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> fr_binary.load(frBinary_DataFile);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.println("done");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> } catch (Exception e) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> e.printStackTrace();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private void storeTrainingData() throws Exception {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.print("Storing training models ....");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> File binaryDataFile = new File(frBinary_DataFile);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (binaryDataFile.exists()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> binaryDataFile.delete();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> fr_binary.save(frBinary_DataFile);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> File personNameMapFile = new File(personNameMappingFileName);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (personNameMapFile.exists()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> personNameMapFile.delete();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> FileOutputStream fos = new FileOutputStream(personNameMapFile, false);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> dataMap.store(fos, "");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> fos.close();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> System.err.println("done.");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> public void storeTrainingImages(String personName, IplImage[] images) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> for (int i = 0; i < images.length; i++) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> String imageFileName = imageDataFolder + "training\\" + personName + "_" + i + ".bmp";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> File imgFile = new File(imageFileName);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (imgFile.exists()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> imgFile.delete();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> cvSaveImage(imageFileName, images[i]);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> private IplImage[] readImages(String personName) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> File imgFolder = new File(imageDataFolder);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage[] images = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (imgFolder.isDirectory() && imgFolder.exists()) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> images = new IplImage[NUM_IMAGES_PER_PERSON];</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> for (int i = 0; i < NUM_IMAGES_PER_PERSON; i++) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> String imageFileName = imageDataFolder + "training\\" + personName + "_" + i + ".bmp";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage img = cvLoadImage(imageFileName);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> images[i] = img;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> return images;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">}</span><br />
<br />
<b>Step-5)</b><br />
Write a client code. The client code must do the following<br />
<br />
1) Get an instance of the face recognizer<br />
<span style="font-family: "courier new" , "courier" , monospace;">LBPFaceRecognizer fr = LBPFaceRecognizer.getInstance();</span><br />
2) Capture image and grab the face coordinates using the code described here<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">FrameGrabber grabber = new OpenCVFrameGrabber(0);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> grabber.start();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage img = grabber.grab();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> IplImage snapshot = cvCreateImage(cvGetSize(img), img.depth(), img.nChannels());</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> cvFlip(img, snapshot, 1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> CvSeq faces = fr.detectFace(img);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> CvRect r = new CvRect(cvGetSeqElem(faces, 0));</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
3) Preprocess the image using fr.preprocess<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">trainImages[imageCounter] = fr.preprocessImage(img, r);</span><br />
4) Invoke the learn method<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">fr.learnNewFace("User1", trainImages);</span><br />
5) Once the learning is complete you can use fr.identiofyFace to identify a face<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">fr.identifyFace(fr.preprocessImage(img, r));</span><br />
<br />
NOTE: The convenience method <span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">preprocessImage </span>is used to clip face, resize and normalize image to improve accuracy.<br />
Happy coding :)<br />
<div>
<br /></div>
Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-5916333717779523782012-07-02T01:54:00.000+05:302017-03-15T09:44:12.201+05:30Creating xxx.activity.out.xml and failing with Error in an XML file: aborting build.It was very annoying when I created a basic Android activity (say activity_test.xml) and tried to run in emulator it fails with an error message stating "Error in an XML file: aborting build."<br />
<br />
When you look in editor, you can see that it created a new blank file named activity_test.out.xml and it has an error "No XML content. Please add a root view or layout to your document."<br />
<br />
I started playing around a little and found that the root cause of this issue is more of an Eclipse pattern, not any error. When you click the "Run" button in Eclipse, it uses the default launch configuration registered for the selected file. What is happening is, the selected file happens to be the layout file activity_text.xml and Eclipse launches an XSL launch configuration and it fails.<br />
<br />
Two ways to fix this issue is listed below<br />
<br />
<a name='more'></a><br />
<br />
1) Instead of using "Run" button, select the project, right click and "Run as " > "Android Application"<br />
<br />
Or<br />
<br />
2) Open Window -> Preferences -> Run/Debug -> Launching -> Launch Configurations<br />
Select the check box that says "Filter checked launch configuration types" and scroll down and select "XSL"<br />
<span style="background-color: white;">and click Apply</span><br />
<br />
Make sure you delete the xxx.out.xml before you run again.<br />
<br />
This should fix the issue. Happy Droiding!!Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-71927320985945191792012-04-01T23:47:00.000+05:302017-03-15T23:18:49.898+05:30How to decrypt an LTPA cookie and view the user information<br />
Lightweight Third-Party Authentication (LTPA), is an authentication technology used in IBM WebSphere and Lotus Domino products. When accessing web servers that use the LTPA technology it is possible for a web user to re-use their login across physical servers.<br />
<br />
In a business that extensively use different IBM products, it is possible to configure LTPA tokens to communicate authentication information between different platforms. For example, an IBM WebSphere Application Server based web application can be configured to propagate the credentials of the logged in user to a WebSphere Process Server based process using LTPA cookies. In a perfect world when everything works fine, there is no issue, but there are several instances when communication does not work as expected and there is a need to see the values that was sent and received as LTPA cookies for diagnostic purposes.<br />
<br />
<a name='more'></a><br />
From the trace logs we can find that the LTPA cookie is a Base64 encoded encrypted cookie. The encryption key itself is encrypted in DESede/ECB/PKCS5Padding mode with the SHA hash of the LTPA token password (supplied while exporting the token) padded with 0X0 up to 24 bytes. Then the data in the cookie is encrypted using the above key using AES/CBC/PKCS5Padding or DESede/ECB/PKCS5Padding. So inorder to decrypt the cookie correctly, we need<br />
1) The LTPA token (which can be read using any ASCII based text editor) that contains the DES Key and the private and public keys<br />
2) The password using the LTPA token was exported<br />
<br />
Once we have these information, use the below code to decrypt the cookie<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">import java.security.MessageDigest;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import java.text.SimpleDateFormat;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import java.util.Arrays;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import java.util.Date;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import java.util.StringTokenizer;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">import javax.crypto.Cipher;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.crypto.SecretKey;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.crypto.SecretKeyFactory;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.crypto.spec.DESedeKeySpec;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.crypto.spec.IvParameterSpec;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.crypto.spec.SecretKeySpec;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">import org.apache.commons.codec.binary.Base64;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">public class DecryptLTPA {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> private static final String AES = "AES/CBC/PKCS5Padding";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> private static final String DES = "DESede/ECB/PKCS5Padding";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> public static void main(String[] args) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> String ltpaKey = "<DES key from ltpa token>";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> String ltpaPassword = "<password used to export ltpa token>";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> String tokenCipher = "<the header text to dercypt>";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> try {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Base64 b = new Base64();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> byte[] secretKey = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> MessageDigest md = MessageDigest.getInstance("SHA");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> md.update(ltpaPassword.getBytes());</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> byte[] hash3DES = new byte[24];</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> System.arraycopy(md.digest(), 0, hash3DES, 0, 20);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Arrays.fill(hash3DES, 20, 24, (byte) 0);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> secretKey = decrypt(b.decode(ltpaKey), hash3DES, DES);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> byte[] ltpaByteArray = b.decode(tokenCipher);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> String algorithm, userInfo, expires, signature, ltpaPlaintext;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> try {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> algorithm="DES";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> ltpaPlaintext = new String(decrypt(ltpaByteArray, secretKey, DES));</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> } catch (Exception e) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> algorithm="AES";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> ltpaPlaintext = new String(decrypt(ltpaByteArray, secretKey, AES));</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> System.err.println("Alogorithm:["+algorithm+"]");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> StringTokenizer st = new StringTokenizer(ltpaPlaintext, "%");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> userInfo = st.nextToken();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> expires = st.nextToken();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> signature = st.nextToken();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> System.err.println("Full token string:[" + ltpaPlaintext + "]");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Date d = new Date(Long.parseLong(expires));</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss z");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> System.err.println("Token is for:[" + userInfo + "]");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> System.err.println("Token expires at:[" + sdf.format(d) + "]");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> System.err.println("Token signature:[" + signature + "]");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> } catch (Exception e) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> e.printStackTrace();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> public static byte[] decrypt(byte[] ciphertext, byte[] key, String algorithm) throws Exception {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> SecretKey sKey = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> if (algorithm.indexOf("AES") != -1) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> sKey = new SecretKeySpec(key, 0, 16, "AES");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> } else {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> DESedeKeySpec kSpec = new DESedeKeySpec(key);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> SecretKeyFactory kFact = SecretKeyFactory.getInstance("DESede");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> sKey = kFact.generateSecret(kSpec);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Cipher cipher = Cipher.getInstance(algorithm);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> if (algorithm.indexOf("ECB") == -1) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> if (algorithm.indexOf("AES") != -1) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IvParameterSpec ivs16 = generateIvParameterSpec(key, 16);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> cipher.init(Cipher.DECRYPT_MODE, sKey, ivs16);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> } else {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IvParameterSpec ivs8 = generateIvParameterSpec(key, 8);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> cipher.init(Cipher.DECRYPT_MODE, sKey, ivs8);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> } else {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> cipher.init(Cipher.DECRYPT_MODE, sKey);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> return cipher.doFinal(ciphertext);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> private static IvParameterSpec generateIvParameterSpec(byte key[], int size) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> byte[] row = new byte[size];</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> for (int i = 0; i < size; i++) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> row[i] = key[i];</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> return new IvParameterSpec(row);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<br />
<br />
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-69163353712541693592012-04-01T01:12:00.000+05:302017-03-15T09:22:04.278+05:30How to use a4j:repeat and a4j:commandLink to have expandable data rows that brings contents via Ajax<br />
We will discuss a way to use<span style="font-family: "courier new" , "courier" , monospace;"> a4j:repeat </span>to create a tabular structure on a JSF page, where each row can be further expanded via Ajax. I am assuming that you have Ajax4JSF installed in your web application. If not, refer this link to install Ajax4JSF in your web application.<br />
<br />
This is the requirement. User selects a state from the dropdown, and based on the selected state we need to create a table that list all the zip codes in the state. User can then click the zip code, which will expand the row and paint all the subscribers from that zip code. Since the size of data is going to be huge, we decided to load the content via ajax<br />
<br />
<a name='more'></a><br />
Since we have multiple zip codes within each state and multiple customers within each zipcode, we cannot use simple datatable even to list the zip codes. In order to use ajax functions inside repeated elements (which inturn is dynamic), we have to use<span style="font-family: "courier new" , "courier" , monospace;"> a4j:repeat </span>tag, otherwise the dynamic ids created by JSF framework could create issues while rerendering the ajax content to a specific row.<br />
<br />
I am assuming you have already written the code to load zip codes for the selected state. Let us say the zip codes for the selected state are available in <span style="font-family: "courier new" , "courier" , monospace;">zipCodes </span>field on the backing bean. I am also assuming that we have the code in backing bean to get all subscribers for a given zip code and the subscribers for the given zip code is available in a <span style="font-family: "courier new" , "courier" , monospace;">HashMap </span>field in backing bean named <span style="font-family: "courier new" , "courier" , monospace;">subscribersForZip</span><br />
<br />
So, in short, backing bean will look something like this<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">public class ZipSubscriberBackingBean {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> private List<SelectItem> states;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> private List<String> zipCodes;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> private Map<String, List<String>> subscribersForZip;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> .......</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> getters and setters</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> .......</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> public void getZipsForState(){</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> //get selected state from request</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> //get zips for state from modal</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> //set the zips to zipCodes</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> public void getSubscribersForZip(){</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> //get selected zip from request parameter</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> //if zip not in Map, get subscribers from modal</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> //add list of subscribers to the Map with zip as key</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
Assuming the States dropdown is hooked up correctly, below code will paint the zip codes in a table, with a link on zipcode so that user can click to expand<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"> <a4j:repeat id="zipCodesForState" value="#{backingbean.zipCodes}" var="zip" ></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <t:panelGroup></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <a4j:commandLink action="#{backingbean.getSubscribersForZip}" reRender="subscriberSection" value="#{zip}"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> oncomplete="javascript:postAjax(this);" id="ajaxLink" ></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <cfui:urlEncodedParam name="zipCode" value="#{zip}"/></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </a4j:commandLink></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <a4j:outputPanel ajaxRendered="true" id="subscriberSection"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <t:dataTable border="1" value="#{backingbean.subscribersForZip[zip]}" var"subName"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <t:column></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <f:facet name="header"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <h:outputText value="Subscriber Name" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </f:facet></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <h:outputText id="subName" value="#{subName}" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </t:column></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </a4j:outputPanel></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </t:panelGroup></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </a4j:repeat></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<br />
<br />
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-14824721632454846502012-02-05T09:50:00.000+05:302017-03-15T09:46:47.653+05:30How to resolve "Error executing aapt. Please check aapt is present at xxxxxx folder"I have Eclipse Helios running on 64 bit Ubuntu and I was getting the error message "<span style="font-family: "courier new" , "courier" , monospace;">Error executing aapt. Please check aapt is present at xxxxxx folder</span>" when I tried to compile the Android project. With a little R&D I found that this error happens because, when we install 64 bit Android libraries, there are few 32 bit libraries that we need to install manually.<br />
<div>
<br /></div>
<div>
To get rid of this error, we need to install the 32 bit libraries by executing the below command</div>
<div>
<br /></div>
<div>
First navigate to the folder where you have installed the Android SDK. </div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">cd /usr/lib/android-sdk-linux/</span></div>
<div>
<br /></div>
<div>
Now run apt-get to install the 32 bit libraries</div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">sudo apt-get install ia32-libs</span></div>
<div>
<br /></div>
<div>
Once the install is complete, restart Eclipse and you should be good to go.</div>
Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-83803495810106224342012-01-28T09:52:00.000+05:302017-03-15T09:43:48.712+05:30An easy way to add a new Activity in an Android application when using EclipseAdding an Activity in an Android application is very simple and straight forward. Activity classes can be created by extending <span style="font-family: "courier new" , "courier" , monospace;">android.app.Activity</span> class and overriding each methods manually. If you do not want to type in all these code manually, there is an easy way to create new Activity when using Eclipse. Eclipse UI provides a very easy and fast way to create new activities.The generated class can also have the code that overrides all the methods from the Activity class, already inserted for you. Here is how we do it.<br />
<br />
<a name='more'></a><br />
Step 1) Open the AndroidManifest.xml<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJtRIpCkbV7UqpWvJebRgdLh81Gs_myJr5Uq8EnMhvytBJz_kqMqD120uBMzyaLR3NvRn7fTgEMGUbZ_oZibbUhnQ7VoqosuwYt33bT2nSK7rFpvvL04t8PVFBiutoggLbjU4JZ4rrYY8/s1600/ScreenHunter_05+Jan.+27+23.10.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJtRIpCkbV7UqpWvJebRgdLh81Gs_myJr5Uq8EnMhvytBJz_kqMqD120uBMzyaLR3NvRn7fTgEMGUbZ_oZibbUhnQ7VoqosuwYt33bT2nSK7rFpvvL04t8PVFBiutoggLbjU4JZ4rrYY8/s320/ScreenHunter_05+Jan.+27+23.10.jpg" width="193" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt5Z9K6yBWsWJRmlXCZ0hSWtOSPCgxQUfPJvYxEnboCN2LTTfRybOwkDUJq1Tx3hOX8q4JJM9Qsns85p-iCaE_KDBBCQvCrh-o0BW_ApWN9xml1skOOeZ2H1UsZlvL6O9g-vRYW0ZqI3s/s1600/ScreenHunter_05+Jan.+27+23.11.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt5Z9K6yBWsWJRmlXCZ0hSWtOSPCgxQUfPJvYxEnboCN2LTTfRybOwkDUJq1Tx3hOX8q4JJM9Qsns85p-iCaE_KDBBCQvCrh-o0BW_ApWN9xml1skOOeZ2H1UsZlvL6O9g-vRYW0ZqI3s/s400/ScreenHunter_05+Jan.+27+23.11.jpg" width="400" /></a></div>
<br />
<br />
Step 2) Click on the "Application" tab<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivtzaLp8dtjwu3EVVofT2JQSJWZl9sat_bQg555hkWRbiPX8Loz_xKnQvOT2moFswyr_S6ldt-Xl38Ov8iN9G6uHMxg-dOGLZJMqT1y8vrOcXOyjihVakyZGOK1kTTKwtlvsc4gHlPiQs/s1600/ScreenHunter_05+Jan.+27+23.13.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="357" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivtzaLp8dtjwu3EVVofT2JQSJWZl9sat_bQg555hkWRbiPX8Loz_xKnQvOT2moFswyr_S6ldt-Xl38Ov8iN9G6uHMxg-dOGLZJMqT1y8vrOcXOyjihVakyZGOK1kTTKwtlvsc4gHlPiQs/s400/ScreenHunter_05+Jan.+27+23.13.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Step 3) In the Application Nodes section, click on "Add..." and select the "Create a new element at the top level, in Application" and select "Activity" and click "OK"</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixyh5NOZu5L1FRMdt___Ap65BQAyV3bUTia87-tqQOKi29mrZ31n4rdQbZArw5Ii_tWMqlh7qNVDN39VU1aL5R3pY-MH9KrMYPQFW8FGLRV8Gny1JF7eKeXHZS2RklL8mgXne3IyksCSQ/s1600/ScreenHunter_05+Jan.+27+23.15.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="395" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixyh5NOZu5L1FRMdt___Ap65BQAyV3bUTia87-tqQOKi29mrZ31n4rdQbZArw5Ii_tWMqlh7qNVDN39VU1aL5R3pY-MH9KrMYPQFW8FGLRV8Gny1JF7eKeXHZS2RklL8mgXne3IyksCSQ/s400/ScreenHunter_05+Jan.+27+23.15.jpg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Step 4) Select the activity and click on the "Name*" hyperlink and enter the name and other details for the new class and click "Finish". You are all set with the new Activity class</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM6T4Dj66jvE4fB55fo_lGp7PkXuU2yp8_hESDjiJbT_23M3ddo_-AzMsk9sHbT-RRPkISKTHUpiMallV-wRd2o0qGWDlNtuLo7KUN4rqVomVb02zFZNpWSIoZeXuY2R6csmb26-PTmHs/s1600/ScreenHunter_05+Jan.+27+23.18.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM6T4Dj66jvE4fB55fo_lGp7PkXuU2yp8_hESDjiJbT_23M3ddo_-AzMsk9sHbT-RRPkISKTHUpiMallV-wRd2o0qGWDlNtuLo7KUN4rqVomVb02zFZNpWSIoZeXuY2R6csmb26-PTmHs/s400/ScreenHunter_05+Jan.+27+23.18.jpg" width="343" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-68739446905811137392012-01-28T09:27:00.000+05:302017-03-15T09:45:38.904+05:30Passing dynamic data from one Activity to another Activity using Bundle in Android applicationsOne of the basic requirement in any Android application development is the ability to navigate to one Activity from another Activity on an action or event. Also, in most of the cases, we would want to pass data from the source activity to the destination activity. If the number of parameters that need to be passed from one activity to another is static and is known during compile time, we can use <span style="font-family: "courier new" , "courier" , monospace;">Intent.putExtra(key, value)</span> method to pass the data. But when the parameters are unknown at compile time and are dynamic in nature, we cannot set the values at compile time directly to the Intent. In this case we will use Bundles. Let us discuss how we can achieve this when we develop Android applications using Eclipse.<br />
<br />
<a name='more'></a><br />
In our example, we have a LearningActivity (which is the first screen of my application) and a HelloActivity (this would be the activity that I would like to navigate to). The LearningActivity class uses a simple layout that contains an TextEdit and a Button.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgT8D95SqnroKi-sUt9OFn-isy7X7EVl-97tNtuZuCEcbHe843iLVPjYzcjR9A7cZcmpKvBIN6FnffExoXZT1GK9bkuf0kKdLZaK4-3xk-KW6o4OfePtAhJN7UIuCq8n_OgJLpt5v1lTY/s1600/ScreenHunter_03+Jan.+27+22.46.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgT8D95SqnroKi-sUt9OFn-isy7X7EVl-97tNtuZuCEcbHe843iLVPjYzcjR9A7cZcmpKvBIN6FnffExoXZT1GK9bkuf0kKdLZaK4-3xk-KW6o4OfePtAhJN7UIuCq8n_OgJLpt5v1lTY/s320/ScreenHunter_03+Jan.+27+22.46.jpg" width="320" /></a></div>
<br />
User can enter his name in the text box and on click of the button.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8FGsOJpBfcjiPuh9MXYFrAp7Tmp7GhNlGSwS9xfR7nkDSo7iY8PxzvL4cMtFqD4eRNDPZ-brTOZA5gyxosn_Cbn3ZTg7ycN0EJeIM1By29zz6ocku_XqzQ6QWX9Lmz7onJZeIfsErR5Q/s1600/ScreenHunter_04+Jan.+27+22.46.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="289" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8FGsOJpBfcjiPuh9MXYFrAp7Tmp7GhNlGSwS9xfR7nkDSo7iY8PxzvL4cMtFqD4eRNDPZ-brTOZA5gyxosn_Cbn3ZTg7ycN0EJeIM1By29zz6ocku_XqzQ6QWX9Lmz7onJZeIfsErR5Q/s320/ScreenHunter_04+Jan.+27+22.46.jpg" width="320" /></a></div>
<br />
When user clicks the button, we want to pass the name that user entered and start HelloActivity which will simply print Hello with the name.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYrVvXkwax6stR1RePxDQ7njo0qp_ARjS3VtoIVHOa-ti24QAoUbxaOTnLjuqMVvLx8kY2HyWR8WUIOv28KbOreGkT2Kys0ie8qLuRYgUe93z5yNxWUDhOJ3VrzRCy10SJ838gowwqkow/s1600/ScreenHunter_05+Jan.+27+22.46.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="292" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYrVvXkwax6stR1RePxDQ7njo0qp_ARjS3VtoIVHOa-ti24QAoUbxaOTnLjuqMVvLx8kY2HyWR8WUIOv28KbOreGkT2Kys0ie8qLuRYgUe93z5yNxWUDhOJ3VrzRCy10SJ838gowwqkow/s320/ScreenHunter_05+Jan.+27+22.46.jpg" width="320" /></a></div>
<br />
<br />
Let us get into action. This is what we are going to do<br />
<br />
<ol>
<li>Attach an onclick listener to the button.</li>
<li>On click of the button, read the entry in the text box</li>
<li>Add the data to a Bundle</li>
<li>Create an Intent with the target activity</li>
<li>Set the bundle as extras to the Intent</li>
<li>Start the next activity</li>
</ol>
<br />
I have added the full source code below. My eclipse project structure is as below<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqmYEzjk-Zk-M6popUhD1PTyMSXyr953G0nKYKX4DZrwrdzrCOGfAjAl5m8MUvFxOO_eenUinjuGWImqDO4AwF5tv3OqdifUaNzZxo8D_w8VaVxR8Bbz1lXoPIbp8EnyaGobpgRL3RTeI/s1600/ScreenHunter_05+Jan.+27+22.53.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqmYEzjk-Zk-M6popUhD1PTyMSXyr953G0nKYKX4DZrwrdzrCOGfAjAl5m8MUvFxOO_eenUinjuGWImqDO4AwF5tv3OqdifUaNzZxo8D_w8VaVxR8Bbz1lXoPIbp8EnyaGobpgRL3RTeI/s400/ScreenHunter_05+Jan.+27+22.53.jpg" width="268" /></a></div>
<br />
<br />
Below is the layout, <span style="font-family: "courier new" , "courier" , monospace;">main.xml</span>, that LearningActivity uses<br />
<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><?xml version="1.0" encoding="utf-8"?></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_width="fill_parent"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_height="fill_parent"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:orientation="vertical" ></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> <TextView</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:id="@+id/textView1"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_width="wrap_content"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_height="wrap_content"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:text="Enter your name:" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> <EditText</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:id="@+id/editText1"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_width="match_parent"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_height="wrap_content" ></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> <requestFocus /></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </EditText></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> <Button</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:id="@+id/button1"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_width="wrap_content"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_height="wrap_content"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:text="Click Me" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"></LinearLayout></span><br />
<br />
Here is the <span style="font-family: "courier new" , "courier" , monospace;"><b>LearningActivity </b></span>class<br />
<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">package com.test;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">import android.app.Activity;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.content.Context;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.content.Intent;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.os.Bundle;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.view.View;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.view.View.OnClickListener;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.widget.Button;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.widget.EditText;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">public class LearningActivity extends Activity {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> /** Called when the activity is first created. */</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> @Override</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> public void onCreate(Bundle savedInstanceState) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> super.onCreate(savedInstanceState);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> setContentView(R.layout.main);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> final Context ctx = this;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Button b = (Button)findViewById(R.id.button1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> b.setOnClickListener(new OnClickListener() {</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "courier new" , "courier" , monospace;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public void onClick(View v) {<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>EditText et = (EditText)findViewById(R.id.editText1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>String userName = et.getText().toString();</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "courier new" , "courier" , monospace;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Bundle b = new Bundle();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>b.putString("NAME", userName);</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "courier new" , "courier" , monospace;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Intent t = new Intent(ctx, HelloActivity.class);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>t.putExtras(b);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>startActivity(t);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<br />
<br />
<br />
Here is <span style="font-family: "courier new" , "courier" , monospace;">hello.xml</span>, which is the layout that <span style="font-family: "courier new" , "courier" , monospace;">HelloActivity </span>uses<br />
<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><?xml version="1.0" encoding="utf-8"?></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_width="match_parent"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_height="match_parent"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:orientation="vertical" ></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> <TextView</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:id="@+id/textView1"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_width="match_parent"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:layout_height="wrap_content"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> android:text="TextView" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"></LinearLayout></span><br />
<br />
and here is the code for <span style="font-family: "courier new" , "courier" , monospace;"><b>HelloActivity</b></span><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">package com.test;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">import android.app.Activity;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.os.Bundle;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import android.widget.TextView;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">public class HelloActivity extends Activity {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>/** Called when the activity is first created. */</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>@Override</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public void onCreate(Bundle savedInstanceState) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> super.onCreate(savedInstanceState);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> setContentView(R.layout.hello);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> Bundle b = getIntent().getExtras();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> String userName = (String)b.get("NAME");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> TextView t = (TextView)findViewById(R.id.textView1);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> t.setText("Hello "+userName+"!");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<div>
<br /></div>
<div>
<br /></div>
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-61859471066444872962012-01-22T07:27:00.000+05:302017-03-15T09:43:33.815+05:30Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder.While using Eclipse for Android development, you can create a new Android Virtual Device by clicking Window -> AVD Manager and by clicking new button. If you are getting the error message "<span style="font-family: "courier new" , "courier" , monospace;">Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder</span>." when trying to create an AVD for target platform 4.0.3, here is what you should do.<br />
<br />
This error is happening because the location of userdata.img file has changed since Android 4 (API Level 14). So we need to reinstall the ARM EABI package. Follow the below steps<br />
<br />
<br />
<a name='more'></a><br />
Step 1) Open Eclipse and click on Run Configurations (pull down the arrow next to the Run or Debug button).<br />
<br />
Step 2) Select "Android Application" and click "New"<br />
<br />
Step 3) Select the "Target" tab and select "Automatic" (Click once more even it is selected and the list box below is disabled"<br />
<br />
Step 4) Click on the "Manager..." button<br />
<br />
Step 5) In all the "Android 4.0.X" sections, select "ARM EABI v7a System Image" checkbox<br />
<br />
Step 6) Click the "Install X Package..." button<br />
<br />
You should be all set now<br />
<br />
Try creating the AVD again, it should work fine<br />
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-36125567024083155672012-01-06T06:03:00.000+05:302017-03-15T09:21:36.889+05:30How to apply XSLT translation on an input xml using java.xml.transform apis<br />
Almost all applications that deal with XML will have the necessity to transform the xml from one form to another. XSLT (XML Style Sheet Language Transformations) is one of the most popular ways of defining the transformations for XML document.<br />
<br />
A transformation defined in XSLT describes rules for transforming a source xml into a result xml. The result XML can be of a completely different structure of that of the source XML. The transformation is achieved by associating patterns with templates. A pattern is matched against elements in the source XML. The result XML is constructed from the source XML by filtering, reordering and/or by adding arbitrary structures using the data from the source xml<br />
<br />
Let us take an example and discuss how we can apply an xslt translation on an xml file using Java XML transformation APIs<br />
<br />
<br />
<br />
<a name='more'></a><br />
<br />
The xml is assumed to be stored as bookStoreXml.xml and has the following content<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><?xml version="1.0" encoding="ISO-8859-1"?></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><results></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><book category="COOKING"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title lang="en">Everyday Italian</title></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Giada De Laurentiis</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <year>2005</year></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <price>30.00</price></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <date>2011-10-20</date></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></book></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><book category="CHILDREN"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title lang="en">Harry Potter</title></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>J K. Rowling</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <year>2005</year></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <price>29.99</price></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <date>2008-01-10</date></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></book></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><book category="WEB"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title lang="en">XQuery Kick Start</title></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>James McGovern</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Per Bothner</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Kurt Cagle</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>James Linn</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Vaidyanathan Nagarajan</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <year>2003</year></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <price>49.99</price></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <date>2008-01-10</date></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></book></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><book category="WEB"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title lang="en">Learning XML</title></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Erik T. Ray</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <year>2003</year></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <price>39.95</price></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <date>2007-01-10</date></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></book></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"></results></span><br />
<br />
Let us say our requirement is to translate the XML to an HTML form with each book node in XML be a row in a table element.<br />
<br />
First, we will create an XSLT that will do the transformation. The xslt is assumed to be stored as bookhtmltransform.xsl and will have the following content<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><?xml version="1.0" encoding="UTF-8"?></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><xsl:output method="html"></xsl:output></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><xsl:template match="/"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><html></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <body></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <table></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <thead></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <th>Title</th></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <th>Author</th></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <th>Price</th></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </thead></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <tbody></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <xsl:for-each select="results/book"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <tr></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <td><xsl:value-of select="title"/> </td></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <td><xsl:value-of select="author"/> </td></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <td><xsl:value-of select="price"/> </td></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </tr></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </xsl:for-each></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </tbody></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </table></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </body></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></html></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></xsl:template></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></xsl:stylesheet></span><br />
<br />
<br />
The following Java code will do the transformation.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">import java.io.ByteArrayOutputStream;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import java.io.File;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.transform.Source;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.transform.Transformer;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.transform.TransformerFactory;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.transform.stream.StreamResult;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.transform.stream.StreamSource;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">public class TestXSLT {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> public static void main(String[] args) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> String returnHtml = "";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> String xmlFileName = "bookStoreXml.xml";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> String xsltFileName = "bookhtmltransform.xsl";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> try {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Source xmlSource = new StreamSource(new File(xmlFileName));</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Source xsltSource = new StreamSource(new File(xsltFileName));</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> TransformerFactory factory = TransformerFactory.newInstance();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Transformer transformer = factory.newTransformer(xsltSource);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> ByteArrayOutputStream bOut = new ByteArrayOutputStream();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> transformer.transform(xmlSource, new StreamResult(bOut));</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> bOut.close();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> returnHtml = bOut.toString();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> System.err.println(returnHtml);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> } catch (Exception e) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> e.printStackTrace();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> System.err.println("Exception occurred: " + e);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<br />
<br />
The same code will work fine if the xml and xslt is in the form of String or an InputStream.<br />
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-584007516592654202012-01-04T16:56:00.000+05:302017-03-15T09:21:09.629+05:30How to execute the XSLT functions as a part of XPath expressions in Java using Xalan parserExecuting XPath is a very common requirement in Java applications that deal with XML data. When there is a decision making requirement based on multiple data records, spanned across the xml document, it would be more efficient to use XSLT functions to extract information, than to parse and navigate the xml document back and forth.
<br />
<br />
XSLT includes several functions that help users extract information from XML data. It consists of many string, date and time, sequence manipulation, qname manipulation, aggregation and mathematical functions. Few of the most popular functions are given below<br />
<br />
<br />
<a name='more'></a><br />
<br />
<b><u>String related:</u></b><br />
<span style="font-family: "courier new" , "courier" , monospace;">string(arg)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">concat(string,string,...)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">string-join((string,string,...),sep)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">substring(string,start,len)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">contains(string1,string2)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">replace(string,pattern,replace)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">matches(string,pattern)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">tokenize(string,pattern)</span><br />
<br />
<b><u>Date and time related:</u></b><br />
<span style="font-family: "courier new" , "courier" , monospace;">dateTime(date,time)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">adjust-dateTime-to-timezone(datetime,timezone)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">year-from-dateTime(datetime)</span><br />
<br />
<b><u>Sequence related:</u></b><br />
<span style="font-family: "courier new" , "courier" , monospace;">index-of((item,item,...),searchitem)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">remove((item,item,...),position)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">exists(item,item,...)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">reverse((item,item,...))</span><br />
<br />
<b><u>Maths, number, set related</u></b><br />
<span style="font-family: "courier new" , "courier" , monospace;">abs(num)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">round(num)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">ceiling(num)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">floor(num)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">max((arg,arg,...))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">min((arg,arg,...))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">avg((arg,arg,...))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">count((item,item,...))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">sum(arg,arg,...)</span><br />
<br />
Let us take a simple example. Assume we have an xml that is the result of a book search from the bookstore application. Below is the xml data.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><?xml version="1.0" encoding="ISO-8859-1"?></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><results></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><book category="COOKING"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title lang="en">Everyday Italian</title></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Giada De Laurentiis</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <year>2005</year></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <price>30.00</price></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <date>2011-10-20</date></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></book></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><book category="CHILDREN"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title lang="en">Harry Potter</title></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>J K. Rowling</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <year>2005</year></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <price>29.99</price></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <date>2008-01-10</date></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></book></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><book category="WEB"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title lang="en">XQuery Kick Start</title></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>James McGovern</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Per Bothner</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Kurt Cagle</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>James Linn</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Vaidyanathan Nagarajan</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <year>2003</year></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <price>49.99</price></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <date>2008-01-10</date></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></book></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><book category="WEB"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <title lang="en">Learning XML</title></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <author>Erik T. Ray</author></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <year>2003</year></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <price>39.95</price></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <date>2007-01-10</date></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></book></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"></results></span><br />
<br />
An efficient way to find the book that has the lowest price would be to execute the XSLT function <span style="font-family: "courier new" , "courier" , monospace;">min(/results/book/price)</span>.<br />
<br />
These kind of operations are called extension functions, in the sense that, they extend the core library of functions that XPath provides. Xalan-Java supports extension elements and extension functions and also provides a growing extensions library for most of our needs. You can access the functions by providing the proper prefix. For eg: Since min is defined in the math functions, it will have a prefix of math<br />
<br />
Complete set of extension functions available in Xalan-Java and their prefix is given below<br />
<br />
<a href="http://xml.apache.org/xalan-j/apidocs/org/apache/xalan/lib/ExsltCommon.html" target="_blank">EXSLT common functions – exslt</a><br />
<a href="http://xml.apache.org/xalan-j/apidocs/org/apache/xalan/lib/ExsltMath.html" target="_blank">EXSLT math functions – math</a><br />
<a href="http://xml.apache.org/xalan-j/apidocs/org/apache/xalan/lib/ExsltSets.html" target="_blank">EXSLT set functions – set </a><br />
<a href="http://xml.apache.org/xalan-j/apidocs/org/apache/xalan/lib/ExsltDatetime.html" target="_blank">EXSLT date-and-time functions – datetime</a><br />
<a href="http://xml.apache.org/xalan-j/apidocs/org/apache/xalan/lib/ExsltDynamic.html" target="_blank">EXSLT dynamic functions – dyn</a><br />
<a href="http://xml.apache.org/xalan-j/apidocs/org/apache/xalan/lib/ExsltStrings.html" target="_blank">EXSLT string functions – str</a><br />
<br />
Let us see how to execute this XPath expression in Java using xalan apis<br />
<br />
<b>Include the below packages</b><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.namespace.QName;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.parsers.DocumentBuilder;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.parsers.DocumentBuilderFactory;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.xpath.XPath;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.xpath.XPathConstants;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.xpath.XPathExpression;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import javax.xml.xpath.XPathFactory;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">import org.apache.xalan.extensions.ExtensionNamespaceContext;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import org.apache.xalan.extensions.XPathFunctionResolverImpl;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import org.w3c.dom.Document;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import org.w3c.dom.Node;</span><br />
<br />
<b>Then create the Xpath</b><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">XPathFactory xpathFactory = XPathFactory.newInstance();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">XPath xpath = xpathFactory.newXPath();</span><br />
<br />
<br />
<b>In order to execute extension functions along with the XPaths, we need to add the ExtensionsNameSpace context to the xpath</b><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">xpath.setNamespaceContext(new ExtensionNamespaceContext());</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">xpath.setXPathFunctionResolver(new XPathFunctionResolverImpl());</span><br />
<br />
<b>And then compile the xpath</b><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">XPathExpression compiledExpr = xpath.compile(xpathExpr);</span><br />
<br />
<b>Now we are ready to execute this xpath against an XML document</b><br />
<br />
For the sake of testing, let us assume the results are in a text file named bookstore.xml(This can be done with xml data in String as well). The below code will run the xpath expression and return the result<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">public class TestXPathExtension {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> public static Object executeXpath(Node node, String xpathExpr,</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> QName returnType) throws Exception {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> Object returnValue = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> XPathFactory xpathFactory = XPathFactory.newInstance();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> XPath xpath = xpathFactory.newXPath();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> xpath.setNamespaceContext(new ExtensionNamespaceContext());</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> xpath.setXPathFunctionResolver(new XPathFunctionResolverImpl());</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> XPathExpression compiledExpr = xpath.compile(xpathExpr);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> returnValue = compiledExpr.evaluate(node, returnType);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> return returnValue;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> public static void main(String[] args) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> String xmlName = "bookstore.xml";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> String xpathExpr = "math:min(/results/book/price)";</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> DocumentBuilder domBuilder;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Document doc = null;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> try {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> FileInputStream fis = new FileInputStream(xmlName);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> domBuilder = domFactory.newDocumentBuilder();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> doc = domBuilder.parse(fis);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> System.out.println(executeXpath(doc,xpathExpr,XPathConstants.NUMBER));</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> fis.close();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> } catch (Exception e) {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> e.printStackTrace();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"> }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">}</span><br />
<br />
<b>Output: <span style="font-family: "courier new" , "courier" , monospace;">29.99</span></b><br />
<br />
<br />Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-26386677185624142502011-04-30T10:29:00.000+05:302017-03-15T09:20:50.073+05:30Error 1330.A file that is required cannot be installed because the cabinet file cab2.cab has an invalid digital signature.<span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;">Error 1330.A file that is required cannot be installed because the cabinet file cab2.cab has an invalid digital signature. This may indicate that the cabinet file is corrupt.</span><br />
<br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">This is a very common error for those who are trying to install <a href="http://www.amazon.com/Professional-Visual-Studio-2008-Programmer/dp/0470229888?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Visual Studio 2008</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0470229888" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> on a <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> using an iso image. I had a tough time with this error, and I spent several hours struggling to solve this issue. I searched internet and most of the forums were asking to keep trying again and again until you are successful. Every time I tried and I got the same error but on a different cab file. Finally, after digging much deeper into the problem, I was able to find the root cause of this issue and solved it. Here we will discuss how to get past this error and install <a href="http://www.amazon.com/Professional-Visual-Studio-2008-Programmer/dp/0470229888?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Visual Studio 2008</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0470229888" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> on a <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /></span><br />
<a name='more'></a><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Let us see what is causing this issue. </span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Even though the error message reads that the cab file is corrupt, most probably the underlying reason was that the installer could not read the whole file successfully. <a href="http://www.amazon.com/Professional-Visual-Studio-2008-Programmer/dp/0470229888?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Visual studio</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0470229888" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> is a pretty big installation and when you try to install the application on <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> using an ISO image, it uses the Temp directory in the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> hard disk and the RAM of the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> to store all the temporary installation files. The reason for this error is momentary unavailability of the hard disk space or RAM. </span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">In order to fix this error, we need to follow the below steps.</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step - 1: </b>Download the iso image to your host pc and extract the iso image to a folder in the host pc hard drive. The iso image for the trial version can be found <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=83c3a1ec-ed72-4a79-8961-25635db0192b&displaylang=en" target="_blank">here</a>. You can use <a href="http://www.amazon.com/WinRAR-Archiver-Compression-software-Windows/dp/B00434XP88?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WinRAR </a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=B00434XP88" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />or <a href="http://www.amazon.com/Corel-WZ15STDPLENMB-WinZip-Standard-Plus/dp/B004I1PWDW?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WinZip </a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=B004I1PWDW" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />to extract the iso image. For this example we will assume that the iso image was extracted to </span><span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;">H:\downloads\VisualStudio2008\VS2008ProEdition90dayTrialENUX1435622</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step - 2:</b>Next step is to make sure that enough memory is available to the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />. Open the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> console and click “Settings”. You might have to stop the PC, if it is already running.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1sEXWMJ7JxI7t2503NXIxRzIo_4UC5orwN_gWqa35glrFNy1sFe7kmk5Ae4f3EJmGwkw0I4Z2rT-jmrb5MW0Az8Dagx_5sX0YV06MWPXxily0tTliM3jw08BC0dLt-thZ0B83jMEiASY/s1600/vs1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1sEXWMJ7JxI7t2503NXIxRzIo_4UC5orwN_gWqa35glrFNy1sFe7kmk5Ae4f3EJmGwkw0I4Z2rT-jmrb5MW0Az8Dagx_5sX0YV06MWPXxily0tTliM3jw08BC0dLt-thZ0B83jMEiASY/s320/vs1.gif" width="320" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Select “Memory” and set the RAM size to 1.5 to 2 GB. Click “Ok” and start the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1eZqcyqKSpt5POY_t8yHAGCyruX2vCq3ZdlfhO-htljpTPTbABBDd7HI9ed-g0GllH_0H9A-LMXPgL_mPKfUbnCrQZsO4_yX3SA_PPzvGydtNgw-DUdavogcGB4DuzJKEhzPw8Zr-EKM/s1600/vs2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="228" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1eZqcyqKSpt5POY_t8yHAGCyruX2vCq3ZdlfhO-htljpTPTbABBDd7HI9ed-g0GllH_0H9A-LMXPgL_mPKfUbnCrQZsO4_yX3SA_PPzvGydtNgw-DUdavogcGB4DuzJKEhzPw8Zr-EKM/s320/vs2.gif" width="320" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step -<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"> </span>3:</b>Now we need to increase the virtual memory for the operating system of the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />. From the start menu of the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />, right click on “My Computer” and select “Properties”.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2dACLNAgwWWYqZ6ayRkFEzJBdmz2gTKSNykEGar84Nrwf-wAWhiAUF6BkvF4ozCwCKtS9R6xaIyl7kcSsVhYRinZZMpbwWkPbskhV19Adp3hOyLvI7vByNz4qoXTjavtKJND1Owm2Ab8/s1600/vs3.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="190" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2dACLNAgwWWYqZ6ayRkFEzJBdmz2gTKSNykEGar84Nrwf-wAWhiAUF6BkvF4ozCwCKtS9R6xaIyl7kcSsVhYRinZZMpbwWkPbskhV19Adp3hOyLvI7vByNz4qoXTjavtKJND1Owm2Ab8/s320/vs3.gif" width="320" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Select the “Advanced” tab and click “Settings” in the “Performance” pane.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5Qey1OPwccoBLtlkP59qddR8rxY6svOMQ3-i4Mdti6OQ36Il5vAMXm5XSp08EiXMWJIdaikvhIJUP4gzopZLi4oIZmT_dcUt0GV5TYFBsf6Sd5cB2vrsod7uiW0WMJL40SLg5Fkl-JSo/s1600/vs4.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5Qey1OPwccoBLtlkP59qddR8rxY6svOMQ3-i4Mdti6OQ36Il5vAMXm5XSp08EiXMWJIdaikvhIJUP4gzopZLi4oIZmT_dcUt0GV5TYFBsf6Sd5cB2vrsod7uiW0WMJL40SLg5Fkl-JSo/s320/vs4.gif" width="278" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Select “Custom Paging size” and give values as shown below.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdNLtdVtrF5TxUvRdvIlVUV2JayZAob1uJMcAaauYBzmbdT8HeUripKar-mQSNvRaGJ82CXkRUAzL_afk4Ghb0Exp9R3y1MKXn-bYzurKnXxwZzPoSVfz2MrVtf7oIHhQF6XdsHVmtUos/s1600/vs5.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="237" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdNLtdVtrF5TxUvRdvIlVUV2JayZAob1uJMcAaauYBzmbdT8HeUripKar-mQSNvRaGJ82CXkRUAzL_afk4Ghb0Exp9R3y1MKXn-bYzurKnXxwZzPoSVfz2MrVtf7oIHhQF6XdsHVmtUos/s320/vs5.gif" width="320" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Click OK and restart the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /></span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step -<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"> </span>4:</b>Let us also clear all the files from the temporary folder. In order to do that, from the Start menu of the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />, select “Run” and type </span><span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;">%temp%</span><span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"> .This should open up the Temp folder. Delete all the files from this folder.</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step -<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"> </span>5:</b>In the next step , we will copy the extracted iso image from the host pc into the local hard drive of the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />. This will reduce the number of file input output operations during the installation. </span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">In order to copy the file from the host pc, you need to map the folder to which you have extracted the iso image as a Shared folder in the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />. </span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">To do that, right click on the small folder icon at the bottom-left corner of the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> Window and select “Share Folder”</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8Vnyl2bOHItA_4qNuofxtHQpqbIWHvWN0pkHvviNTcqDoGSZ0OWIfR2DxzweZPz5I7PYHl4TqEOkiO7Z_vBIiZeP7qSL9YsdrHHjx2HJ9uyBRoVyOl3ccz5RZf-h8itCZKAi9MxXBLtE/s1600/vs6.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8Vnyl2bOHItA_4qNuofxtHQpqbIWHvWN0pkHvviNTcqDoGSZ0OWIfR2DxzweZPz5I7PYHl4TqEOkiO7Z_vBIiZeP7qSL9YsdrHHjx2HJ9uyBRoVyOl3ccz5RZf-h8itCZKAi9MxXBLtE/s320/vs6.gif" width="118" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Navigate to the folder to which we have extracted the iso image and click ok.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSBFhiSQ7oYYmVhaIBGn-6wJtXrzqUbzFh7ASfFRtcgCWdMcPCf4lc10eSgJCrNQyAyW0wxHSiOhlyIdyFx4bY_CPUpzkDnPdZ2V8zxOQwEqboB2h7CpKzQD-iQ6Usjy3GxGfd-aiVbVw/s1600/vs7.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSBFhiSQ7oYYmVhaIBGn-6wJtXrzqUbzFh7ASfFRtcgCWdMcPCf4lc10eSgJCrNQyAyW0wxHSiOhlyIdyFx4bY_CPUpzkDnPdZ2V8zxOQwEqboB2h7CpKzQD-iQ6Usjy3GxGfd-aiVbVw/s320/vs7.gif" width="293" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Now open the file explorer in the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />, you can see the folder on the host pc as a shared folder. Copy the folder to the <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> C: Drive</span><br />
<br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step -<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"> </span>6:</b></span><span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Once the copy is complete, open the folder in the C: drive of <a href="http://www.amazon.com/Microsoft-Virtual-Server-Networking-Technology/dp/1428321950?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Virtual PC</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1428321950" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> and double click the setup.exe and follow the installation wizard. The installation will complete without issues. </span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step -<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"> </span>7:</b>In the rare case that a cab file corrupt message comes again, try replacing that particular cab file from host pc. The <a href="http://www.amazon.com/Professional-Visual-Studio-2010-Programmer/dp/0470548657?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Visual Studio</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0470548657" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> installation should complete without any issue now.</span><br />
<div>
<br /></div>
Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-15708718727603542602011-04-22T08:15:00.000+05:302017-03-15T09:20:35.584+05:30Error while installing IIS. Prompts for iisback.vbs or asks for Windows Server CD<div class="MsoNormal">
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Internet Information Services (<a href="http://www.amazon.com/Professional-IIS-7-Kenneth-Schaefer/dp/0470097825?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">IIS</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0470097825" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />) is a web server application and set of feature extension modules created by Microsoft for use with Microsoft <a href="http://www.amazon.com/Windows-Server-2008-Inside-Out/dp/0735624380?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Windows</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0735624380" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />. It is an an essential component for hosting any ASP.Net project on <a href="http://www.amazon.com/Windows-Server-2008-Inside-Out/dp/0735624380?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Windows platform</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0735624380" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />. </span><span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">While installing or configuring <a href="http://www.amazon.com/Professional-IIS-7-Kenneth-Schaefer/dp/0470097825?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank"></a><a href="http://www.amazon.com/Professional-IIS-7-Kenneth-Schaefer/dp/0470097825?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">IIS</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0470097825" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0470097825" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />, if the system prompts for iisback.vbs or asks for the <a href="http://www.amazon.com/Windows-Server-2008-Unleashed-ebook/dp/B0032O5MLI?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Windows Server</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=B0032O5MLI" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> CD, here is how we can solve it.</span></div>
<a name='more'></a><br />
<br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">iisback.vbs is a very important file in terms of backing up <a href="http://www.amazon.com/Professional-IIS-7-Kenneth-Schaefer/dp/0470097825?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">IIS </a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0470097825" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />config. This file comes along with the <a href="http://www.amazon.com/Windows-Server-2008-Unleashed-ebook/dp/B0032O5MLI?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Windows Server</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=B0032O5MLI" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> installation cd and will be available in the I386 folder in the file system after the <a href="http://www.amazon.com/Windows-Server-2008-Unleashed-ebook/dp/B0032O5MLI?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Windows Server</a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=B0032O5MLI" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> is installed completely. To overcome this error, follow the below steps</span><br />
<div class="MsoNormal" style="margin-left: .25in;">
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span></div>
<div class="MsoNormal" style="margin-left: .25in;">
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step – 1:</b> Open the explorer and navigate to the <a href="http://www.amazon.com/Windows-Server-2008-Unleashed-ebook/dp/B0032O5MLI?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Windows </a><img alt="" border="0" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=B0032O5MLI" height="1" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />Installation folder in C drive</span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal" style="margin-left: .25in;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSUP-7CMYEkgFnoDTe4nPJkM2VW3CUItcBHLFxGzF1IDCm_I2TRIyOislGRG_5LgmtEs87PwyNUopvTammdODmadglXrDznEWAKd1yiMOSSqRD09tdjqhPRTwmQGNPgxUpSepyORFxiH4/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSUP-7CMYEkgFnoDTe4nPJkM2VW3CUItcBHLFxGzF1IDCm_I2TRIyOislGRG_5LgmtEs87PwyNUopvTammdODmadglXrDznEWAKd1yiMOSSqRD09tdjqhPRTwmQGNPgxUpSepyORFxiH4/s320/1.jpg" width="296" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span></div>
<div class="MsoNormal" style="margin-left: .25in;">
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step – 2:</b> In the I386 folder, look for the file named </span><span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;">IISBACK.VBS</span><span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"> or </span><span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;">IISBACK.VB_</span><br />
<span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;"><br />
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwIIGn8p9Zx6dK3nEwFbswixFMfS3EQtksPH22u0cSzrrU3yrczZnT7ZF3cCX_ZGh38ETRDQx356KGjPrxmDB_-jdRn3rysTSd0oh63EltUq_7MvHaTMNtO9IDR7QZoAt-VUFLJWRoQ5I/s1600/3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="97" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwIIGn8p9Zx6dK3nEwFbswixFMfS3EQtksPH22u0cSzrrU3yrczZnT7ZF3cCX_ZGh38ETRDQx356KGjPrxmDB_-jdRn3rysTSd0oh63EltUq_7MvHaTMNtO9IDR7QZoAt-VUFLJWRoQ5I/s200/3.JPG" width="200" /></a></div>
<span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;"><br />
</span></div>
<div class="MsoNormal" style="margin-left: .25in;">
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">If you can find this file, click “Browse” on the error prompt and give the full path to I386 folder in the text box. In this example it is “</span><span class="Apple-style-span" style="font-family: "courier new" , "courier" , monospace;">C:\Windows Installation Files\I386</span><span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">” and click Ok</span></div>
<div class="MsoNormal" style="margin-left: .25in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .25in;">
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><b>Step – 3:</b> If this works, very well.. Otherwise, we need to find any other directories that might have this file. So select “C:” and click on search and search for filename “IISBACK”. <i>Do not give the extension</i>.</span></div>
<div class="MsoNormal" style="margin-left: .25in;">
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN93bo6dtcztZQu28o7kdIfFHy8ZEqROJQ3xpx9t4GqOG0r7XahbusSaB975P_H6okKBNqTK2pFXtexRZ_-hHm-GF7IHeJvTF0JyYlWwREjANf5L-xzaIobpANBGpAI6t2xKRvYCiNt58/s1600/2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN93bo6dtcztZQu28o7kdIfFHy8ZEqROJQ3xpx9t4GqOG0r7XahbusSaB975P_H6okKBNqTK2pFXtexRZ_-hHm-GF7IHeJvTF0JyYlWwREjANf5L-xzaIobpANBGpAI6t2xKRvYCiNt58/s1600/2.jpg" /></a></div>
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span></div>
<div class="MsoNormal" style="margin-left: .25in;">
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">Click Search. Wait for few minutes till the search is complete. Try pointing to each folder displayed in search results, one after another till it works. </span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: "verdana" , sans-serif;">If you have any other solutions please share with us.</span></div>
Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-46972468839934418792011-04-03T04:43:00.000+05:302011-10-02T07:06:43.014+05:30java.io.IOException: FATAL ERRORS encountered by WSDL2Java tool<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">We will discuss how to resolve the below error message in <a href="http://www.amazon.com/Introduction-IBM-Rational-Application-Developer/dp/1931182221?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Rational Application Developer (RAD)</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1931182221" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> <img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=073843289X" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />when you start the <a href="http://www.amazon.com/WebSphere-Application-Server-Step-Step/dp/1583470611?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WebSphere Application Server</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1583470611" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /></span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Error messages were issued.</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">java.io.IOException: FATAL ERRORS encountered by WSDL2Java tool.</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at com.ibm.ws.webservices.wsdl.Parser.generate(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at com.ibm.ws.webservices.wsdl.Parser.generate(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at com.ibm.ws.webservices.tools.wsad.WSDL2Java._execute(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at com.ibm.ws.webservices.tools.wsad.WSDL2JavaBase.execute(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at com.ibm.etools.webservice.command.adapter.CommandToCommand.execute(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at com.ibm.ast.ws.v7.jaxrpc.jee5.stub.WSDeployStub.execute(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">at java.lang.reflect.Method.invoke(Unknown Source)</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">In <a href="http://www.amazon.com/WebSphere-Application-Server-Step-Step/dp/1583470611?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WebSphere Application Server</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1583470611" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />, when you deploy or publish an application, it uses the <a href="http://www.amazon.com/Perspectives-Web-Services-Real-World-Professional/dp/3540009140?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WSDL </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=3540009140" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />files and generates the serializer and deserializer, <b>even if it was already generated as a part of the <a href="http://www.amazon.com/Perspectives-Web-Services-Real-World-Professional/dp/3540009140?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">proxies</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=3540009140" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /></b>. This error message indicates that the <a href="http://www.amazon.com/Perspectives-Web-Services-Real-World-Professional/dp/3540009140?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WSDL</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=3540009140" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> file was either corrupted or not contains <a href="http://www.amazon.com/J2EE-Web-Services-SOAP-JAX-RPC/dp/0321146182?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">XSDs </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0321146182" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />that does not match up. </span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">If you have your <a href="http://www.amazon.com/Perspectives-Web-Services-Real-World-Professional/dp/3540009140?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WSDLs </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=3540009140" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />changed recently, there could be chances that the server cache still has old <a href="http://www.amazon.com/Perspectives-Web-Services-Real-World-Professional/dp/3540009140?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WSDLs</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=3540009140" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />. We will discuss how to get rid of this error. P</span><span class="Apple-style-span" style="font-family: Verdana, sans-serif;">lease follow the below steps</span><br />
<a name='more'></a><br />
<br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">1) If any of your <a href="http://www.amazon.com/Perspectives-Web-Services-Real-World-Professional/dp/3540009140?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">WSDLs </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=3540009140" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />changed, you need to make sure that you have all the dependent <a href="http://www.amazon.com/J2EE-Web-Services-SOAP-JAX-RPC/dp/0321146182?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">XSDs </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0321146182" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />available in the same structure. Some <a href="http://www.amazon.com/J2EE-Web-Services-SOAP-JAX-RPC/dp/0321146182?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">XSD </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0321146182" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />files will have references to other <a href="http://www.amazon.com/J2EE-Web-Services-SOAP-JAX-RPC/dp/0321146182?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">XSD </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0321146182" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />files. In that case, you need to make sure the referenced <a href="http://www.amazon.com/J2EE-Web-Services-SOAP-JAX-RPC/dp/0321146182?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">XSDs </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0321146182" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />files are also available</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"></span><span class="Apple-style-span" style="font-family: Verdana, sans-serif;">2) Select the project and right click and select "Refresh" form the menu</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">3) Build the project and start the server</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">4) If you still see the error, Right click on your server in the <a href="http://www.amazon.com/Introduction-IBM-Rational-Application-Developer/dp/1931182221?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">RAD </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1931182221" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=073843289X" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />Server view and select "Add and Remove Projects" and remove your project from server</span><br />
<br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">5) Go to the Administrative Console -> Applications -> Application Types -> Websphere Enterprise Applications and uninstall your application, if it is listed there</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">6) Stop the server</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">7) Using the file system explorer navigate to <<a href="http://www.amazon.com/Pro-WebSphere-Application-Server-Internals/dp/1430219580?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Websphere </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1430219580" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />installation directory>\profiles\<your profile>\temp\wscache and delete your project from there</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">8) Then navigate to <<a href="http://www.amazon.com/Pro-WebSphere-Application-Server-Internals/dp/1430219580?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Websphere </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1430219580" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />installation directory>\profiles\<your profile>\temp\<your node>\<your server> and delete your project from there</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">9) Select your project in <a href="http://www.amazon.com/Introduction-IBM-Rational-Application-Developer/dp/1931182221?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">RAD </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1931182221" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=073843289X" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />and from the top menu select Project -> Clean (Make sure start a build immediately is checked)</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">10) Once the build is complete, right click on your server in the <a href="http://www.amazon.com/Introduction-IBM-Rational-Application-Developer/dp/1931182221?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">RAD </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1931182221" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=073843289X" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />Server view and select "Add and Remove Projects" and add your project to the server</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">11) Start the server. The error should be gone now</span><br />
<div><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span></div>Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.comtag:blogger.com,1999:blog-1818775688332926775.post-12163824393036873792011-03-06T05:47:00.000+05:302011-10-02T07:07:19.535+05:30SECJ0371W: Validation of the LTPA token failed because the token expired with the following info: {0}<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">If you are seeing this exception in the logs of <a href="http://www.amazon.com/Pro-WebSphere-Application-Server-Internals/dp/1430219580?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Websphere 7</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=1430219580" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> server, it is mainly because the <a href="http://www.amazon.com/LIGHTWEIGHT-THIRD-PARTY-AUTHENTICATION-LAMBERT-HENSSONOW/dp/6132452648?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">LTPA </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=6132452648" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />token has expired and therefore, it cannot be validated.</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">Based on different scenarios, the reason of this error may be different</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"></span><br />
<a name='more'></a><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><b>1) If you are seeing it in a <a href="http://www.amazon.com/Web-Application-Architecture-Principles-Protocols/dp/047051860X?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">web application</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=047051860X" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /></b></span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><a href="http://www.amazon.com/LIGHTWEIGHT-THIRD-PARTY-AUTHENTICATION-LAMBERT-HENSSONOW/dp/6132452648?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">LTPA </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=6132452648" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />or <a href="http://www.amazon.com/LIGHTWEIGHT-THIRD-PARTY-AUTHENTICATION-LAMBERT-HENSSONOW/dp/6132452648?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Lightweight Third Party Authentication</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=6132452648" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> is a technology used in <a href="http://www.amazon.com/WebSphere-Application-Server-Administration-Jython/dp/0137009526?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Websphere server </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0137009526" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />to re-use the login across physical servers. It is simply a cookie that contains the user authentication information. Every <a href="http://www.amazon.com/LIGHTWEIGHT-THIRD-PARTY-AUTHENTICATION-LAMBERT-HENSSONOW/dp/6132452648?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">LTPA </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=6132452648" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />token has a defined period of time after which the token expires. Once the token time out is reached, the token will not be validated and the user has to authenticate again. This is normal.</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><b>2) If the instance is configured with the RTT 6.1</b> <a href="http://www.amazon.com/Microsoft-Server-2008-Management-Administration/dp/067233044X?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Management Server</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=067233044X" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> (MS)</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">WAS generates the <a href="http://www.amazon.com/LIGHTWEIGHT-THIRD-PARTY-AUTHENTICATION-LAMBERT-HENSSONOW/dp/6132452648?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">LTPA </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=6132452648" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />token when you log onto the MS console. When you leave the MS console open, this token expires after a while. Then, the WAS container issues this message when it re-authenticates your logon using the same userid and password you used to log onto the MS console.</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><b>3) In a <a href="http://www.amazon.com/IBM-WebSphere-Deployment-Advanced-Configuration/dp/0131468626?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">clustered environment</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0131468626" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /></b></span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><a href="http://www.amazon.com/Application-Architecture-WebSphere-Practical-Applications/dp/0137129262?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Websphere</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0137129262" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> uses <a href="http://www.amazon.com/LIGHTWEIGHT-THIRD-PARTY-AUTHENTICATION-LAMBERT-HENSSONOW/dp/6132452648?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">LTPA </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=6132452648" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />tokens to authenticate servers within the <a href="http://www.amazon.com/IBM-WebSphere-Deployment-Advanced-Configuration/dp/0131468626?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">cluster </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0131468626" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />and to communicate. By default, <a href="http://www.amazon.com/LIGHTWEIGHT-THIRD-PARTY-AUTHENTICATION-LAMBERT-HENSSONOW/dp/6132452648?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">LTPA </a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=6132452648" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" />keys are regenerated on a schedule every 90 days, configurable to the day of the week.The "<a href="http://www.amazon.com/Authentication-Passwords-Public-Richard-Smith/dp/0201615991?ie=UTF8&tag=thcobl08-20&link_code=btl&camp=213689&creative=392969" target="_blank">Authentication</a><img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=thcobl08-20&l=btl&camp=213689&creative=392969&o=1&a=0201615991" style="border: none !important; margin: 0px !important; padding: 0px !important;" width="1" /> cache timeout" field specifies the time period during which the authenticated credential in the cache is valid. This time period must be less than the time period specified for the Timeout value for forwarded credentials between servers field.</span>Srijithttp://www.blogger.com/profile/08543856089668499742noreply@blogger.com