tag:blogger.com,1999:blog-2787160012062381892024-03-05T10:59:20.437-08:00Coder's WorldPurpose of this blog is to share my programming knowledge with rest of the worldAnonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.comBlogger37125tag:blogger.com,1999:blog-278716001206238189.post-85306216759816754892016-09-05T02:38:00.003-07:002016-09-05T02:38:52.373-07:00Ubuntu Locale Warning from Perl<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="p1">
<span style="font-family: Verdana, sans-serif;">Error</span></div>
<div class="p1">
<br /></div>
<div class="p1">
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: red;">perl: warning: Please check that your locale settings:</span></span></div>
<div class="p1">
<span class="s1"><span style="color: red; font-family: Courier New, Courier, monospace;"> LC_ALL = (unset),</span></span></div>
<div class="p1">
<span class="s1"><span style="color: red; font-family: Courier New, Courier, monospace;"> LANG = "en_US.UTF-8"</span></span></div>
<div class="p1">
<span class="s1"><span style="color: red; font-family: Courier New, Courier, monospace;"> are supported and installed on your system.</span></span></div>
<div class="p1">
<span class="s1"><span style="color: red; font-family: Courier New, Courier, monospace;">
</span></span></div>
<div class="p1">
<span class="s1"><span style="color: red; font-family: Courier New, Courier, monospace;">perl: warning: Falling back to the standard locale ("C").</span></span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1"><span style="font-family: Verdana, sans-serif;">Fix</span></span></div>
<div class="p1">
<span class="s1"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div>
<div class="p1">
<span class="s1"><span style="font-family: Verdana, sans-serif;">Add the below two entries in ~/.bashrc</span></span></div>
<div class="p1">
<span class="s1"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;"><span class="s1">LC_CTYPE=en_US.UTF-</span><span class="s2">8</span></span></div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;"><span class="s1">LC_ALL=en_US.UTF-</span><span class="s2">8</span></span></div>
<div class="p1">
<span class="s2"><br /></span></div>
<div class="p1">
<span class="s2"><span style="font-family: Verdana, sans-serif;">( or )</span></span></div>
<div class="p1">
<span class="s2"><br /></span></div>
<div class="p2">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">sudo locale-gen</span></span></div>
<br />
<div class="p2">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">sudo dpkg-reconfigure locales</span></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-18403790430061878512016-09-01T12:55:00.003-07:002016-09-01T12:55:39.760-07:00No apport report written because MaxReports is reached already<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; text-align: left;">This error comes mostly because of the debian broken packages. To fix broken packages, follow the below simple steps</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">Lets say for instance, I have foreman broken packages, to fix foreman installation,</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo dpkg --purge foreman</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo dpkg --purge foreman-proxy</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo dpkg --purge foreman-compute</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo dpkg --purge foreman-libvert</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo dpkg --purge foreman-sqlite3</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo apt-get autoremove</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo apt-get autoclean</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo apt-get update</span></div>
<div style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;">sudo apt-get -f install</span></div>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-10791721060648056992016-08-30T08:27:00.007-07:002016-08-30T08:34:22.804-07:00activesupport requires Ruby version >= 2.2.2<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "verdana" , sans-serif;"><b>Rails installation error in Ubuntu</b></span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><span style="color: red;">ERROR</span>: Error installing rails:</span><br />
<span style="font-family: "verdana" , sans-serif;"> activesupport requires Ruby version >= 2.2.2</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="font-family: "verdana" , sans-serif;"><b>Fix</b></span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="background-color: #eff0f1; color: #242729; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace , sans-serif; font-size: 13px; line-height: 16.9px; white-space: pre-wrap;">gem install rails -v 4.2.2</span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-69412174127842904892016-08-23T12:30:00.002-07:002016-08-23T12:30:53.329-07:00Remove APT Repository from newer versions of Ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "verdana" , sans-serif;">To remove apt repository from newer versions of Ubuntu, Just type the below command in terminal</span><br />
<span style="font-family: "verdana" , sans-serif;"><br /></span>
<span style="background-color: #eff0f1; color: #111111; font-family: Courier New, Courier, monospace; font-size: 13px; line-height: 16.9px; white-space: pre-wrap;"><i>cd /etc/apt/sources.list.d</i></span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">and then remove the files manually using</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><i>sudo rm -f <<filename>>.list</i></span><br />
<span style="font-family: Courier New, Courier, monospace;"><i>sudo rm -f <<filename>>.save</i></span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-38255617726022771772016-08-23T00:01:00.001-07:002016-08-23T00:01:22.767-07:00Puppet Master & Client Uninstallation in Ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;"><b>Uninstall puppetmaster-common</b></span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">sudo apt-get remove puppetmaster-common</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">This will remove just the puppetmaster-common package itself.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>Uninstall puppetmaster-common and it's dependencies</b></span><br />
<span style="font-family: Verdana, sans-serif;"><b><br /></b></span>
<span style="font-family: Verdana, sans-serif;">sudo apt-get remove --auto-remove puppetmaster-common</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">This will remove the puppetmaster-common package and any other dependant packages that are no longer needed.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>Purging your config/data</b></span><br />
<span style="font-family: Verdana, sans-serif;"><b><br /></b></span>
<span style="font-family: Verdana, sans-serif;">If you also want to delete your local/config files for puppetmaster-common then this will do the trick.</span><br />
<br />
<span style="font-family: Verdana, sans-serif;">sudo apt-get purge puppetmaster-common</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">Or similarly, like this</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"></span><br />
<span style="font-family: Verdana, sans-serif;">sudo apt-get purge --auto-remove puppetmaster-common</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<br />
<br />
<span style="font-family: Verdana, sans-serif;"><b><br /></b></span>
<span style="font-family: Verdana, sans-serif;"><b>Uninstall just puppet</b></span><br />
<span style="font-family: Verdana, sans-serif;"><b><br /></b></span>
<span style="font-family: Verdana, sans-serif;">sudo apt-get remove puppet</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">This will remove just the puppet package itself.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>Uninstall puppet and it's dependencies</b></span><br />
<span style="font-family: Verdana, sans-serif;"><b><br /></b></span>
<span style="font-family: Verdana, sans-serif;">sudo apt-get remove --auto-remove puppet</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">This will remove puppet package and any other dependant packages that are no longer needed.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>Purging your config/data too</b></span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">If you also want to delete your local/config files for puppet then this will do the trick.</span><br />
<br />
<span style="font-family: Verdana, sans-serif;">sudo apt-get purge puppet</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">Or like this,</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">sudo apt-get purge --auto-remove puppet</span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-59466274375528376202015-12-19T10:28:00.000-08:002016-08-15T06:40:01.133-07:00Android Studio JVM Error<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<b><span style="font-family: "verdana" , sans-serif; font-size: small;">Error: </span><span style="color: red; font-family: "verdana" , sans-serif; font-size: small;">android studio was unable to find a valid JVM</span></b></div>
<div class="p1">
<h2 style="text-align: left;">
<span class="s1" style="font-family: "verdana" , sans-serif; font-size: small;"><b>Fix:</b></span></h2>
</div>
<ul style="text-align: left;"><span style="font-family: "verdana" , sans-serif;">
</span>
<li><span style="font-family: "verdana" , sans-serif;"> Go to Applications->Android Studio</span></li>
<li><span style="font-family: "verdana" , sans-serif;"> Right click and choose Show Package Contents</span></li>
<li><span style="font-family: "verdana" , sans-serif;"> Open Info.plist</span></li>
<li><span style="font-family: "verdana" , sans-serif;"><span class="s1"> Change the key </span><span style="background-color: white; color: #222426; font-size: 15px; line-height: 19.5px;"><span style="font-family: inherit;">JVMversion to 1.7* or 1.8* ( depends on which jdk is installed in your mac )</span></span></span></li>
</ul>
<b>
</b></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-90312948492772964822015-11-22T23:28:00.001-08:002016-08-15T07:08:29.518-07:00setColor cocos2dx compile error<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;"><b><span style="color: red;">Error</span>:<span style="color: red;"> </span><span style="color: red;">setColor cocos2dx compile error</span></b></span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>Fix:</b></span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"> <span style="font-family: Courier New, Courier, monospace;">ccColor3B c3 = { 0, 0, 0 };</span></span><br />
<span style="font-family: Verdana, sans-serif;"> selectedImage->setColor(c3);</span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-61597273852758245502015-11-14T04:13:00.000-08:002016-08-15T07:11:29.255-07:00syntax error: unknown user in statoverride file<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;">Fix: </span><i style="font-family: Verdana, sans-serif;"> </i><span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;">sudo sed -i '/<user>/d' /var/lib/dpkg/statoverride</span></span></b></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span></span></div>
<span style="color: red; font-family: Verdana, sans-serif;"><b>Note: Replace <user> with your real userID</b></span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-12014751673270527192015-11-14T04:02:00.004-08:002015-11-14T04:02:41.728-08:00installation error: install_failed_media_unavailable<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 style="text-align: left;">
<b>Fix: Make sure that you have enough space in your device</b></h3>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-24409216137329905372015-11-06T22:30:00.000-08:002016-08-15T07:18:55.827-07:00Turn ON MySql Event Scheduler feature<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">By default MySql event scheduler settings are turned OFF. Execute the below commands to turn ON event scheduling in MySql</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>show variables where variable_name='event_scheduler';</b></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">+-----------------+-------+</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">| Variable_name | Value |</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">+-----------------+-------+</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">| event_scheduler | OFF |</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">+-----------------+-------+</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b><br /></b></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>SET GLOBAL event_scheduler = ON;</b></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>show variables where variable_name='event_scheduler';</b></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">+-----------------+-------+</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">| Variable_name | Value |</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">+-----------------+-------+</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">| event_scheduler | ON |</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">+-----------------+-------+</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-40310273641627838882015-10-19T11:35:00.001-07:002016-08-15T07:19:55.048-07:00How to find and kill a process that is using a particular port in ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;">1) <i>sudo netstat -lpn |grep :8080</i></span><br />
<i><span style="font-family: Verdana, sans-serif;"> </span></i><br />
<span style="font-family: Verdana, sans-serif;"> and press Enter</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"> You can see the PID that occupied the port 8080</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">2) <i>sudo kill -9 xxxx</i></span><br />
<span style="font-family: Verdana, sans-serif;"><i><br /></i>
Now you can use the port 8080 for some other application</span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-34190275925520941212015-10-19T08:11:00.000-07:002016-08-15T07:20:24.122-07:00Memory constraints and limitations of Virtual Private Server<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">Before you decide to go for Virtual Private Server( VPS ), make your requirements very clear and know the memory limitations of VPS. Long time back I purchased a VPS and I was able to install MySql, Glassfish, Nginx, mail server, puppetmaster and client, memcached, git, etc. Later on I was trying to improve the performance of Glassfish cluster instances and Mysql.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">I was able to make changes in memory settings MySql and optimized its performance and tested with mysqltuner. No problem!</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">Since I had two glassfish cluster instances running on the same machine, I thought of increasing JVM heap size of both instances to 5G. Earlier I had allocated only 2G and I was trying to push this to 5G for both instances.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">After making changes in cluster xml, I started 1st instance and it was successful. Instance one was ready to serve requests.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">When I try to start the 2nd instance, BOOOOOM!, 2nd instance throws "Out Of Memory Exception", Couldn't reserve enough space for JVM.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">Then I checked the available memory in my machine using "free -g". It displayed like this 17G free available memory and only 3G occupied.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">What does that mean? 17GB still left but unable to allocate.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">Then I spoke to my hosting provider guys and I have been told that it doesn't work the way you think.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">This command:</span><br />
<span style="font-family: Verdana, sans-serif;"> "<i style="background-color: #fff9ee; color: #222222; font-size: 15.4px; line-height: 21.56px;">cat /proc/user_beancounters" </i></span><br />
<span style="font-family: Verdana, sans-serif;"><i style="background-color: #fff9ee; color: #222222; font-size: 15.4px; line-height: 21.56px;"><br /></i>
</span><br />
<span style="color: #222222; font-family: Georgia, Utopia, Palatino Linotype, Palatino, serif;"><span style="background-color: #fff9ee; font-family: Verdana, sans-serif; font-size: 15.4px; line-height: 21.56px;">You have to investigate the output of the above command to understand why it couldn't allocate 5G to second instance.</span></span><br />
<br />
<span style="color: #222222; font-family: Georgia, Utopia, Palatino Linotype, Palatino, serif;"><span style="background-color: #fff9ee; font-family: Verdana, sans-serif; font-size: 15.4px; line-height: 21.56px;">Look for this row:</span></span><br />
<span style="color: #222222; font-family: Georgia, Utopia, Palatino Linotype, Palatino, serif;"><span style="background-color: #fff9ee; font-family: Verdana, sans-serif; font-size: 15.4px; line-height: 21.56px;"> <i>privvmpages</i></span></span><br />
<span style="color: #222222; font-family: Georgia, Utopia, Palatino Linotype, Palatino, serif;"><span style="background-color: #fff9ee; font-family: Verdana, sans-serif; font-size: 15.4px; line-height: 21.56px;">Check for <i>limit</i> column. That number is the maximum limit that can be allocated to any application. In my case, it was just about 5G. Thats it!</span></span><br />
<span style="color: #222222; font-family: Georgia, Utopia, Palatino Linotype, Palatino, serif;"><span style="background-color: #fff9ee; font-family: Verdana, sans-serif; font-size: 15.4px; line-height: 21.56px;">They will not allow you to edit and increase this limit. You have to go for either large vps or a dedicated server to allocate more memory.</span></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-79053778986048125012015-10-17T18:25:00.000-07:002016-08-15T07:21:21.855-07:00Increase memcached memory limit in ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;">Follow the below simple steps to increase memcached memory limit for production use:</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">1) In Ubuntu, memcached configuration file is located at /etc/</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivbKOAi5swlV3YQqbam77ji_Fz9us1uPp_BlHYwcBOPmniIAx_P4LwES3kJrh6l_Gf4Hjmdeaz5juC31WY6mDH_ZZ3mQLZTFmjNndXPva4hYPtESiqberGSV4gSbVWCqPhgWpKB0N0G64/s1600/memcache-command.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivbKOAi5swlV3YQqbam77ji_Fz9us1uPp_BlHYwcBOPmniIAx_P4LwES3kJrh6l_Gf4Hjmdeaz5juC31WY6mDH_ZZ3mQLZTFmjNndXPva4hYPtESiqberGSV4gSbVWCqPhgWpKB0N0G64/s1600/memcache-command.png" /></span></a></div>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">2) increase the value of -m 64 ( default ) to 2 to 3g.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpCp74850w3EWnmyZ50u8JoMtXh68scfS4ntn9NYRGdk_b05BO5ypEo4AigTZZmqy75nQPSPPMsl3jmPHUFTqWni2rd_wXh-hUFVm8fyrog-DzS-tEOmAGje_bFIn-ukH-jjIMedui4-E/s1600/memcache-memory.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" height="202" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpCp74850w3EWnmyZ50u8JoMtXh68scfS4ntn9NYRGdk_b05BO5ypEo4AigTZZmqy75nQPSPPMsl3jmPHUFTqWni2rd_wXh-hUFVm8fyrog-DzS-tEOmAGje_bFIn-ukH-jjIMedui4-E/s320/memcache-memory.png" width="320" /></span></a></div>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">3) Restart memcached server</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"> <span style="background-color: black;"><span style="color: white;">/etc/init.d/memcached restart</span></span></span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-88358808326908516722015-10-13T13:23:00.001-07:002016-08-15T07:22:15.405-07:00Display Number of Processors in Linux<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;">The below command spits the number of processors of Linux machine. In Linux, /proc/cpuinfo has all the processor information for all current processors in your machine.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<i><span style="font-family: Verdana, sans-serif;"><b>cat /proc/cpuinfo | grep processor | wc -l</b></span></i><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">or</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<i><span style="font-family: Verdana, sans-serif;"><b>nproc</b></span></i><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">or</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">lscpu gathers cpu architecture information in human readable format</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<i><span style="font-family: Verdana, sans-serif;"><b>lscpu</b></span></i><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<br /></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-37332192866618427532015-10-13T10:13:00.002-07:002016-08-15T07:22:38.931-07:00Simultaneous TCP connection limitations of Virtual Private Server ( VPS )<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">Thinking that one VPS machine can handle more than 100k concurrent users, I have configured nginx web server to handle quite a large number of concurrent users and adjusted glassfish web instance max connection, thread pools and acceptor threads to a large and optimized values.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">I tested this setup with quite a large number of users but it was not going beyond 3k users concurrently. Finally I came across the network tcp connection limitations of vps server and restrictions made by the hosting providers. In order to make these many number of concurrent users even one dedicated machine is not enough. We need to have a cloud setup.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">I don't believe that even a good dedicated server can handle 100k TCP requests</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">simultaneously. Your vServer is limited by the user_beancounters. You can</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">check these with</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<i><span style="font-family: Verdana, sans-serif;"><b>cat /proc/user_beancounters</b></span></i></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">The numtcpsock parameter will show you how many TCP connections can be handled in parallel.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<a href="https://wiki.openvz.org/UBC_primary_parameters"><span style="font-family: Verdana, sans-serif;">https://wiki.openvz.org/UBC_primary_parameters</span></a></div>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com1tag:blogger.com,1999:blog-278716001206238189.post-56843631034262349492015-10-13T10:02:00.001-07:002016-08-15T07:23:09.866-07:00How to check Java Max Heap Size in Ubuntu<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'</span></div>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-75523247839412215092013-11-26T13:49:00.001-08:002016-08-15T07:30:32.291-07:00Native Query Mapping to Transient Fields of Entity class<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;"><span style="font-family: "trebuchet ms" , sans-serif;">Native queries are often a problem when comes to mapping with customized Entity classes. </span><span style="font-family: "trebuchet ms" , sans-serif;">Especially classes with transient fields. To overcome this problem we have a special annotation available in JPA since version 1.0.</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: "trebuchet ms" , sans-serif;"> </span><span style="font-family: "trebuchet ms" , sans-serif;">@SqlResultSetMapping</span></span><br />
<span style="font-family: Verdana, sans-serif;">That will do the trick for you!</span><br />
<span style="font-family: Verdana, sans-serif;">This type of mapping is called scalar mapping. The only problem in choosing JPA is, the community is very limited and very limited resources are available internet. For complex JPA queries, most struggle to find a solution.</span><br />
<span style="font-family: Verdana, sans-serif;">So I am going to show an example of mixing entity and scalar mapping.</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<script class="brush: java" type="syntaxhighlighter"><![CDATA[
@SqlResultSetMapping(
name = "ProjectProgress",
entities = {
@EntityResult(entityClass = Project.class)
},
columns = {
@ColumnResult(name = "progress")})
@Entity
@Table(name = "project")
@XmlRootElement
public class Project implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Long id;
@Transient
private Long progress = 0L;
}
]]></script><span style="font-family: "trebuchet ms" , sans-serif;">
@ColumnResult(name = "progress") does the scalar mapping. Remember that when you write your native query, It must have a column with alias progress.</span></span><br />
<span style="font-family: Verdana, sans-serif;">For example: select p.*, count(*) as progress from project p</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: "trebuchet ms" , sans-serif;">We can also use </span><span style="font-family: "trebuchet ms" , sans-serif;">@SqlResultSetMapping to map different Entities from one native query. I will show this example in my next post.</span></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com1tag:blogger.com,1999:blog-278716001206238189.post-68499596160969125802013-10-31T03:19:00.001-07:002013-10-31T03:19:51.006-07:00How to make java program run as a service/daemon in linux<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Courier New, Courier, monospace;"><b>Create a shell script as below</b></span><br />
<script class="brush: java" type="syntaxhighlighter"><![CDATA[
#!/bin/sh
### BEGIN INIT INFO
# Provides: push
# X-Interactive: true
# Short-Description: Start/stop push server
### END INIT INFO
PUSHPATH=/home/push
case $1 in
start)
echo "Starting push ..."
if [ ! -f $PUSHPATH/pid ]; then
nohup java -jar $PUSHPATH/push.jar $PUSHPATH 2>> /dev/null >> /dev/null &
echo $! > $PUSHPATH/pid
echo "push started ..."
else
echo "push is already running ..."
fi
;;
stop)
if [ -f $PUSHPATH/pid ]; then
PID=$(cat $PUSHPATH/pid);
echo "Stopping push ..."
kill $PID;
echo "push stopped ..."
rm $PUSHPATH/pid
else
echo "push is not running ..."
fi
;;
restart)
if [ -f $PUSHPATH/pid ]; then
PID=$(cat $PUSHPATH/pid);
echo "Stopping push ...";
kill $PID;
echo "push stopped ...";
rm $PUSHPATH/pid
echo "Starting push ..."
nohup java -jar $PUSHPATH/push.jar $PUSHPATH 2>> /dev/null >> /dev/null &
echo $! > $PUSHPATH/pid
echo "push started ..."
else
echo "push is not running ..."
fi
;;
esac
]]></script>
<span style="font-family: Courier New, Courier, monospace;">Now move this file to init.d location and issue update command to automatically start this as service when system reboots.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<script class="brush: java" type="syntaxhighlighter"><![CDATA[
sudo mv push.sh /etc/init.d/push
sudo chmod +x /etc/init.d/push
sudo update-rc.d push defaults
]]></script>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-88994326904330725352013-10-17T00:15:00.001-07:002016-08-15T07:31:35.824-07:00Connecting to Plesk Mysql through Command Line<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-family: Verdana, sans-serif;">Connecting to Plesk Mysql though Command Line:</span></b><br />
<span style="font-family: Verdana, sans-serif;"><b><span style="font-family: Courier New, Courier, monospace;"><br /></span></b>
<span style="font-family: Courier New, Courier, monospace;"> Connection to plesk mysql on ubuntu systems doesn't work in the usual way. Plesk mysql password is stored in a different location and its encrypted too. So we can't keyin the normal password through commandline unless you know the complete encrypted form.So, mysql -u root -p command is not going to work for you. Use the below command to connect to plesk mysql on ubuntu systems through command line. </span><span style="font-family: 'Courier New', Courier, monospace;"><b>/etc/psa/.psa.shadow ( this is the place where your plesk mysql password is stored ). </b>Use "cat" command to print the password right after -p.</span></span><br />
<span style="font-family: Verdana, sans-serif;"> </span><br />
<div style="text-align: left;">
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"> <b><span style="color: blue; font-size: medium;">mysql -uadmin -p`cat /etc/psa/.psa.shadow`</span></b></span><span style="font-family: 'Courier New', Courier, monospace;"><span style="color: blue; font-size: large;"> </span> </span></span></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-25749974803196956342013-10-06T23:06:00.000-07:002016-08-15T07:32:20.129-07:00Install Android in NetBeans 7.3<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;"><b>Android in Netbeans 7.3</b></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Please follow the below steps to install Android in NetBeans 7.3</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Step1:</span></span><br />
<span style="font-family: Verdana, sans-serif;"> Open Netbeans, Go to Tools->Plugins, and select Settings Tab, Click on Add button</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Step 2:</span></span><br />
<span style="font-family: Verdana, sans-serif;"> In URL field, paste the below url</span><br />
<span style="font-family: Verdana, sans-serif;"> <a href="http://nbandroid.org/release72/updates/updates.xml">http://nbandroid.org/release72/updates/updates.xml </a> </span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> In Name Field, "Android"</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB92aEjpvn3lQwThbwQYv0Yk87tbSYBohr1bFQ4X8MSXCA2IouhL3oexRKpdJN0zdjElvCjtv4TRl5mmsrGN8kVgkEuIuaTcdQwGE1qOnlgWsizCf6rGG3uYPSi6WhUGZhqWzNfX9Qev4/s1600/android.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" height="380" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB92aEjpvn3lQwThbwQYv0Yk87tbSYBohr1bFQ4X8MSXCA2IouhL3oexRKpdJN0zdjElvCjtv4TRl5mmsrGN8kVgkEuIuaTcdQwGE1qOnlgWsizCf6rGG3uYPSi6WhUGZhqWzNfX9Qev4/s640/android.png" width="640" /></span></a></div>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Step 3: </span></span><br />
<span style="font-family: Verdana, sans-serif;"> Now go to Available Plugins tab and search for "Android", select android plugin and click Install button and restart NetBeans.</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Step 4:</span></span><br />
<span style="font-family: Verdana, sans-serif;"> Create new android project: </span><br />
<span style="font-family: Verdana, sans-serif;"> select "Android" category and "Android Project" from Projects section.</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBCjjp3CXxxnyfVk6VbvrBLtW8CpJ46wKCcAtpbEh0N-F6uLsIbDpi4uraNUX17YPAfEkVGIZQ3UcJuCLKwwPC0lL3v8SFefr7GMJOD7h_UuxZRbj7wCgKWHbLH8nNh_GI_FQj5L-LSxs/s1600/android.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBCjjp3CXxxnyfVk6VbvrBLtW8CpJ46wKCcAtpbEh0N-F6uLsIbDpi4uraNUX17YPAfEkVGIZQ3UcJuCLKwwPC0lL3v8SFefr7GMJOD7h_UuxZRbj7wCgKWHbLH8nNh_GI_FQj5L-LSxs/s1600/android.png" /></span></a></div>
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">Step 5: Provide project Name, Location, package name, main activity and select android target platform.</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDFeweliwuM-8j4-2wcAjGwEf4rf1pNtMaO9qD6Y9q4Yp9kkHGRow3J9398scEvR7jKTrUBImVNx9_Jvo-TpkMpXN_7QOh4kIlXDVr2f6tbbC5zNmwcbWzhzh67vxr-u3gLWZt5erPA7Q/s1600/android-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDFeweliwuM-8j4-2wcAjGwEf4rf1pNtMaO9qD6Y9q4Yp9kkHGRow3J9398scEvR7jKTrUBImVNx9_Jvo-TpkMpXN_7QOh4kIlXDVr2f6tbbC5zNmwcbWzhzh67vxr-u3gLWZt5erPA7Q/s1600/android-1.png" /></span></a></div>
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /> If Android SDK is not configured, Please go to android developer site and download the latest android sdk </span><a href="http://developer.android.com/sdk/index.html"><span style="font-family: Courier New, Courier, monospace;">http://developer.android.com/sdk/index.html</span></a></span><br />
<span style="font-family: Verdana, sans-serif;">and configure its path in netbeans ( Go to Tools->Options and select Android tab )</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI9QuahzFCEzZRT6Brqe-0dUoOZl6SzaMErBNlDttftYXJM_BK7EsQTd10hZCc9rhn4fQhSzxiW3w5tr41oz3_U0ipvyenuQZMTdYgrVpnrx2REGCKklJO8WLtuTz53DRkQFOsti7xjqU/s1600/android-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI9QuahzFCEzZRT6Brqe-0dUoOZl6SzaMErBNlDttftYXJM_BK7EsQTd10hZCc9rhn4fQhSzxiW3w5tr41oz3_U0ipvyenuQZMTdYgrVpnrx2REGCKklJO8WLtuTz53DRkQFOsti7xjqU/s1600/android-2.png" /></span></a></div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-1286997941442073112013-10-03T00:06:00.000-07:002016-08-15T07:32:59.222-07:00Glassfish 4 and Primeface 4.0.RC1 fileupload issues<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-family: Verdana, sans-serif;">Glassfish 4 and Primeface fileupload issues!</span></b><br />
<span style="font-family: Verdana, sans-serif;"><b><span style="font-family: Courier New, Courier, monospace;"><br /></span></b>
<span style="font-family: Courier New, Courier, monospace;"><b>Maven dependencies:</b></span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span></span>
<span style="font-family: Verdana, sans-serif;"><dependency></span><br />
<span style="font-family: Verdana, sans-serif;"> <groupId>org.primefaces</groupId></span><br />
<span style="font-family: Verdana, sans-serif;"> <artifactId>primefaces</artifactId></span><br />
<span style="font-family: Verdana, sans-serif;"> <version>4.0.RC1</version></span><br />
<span style="font-family: Verdana, sans-serif;"></dependency></span><br />
<span style="font-family: Verdana, sans-serif;"><dependency></span><br />
<span style="font-family: Verdana, sans-serif;"> <groupId>org.apache.commons</groupId></span><br />
<span style="font-family: Verdana, sans-serif;"> <artifactId>commons-io</artifactId></span><br />
<span style="font-family: Verdana, sans-serif;"> <version>1.3.2</version></span><br />
<span style="font-family: Verdana, sans-serif;"></dependency></span><br />
<span style="font-family: Verdana, sans-serif;"><dependency></span><br />
<span style="font-family: Verdana, sans-serif;"> <groupId>commons-fileupload</groupId></span><br />
<span style="font-family: Verdana, sans-serif;"> <artifactId>commons-fileupload</artifactId></span><br />
<span style="font-family: Verdana, sans-serif;"> <version>1.3</version></span><br />
<span style="font-family: Verdana, sans-serif;"></dependency></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><b>uploadFile.getContents() method is not working in primeface 4.0.RC1 version. To get the file content, use the below code:</b></span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">private byte[] getFileContents(InputStream in) {</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>byte[] bytes = null;</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>try {</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> // 277*121, 292*170, 327*143, 586*340</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> // write the inputStream to a FileOutputStream </span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> ByteArrayOutputStream bos = new ByteArrayOutputStream();</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> int read = 0;</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> bytes = new byte[1024];</span><br />
<span style="font-family: Verdana, sans-serif;"><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> while ((read = in.read(bytes)) != -1) {</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>bos.write(bytes, 0, read);</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> }</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> bytes = bos.toByteArray();</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> in.close();</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> in = null;</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> bos.flush();</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> bos.close();</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> bos = null;</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> logger.debug("New file created!");</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>} catch (IOException e) {</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span> System.out.println(e.getMessage());</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: Verdana, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return bytes;</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"></span><br /></span>
<span style="font-family: Verdana, sans-serif;">}</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">getFileContents(getFile().getInputstream());</span></span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com1tag:blogger.com,1999:blog-278716001206238189.post-65590799995937985402013-08-13T13:06:00.003-07:002016-08-15T07:35:00.373-07:00Eclipselink Unique Key Constraint Log issue in glassfish server<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;">You can find lot of people asking how to disable eclipselink unique key constraint violation logs in glassfish server, and there are lot of replies where none of them really works. The real solution lies in glassfish server configuration and not in eclipselink configuration. You can find lot of posts referring to eclipselink configuration where we have to add some property tags in persistence.xml file to switch off logs, but that wont stop the logs in glassfish.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><property name="eclipselink.logging.level" value="OFF" /></span><br />
<span style="font-family: Verdana, sans-serif;"><property name="eclipselink.logging.parameters" value="false"/> </span><br />
<span style="font-family: Verdana, sans-serif;"><property name="eclipselink.target-server" value="SunAS9"/></span><br />
<span style="font-family: Verdana, sans-serif;"><property name="eclipselink.logging.exceptions" value="false"/></span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">By the time you catch exception, database constraint voilation would have already written to glassfish server log. So you have to switch off glassfish JTA server logs. But where and how to do it??? This blog entry has the answer for that.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">Please follow the below steps :</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<ol style="text-align: left;">
<li><span style="font-family: Verdana, sans-serif;">Log in to glassfish admin console</span></li>
<li><span style="font-family: Verdana, sans-serif;">Go to Configurations->server-config->Logger Settings</span></li>
</ol>
<div>
<span style="font-family: Verdana, sans-serif;"> </span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVVbroYRFL-aoovAkJJlzRLYtNJRnd1SQAOmhS2FfCcWYWSTYHqnXmNMQClcW6d6sr692_lk5lmiemOReYH_rsv4XJodxYqN1N6XWgHuO0YdqSujTGl2Xi4AMUesNc4EwdQ23N_lKW0Rg/s1600/glassfisheclipselinklogs.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" height="539" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVVbroYRFL-aoovAkJJlzRLYtNJRnd1SQAOmhS2FfCcWYWSTYHqnXmNMQClcW6d6sr692_lk5lmiemOReYH_rsv4XJodxYqN1N6XWgHuO0YdqSujTGl2Xi4AMUesNc4EwdQ23N_lKW0Rg/s640/glassfisheclipselinklogs.png" width="640" /></span></a></div>
</div>
<div>
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"> </span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"> </span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"> 3. select javax.enterprise.resource.jta option and select SEVERE from log level combobox.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"> 4. Save and restart the server</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<br /></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-38977712938523825812013-08-02T12:32:00.004-07:002015-02-28T12:12:34.662-08:00Spring security REST Authentication ( apikey or token based authentication )<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-family: Verdana, sans-serif;">Spring Security REST Authentication:</span></b><br />
<span style="font-family: Verdana, sans-serif;"> One of the most searched terms on internet. Yes, I have searched a lot to accomplish a successful and well secured RESTful authentication. A lot of articles are available on internet regarding spring security, most of the articles are talking about the advanced technology behind it, but none of them explained the basic workflow of it. After searching for almost 2-3 weeks, Finally I have got a blog link for the entire code to achieve what I want, though, the explanation was not quite understandable. If you can understand just by looking at the code, you can copy paste the below code straight away. Users who prefer to understand the work flow nature of spring security REST authentication, please see the below picture. Its better to explain concepts using pictures rather than writing 1000 of words.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">Let me list out the names of all classes we need</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">1) RESTAuthenticationFilter.java</span><br />
<span style="font-family: Verdana, sans-serif;">2) RESTAuthenticationToken.java</span><br />
<span style="font-family: Verdana, sans-serif;">3) RESTCredentials.java</span><br />
<span style="font-family: Verdana, sans-serif;">4) UserSecurityServiceImpl.java</span><br />
<span style="font-family: Verdana, sans-serif;">5) UserSecurityService.java</span><br />
<span style="font-family: Verdana, sans-serif;">6) UserSecurityRepository.java</span><br />
<span style="font-family: Verdana, sans-serif;">7) UserSecurityRepositoryImpl.java</span><br />
<span style="font-family: Verdana, sans-serif;">8) RESTUser.java</span><br />
<span style="font-family: Verdana, sans-serif;">9) HMacShaPasswordEncoder.java</span><br />
<span style="font-family: Verdana, sans-serif;">10) RESTDaoAuthenticationProvider.java</span><br />
<span style="font-family: Verdana, sans-serif;">11) UserNotFoundException.java</span><br />
<span style="font-family: Verdana, sans-serif;">12) NoRedirectStrategy.java</span><br />
<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/AVvXsEjcNYysRrcfKb3FDqOSNgKwyUlL6GmFM72RllmWeOpWCZnnNyVpPnDyXU9NgrkybyGKJ3VoKUoSYPwPmyhsakG4c3iYpehrUJqumhU8gXfA7LAZf29neIZojXMwbMAq6rTbODr0JtnmobI/s1600/restauthentication.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcNYysRrcfKb3FDqOSNgKwyUlL6GmFM72RllmWeOpWCZnnNyVpPnDyXU9NgrkybyGKJ3VoKUoSYPwPmyhsakG4c3iYpehrUJqumhU8gXfA7LAZf29neIZojXMwbMAq6rTbODr0JtnmobI/s1600/restauthentication.png" /></span></a></div>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">Above diagram shows the basic authentication flow of spring security. It all begins with a user who tries to login to a secured system. For example, lets take a simple url ( http://localhost/web-app/secured/payment) We are going to let only users who have the right permission/role to access secured urls. In that URL, "web-app" is the context-name and "/secured" is the relative url prefix mapped to DispatcherServlet. Whevever a url request hits the server with "/secured" as its relative prefix, DispatcherServlet handles/process the request. Put the below code in web.xml to create url-mapping. </span><br />
<span style="font-family: Verdana, sans-serif;"><b>Web.xml
</b><script class="brush: html" type="syntaxhighlighter"><![CDATA[
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/app/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/secured/*</url-pattern>
</servlet-mapping>
]]></script>
</span><br />
<span style="font-family: Verdana, sans-serif;">Before this request is handed over to Spring controller and DispatcherServlet, we have to make sure the user has the rights/authority/permission to access this particular page. To bring authentication in to play, Enable spring security filter in web.xml and map spring security filter to this url-mapping (.../secured/...) in applicationContext-security.xml to intercept the secured url calls. Use the below code</span><br />
<span style="font-family: Verdana, sans-serif;"><b>web.xml</b></span>
<script class="brush: html" type="syntaxhighlighter"><![CDATA[
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
]]></script>
<br />
<b>applicationContext-security.xml</b><script class="brush: html" type="syntaxhighlighter"><![CDATA[
<http realm="Protected Rest API" disable-url-rewriting="true"
entry-point-ref="forbiddenEntryPoint" use-expressions="true"
create-session="never" pattern="/secured/**">
<session-management session-fixation-protection="none"/>
<custom-filter ref="defaultRestAuthenticationFilter" position="FORM_LOGIN_FILTER" />
<intercept-url pattern="/secured/**" access="isAuthenticated()" />
</http>
]]></script><br />
<span style="font-family: Verdana, sans-serif;">The above tag applies spring security to all urls begins with "/secured" as their relative path. Now, no one can access secured urls without proper authentication. </span><br />
<span style="font-family: Verdana, sans-serif;">The above are the basic config tags that you must apply to implement any authentication scheme offered by spring. Lets take a look at some of the new bean instance references shown in applicationContext-security.xml (forbiddenEntryPoint and defaultRestAuthenticationFilter).</span><span style="font-family: Verdana, sans-serif;"> </span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">forbiddenEntryPoint: </span><span style="font-family: Verdana, sans-serif;">When a user tries to access a protected url without proper authentication details, display forbidden message ( httpstatus 405 ).</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">defaultRestAuthenticationFilter: As shown in the diagram, its the entry point for all url requests. This is the place where all secured url authentication is validated. This filter extracts the token, signatures and salt parameter and validates the authentication details. If the url has all the required authentication details, then it is passed on to the next spring security filter chain and finally to the actual spring controller. In our case its "payment" controller. Take some time to understand the below code, you can find a few new bean references.</span><br />
<b>applicationContext-security.xml</b><br />
<script class="brush: html" type="syntaxhighlighter"><![CDATA[
<beans:bean id="forbiddenEntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/>
<beans:bean id="restAuthenticationFilter" class="com.example.auth.http.RESTAuthenticationFilter">
<beans:constructor-arg name="defaultFilterProcessesUrl" value="/"/>
<beans:property name="authenticationManager" ref="authenticationManager"/>
<beans:property name="authenticationSuccessHandler">
<beans:bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler">
<beans:property name="redirectStrategy">
<beans:bean class="com.example.auth.http.NoRedirectStrategy"/>
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="daoAuthenticationProvider"/>
</authentication-manager>
<beans:bean id="daoAuthenticationProvider" class="com.example.auth.RESTDaoAuthenticationProvider">
<beans:property name="userSecurityService" ref="userSecurityServiceImpl"/>
<beans:property name="passwordEncoder" ref="passwordEncoder"/>
</beans:bean>
<beans:bean id="passwordEncoder" class="com.example.auth.algorithms.HMacShaPasswordEncoder">
<beans:constructor-arg name="strength" value="256"/>
<beans:constructor-arg name="encodeHashAsBase64" value="true"/>
</beans:bean>
]]></script>
</div>
Authentication Manager processes an authentication request. As shown in the diagram above, Authentication Filter passes an authentication object to Authentication Manager and finally returns a fully populated authentication object(including granted authorities ) if successful. <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/authentication/AuthenticationManager.html">http://static.springsource.org/spring-security/site/docs/3.0.x/apidocs/org/springframework/security/authentication/AuthenticationManager.html</a>. AuthenticationManager is a kind of wrapper class, It can support multiple AuthenticationProviders.<br />
<br />
AuthenticationProvider is where the core authentication details validation logic is defined. It has retrieveUser(......) delegate method that takes username and UsernamePasswordAuthenticationToken as params and returns UserDetails instance which includes GrantedAuthority if successful.</div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-56251972954917970312013-07-27T13:29:00.002-07:002016-08-15T07:37:17.723-07:00Java Automated Build Process With Hudson, Nexus, Git and Maven<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;">Automated Build Process</span></b></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN7whudSzvMvNH-53jGATnpZJcwrpHyEjH6QA9P6e5KhFH1JRn3I0YpjBGL5uc2CqdPvOCu-KZ0R29gLiQ_bdySTgqL7ny_EY9GBvvvxFCxN4zkwCnKA9MWkSmBIrFUsCeVge5pClo6Yo/s1600/automatedbuild.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN7whudSzvMvNH-53jGATnpZJcwrpHyEjH6QA9P6e5KhFH1JRn3I0YpjBGL5uc2CqdPvOCu-KZ0R29gLiQ_bdySTgqL7ny_EY9GBvvvxFCxN4zkwCnKA9MWkSmBIrFUsCeVge5pClo6Yo/s1600/automatedbuild.png" /></span></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;"><br /></span></b></div>
<span style="font-family: Verdana, sans-serif;">
I am going to explain the above picture work flow, then we will look at each technologies in detail.<br /><b>Validate </b>- validate the project<br /><b>Test </b>- Test the compiled source code using a suitable unit testing framework. Test code is separated from source code. Its not packaged and deployed with source code.<br /><b>Package</b>- Take the compiled source code and packaged in to a distributed format, such as jar/war<br /><b>Integration-test</b> - process and deploy the package if necessary into an environment where integration tests can be run<br /><b>Verify</b>- Run and check to verify the package is valid or not<br /><b>Install </b>- Install the package in to the local repository<br /><b>Deploy</b>- Done in release environment. Deploy the package in to remote repository for sharing with developers or other projects.</span><br />
<br />
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>1</b>. Developer has git installed in his local system. Lets assume that he has completed the task, he issues git commit command to commit his current changes in his local repository.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>2</b>. He, then issues git push command to push his changes to the remote repository which is a centralized repository server where the source code version is maintained. Clients connects to this centralized version control server to clone, pull, commit, push their changes. To learn more about git command please visit <a href="http://git-scm.com/documentation">http://git-scm.com/documentation</a></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>3</b>. Hudson(Continuous Integration) server. CI main focus is to notify the users who breaks the build due to erroneous code changes. Its possible that developers sometimes commit and push their changes without proper testing. So, CI connects to our central code repository server and picks the latest changes periodically and verify the changes by running test against them. It can be configured to notify all the developers in case if the build breaks. As shown in the diagram, It connects to the central repository to fetch the latest changes</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>4</b>. Picks the latest changes and validate, compile, build, package, install in to the local repository or notify developers in case of any failure</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>5</b>. If build and release phase is configured in the pom.xml file, It performs a release and deploy the new version in nexus repository management server.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>6</b>. This step is performed to automate the deployment of new version release in our web application server. In this step, We have to create a script file and configure it to execute after a successful release in pom.xml. This script file main focus is to connect to the nexus repository and download the latest release.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>7</b>. Once the download is complete, script file automatically deploy the distribution war in our web application server(glassfish opensource edition).</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">In java world, if you are a programmer who frequently working with server side applications, then an automated build process is very essential. In this post I will try to explain the work flow of an automated build system that we are currently following in our company. Automated build process of java application become very popular with the release of Maven technology. Without Maven its very tedious to build an automated system. Maven simplified the entire automated build process. Maven has its own life cycle to build an application phase by phase. It starts with</span></div>
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;"><br /></span></b></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>Compile</b>- Compile the source code of the project</span></div>
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;"><br /></span></b></div>
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;"><br /></span></b></div>
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;"><br /></span></b></div>
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;"><br /></span></b></div>
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;"><br /></span></b></div>
<div style="text-align: left;">
<b><span style="font-family: Verdana, sans-serif;"><br /></span></b></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;">pom.xml is the heart of any maven project. Its the file where we can configure the build phases, what to include/exclude in a phase, how to filter unwanted dependencies, and most importantly how to maintain the dependencies. Managing dependencies version is one of the most important aspect of maven technology. In early days, developers has to taken care of the dependency jar file versions manually. But maven simply eliminated that need and provided a framework to handle all dependency files versions automatically. If we put "LATEST" as the version under "<version>" tag, maven automatically fetches the latest version of that dependency from maven central repository. Its that simple.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>Sonatype Nexus</b>: Nexus is a repository management standard. It helps the developers to share the artifacts with other projects.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>Hudson</b>: Continuous Integration, CI is a technology to automate the build process. It periodically check the code changes in source code repositories with the help of SCM tags and validate, compile, test, build and install the distribution package in local repository. It alerts the developers in case of any build cycle failure.</span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Verdana, sans-serif;"><b>GIT: </b>GIt is a distributed version control and source code management (SCM) system.</span></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0tag:blogger.com,1999:blog-278716001206238189.post-3993516280835962122013-07-21T09:22:00.002-07:002016-08-15T07:38:22.360-07:00JVM Tuning<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;">JVM is the heart of any java based applications. Most of the issues we face in our applications and servers are due to incorrect JVM settings and memory leaks. Memory leaks, well, we have no option we have to sit and debug the code. But the former is entirely a different task, Tuning a JVM is a dark art. You need to have complete knowledge about the JVM architecture. Also, tuning a JVM for a specific hardware is another headache. I have struggled a lot to configure our Glassfish server on Ubuntu with 16GB RAM. </span><span style="font-family: Verdana, sans-serif;">The default glassfish server JVM settings are not suitable for production use and that required some alteration. </span><span style="font-family: Verdana, sans-serif;">Now, after so much struggle, our server is running fine. So I thought this post would be helpful for some people who are struggling like me to configure JVM settings for different application servers. First we will learn about each segments of JVM in detail and in my next post I will show the glassfish jvm settings for production use.</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu9arJP1s3KFHcHRpTZTqkE962y4isW3QXIAcTCgA_ZRoCjSsmlVb7h_Gz3jWKtsOfm0iuP3z7nlYAS58hGUGhj5v01icCvRjnuOuqk0N3ZNN_Jk8wg7n37WuctooMeflgnFIh-rBE-4o/s1600/jvm.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu9arJP1s3KFHcHRpTZTqkE962y4isW3QXIAcTCgA_ZRoCjSsmlVb7h_Gz3jWKtsOfm0iuP3z7nlYAS58hGUGhj5v01icCvRjnuOuqk0N3ZNN_Jk8wg7n37WuctooMeflgnFIh-rBE-4o/s640/jvm.png" width="640" /></span></a></div>
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><span id="goog_736854938"></span><span id="goog_736854939"></span><br /></span></span><br />
<span style="font-family: Verdana, sans-serif;"><b>-Xms:</b> This jvm argument request the operating system to allocate the minimum amount of heap memory at start-up. i.e, -Xms1g allocates 1GB as the initial heap memory. It accepts m and g as the units</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>-Xmx:</b> Set the maximum amount of JVM heap memory. OutOfMemoryException is thrown when memory goes beyond this level due to memory leaks or because of overload condition.</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>-XX:NewRatio:</b> It defines the old/new generation ratio. In other words, this ratio defines the size of old(tenured) and new(eden) generation space. i.e, </span></span><br />
<span style="font-family: Verdana, sans-serif;">-XX:NewRatio=2 allocates 2:1 ratio for old to new generation.</span><br />
<span style="font-family: Verdana, sans-serif;">If our max heap space is -Xmx=9g, then the calculation goes like this</span><br />
<span style="font-family: Verdana, sans-serif;">2 / 3 * 9 = 6GB for old generation</span><br />
<span style="font-family: Verdana, sans-serif;">1 / 3 * 9 = 3GB for new generation</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>-XX:PermSize:</b> Allocates the initial permanent generation non heap size</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>-XX:MaxPermSize:</b> </span><span style="font-family: Verdana, sans-serif;">Allocates the maximum permanent generation non heap size</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>-XX:SurvivorRatio:</b> This parameter controls the size of two survivor spaces. i.e, </span><span style="font-family: Verdana, sans-serif;">-XX:SurvivorRatio=6 sets the ratio between each survivor space and eden to be 1:6, each survivor space will be one-eighth of the young generation.</span></span><br />
<span style="font-family: Verdana, sans-serif;">UseAdaptiveSizePolicy parameter must be disabled, otherwise jvm ignore this parameter. If the size is too small, copying collection overflows directly in to tenured space. If the size is too large, they will be empty.</span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>-server:</b> jvm can be tuned for client or server machine. For example, If you download glassfish app server, by default, it is configured for client machine using -client parameter. But for production, we have to change this parameter to -server for better performance. -client and -server changes the garbage collection algorithms. <b>-client</b> uses <b>Serial collector</b> and <b>-server</b> uses <b>Parallel collector</b> algorithms. We will see GC algorithms in a short while.</span></span><br />
<span style="font-family: Verdana, sans-serif;"><span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><b>How Garbage Collection works?</b></span></span><br />
<span style="font-family: Verdana, sans-serif;"> All GC algorithms follows the same basic principle to deliver better memory utilization, though their implementation differs, some algorithms favor better throughput and some favor reduced latency. But their core principle is the same. When new instances/objects are created by the application, it is pushed in to Eden/young generation space, from there, algorithm detects whether its a short lived or long lived object, if its a long lived object, it is further moved on to survivor spaces and then on to tenured or old generation.</span><br />
<span style="font-family: Verdana, sans-serif;">Finally when full GC occurs, this old object will be cleaned up if the object has no references. Short lived object stays in eden or in survivor spaces and cleaned up when short pause GC occurs.</span></div>
Anonymoushttp://www.blogger.com/profile/03495649753511438425noreply@blogger.com0