Hobione's Weblog

Living & Breathing in Web 2.0 Era

raspberry pi 3 disable screen saver

The easiest way to disable screen blanking in the Raspbian GUI is to install xscreensaver then configure it to disabled.

Open up the terminal window and run these two lines

sudo apt-get update
sudo apt-get install xscreensaver

You may have to reboot after installing xscreensaver.

Use mouse to go to Preferences –> Screen Saver (from top left menu option)

In the [Display Mode] tab, set like this – Mode: [Disable Screen Saver]

January 31, 2018 Posted by | rasberry pi | 1 Comment

RSA premaster secret error

I wrote how to use SSL connection string using JDBC driver in my previous blog. I deployed the code on the Unix server from Windows 7 pc and I got RSA premaster secret error.

Caused by: java.security.NoSuchAlgorithmException: SunTlsRsaPremasterSecret KeyGenerator not available

I figured it out after banging my head on the wall for couple of days. I had to explicitly use sunjce_provider.jar file name on the class path.

$JAVA_HOME/bin/java -Xms64m -Xmx256m -Djava.ext.dirs=.:$SURVEY_LIB -cp .:$JAVA_HOME/jre/lib/ext/sunjce_provider.jar:$CLASSPATH:$SURVEY_BIN/surveys.jar com.hobi.survey.SurveyMainClass getAllSurveys

August 29, 2014 Posted by | SSL | Leave a comment

SSL connection from Java to MSSQL Database Server using JDBC driver

First of all, need to get the self-signed certificate from database administrator and install/import to the following path.
C:\Program Files\Java\jdk1.7.0_17\jre\lib\security\cacerts

How to install ssl certificate?
Step 1: Get the certificate from certificate owner, it is usually .cer file (SQLcert.cer)
Step 2: Make a dir under c drive (c:\certificate)
Step 3: Copy the cacerts from C:\Program Files\Java\jdk1.7.0_17\jre\lib\security\cacerts to c:\certificate
Step4: Copy SQLcert.cer to c:\certificate
Step5: Open up a command prompt and change directory to c:\certificate
Step6: Execute this command
keytool -import -keystore cacerts -file SQLcert.cer

How to import SSL certificate

Step8: Copy cacerts file back to the original path –> *C:\Program Files\Java\jdk1.7.0_17\jre\lib\security

How to install jdbc4 driver to local maven repository?

Missing artifact com.microsoft.sqlserver:sqljdbc4:jar:4.0
To add the jar file in pom.xml since Microsoft don’t make this available via any maven repository.

Download the jar from the Microsoft website, and then manually install it into local maven repository using following command.
mvn install:install-file -Dfile=sqljdbc4.jar –DgroupId=com.microsoft.sqlserver –DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar

How to install jdbc4 driver to local maven repository


How to setup jdbc ssl connection string for MSSQL server 2012?

Pay attentions on slashes (forward slash vs backward slash: before server name, it has forward slash but after the server name there are two back slashes). I also had to use full server name instead of an ip address.

I was able to connect to the SQL server after few days of hard work.


How to list all certificates in cacerts file?
c:\Program Files\Java\jdk1.7.0_17\jre\lib\security>keytool -list -v -keystore cacerts

August 18, 2014 Posted by | SSL | , | Leave a comment

Oracle 11g on Windows 7 professional (32 bits)

I have downloaded two zip files for Oracle 11g release 2 from Oracle site as follows.

Unzipped ’em and ran setup.exe from \win32_11gr2_database_1of2\database\setup.exe and got zillion of file not found errors as follows.

–> \application\em.ear, \bin\db2gc\, \config\system-application.xml\

–> Template General_Purpose.dbc does not exist

–> Oracle Database Configuration Assistant failed

Anyway, after fiddling with some times, I found out that the two zip files I have downloaded, needed to combine together to solve file not found errors. So I copied win32_11gR2_database_2of2\database to win32_11gR2_database_1of2\database to merge two database directories and here is the login page for Oracle 11g r2 after a successful install.

A video that I found to show step by step but it does not say to combine two zip files if you download the the software from web.

January 20, 2011 Posted by | Databases: Oracle,MySql | 2 Comments

HSSFWorkbook object write it to Excel, send it as an attachment

public static void loadDailyDataToExcel(ResultSet rs, Statement st, Connection connection, Properties properties) {

 try {
 HSSFWorkbook workBook = new HSSFWorkbook();
 HSSFSheet sheet = workBook.createSheet("Excel Sheet");
 HSSFRow rowhead = sheet.createRow((short) 0);
 rowhead.createCell((short) 0).setCellValue("RESPONSE DATE");
 rowhead.createCell((short) 1).setCellValue("SERVICE ID");
 rowhead.createCell((short) 2).setCellValue("Q");
 rowhead.createCell((short) 3).setCellValue("T");
 rowhead.createCell((short) 4).setCellValue("V");
 rowhead.createCell((short) 5).setCellValue("CUSTOMER");
 rowhead.createCell((short) 6).setCellValue("OVERALL");
 rowhead.createCell((short) 7).setCellValue("COMMENTS");
 rowhead.createCell((short) 8).setCellValue("CONTACT");
 rowhead.createCell((short) 9).setCellValue("CONTACT INFO");

 int index = 1;
 Format formatter = new SimpleDateFormat("MM/dd/yy");

 while (rs.next()) {

 HSSFRow row = sheet.createRow((short) index);
 row.createCell((short) 0).setCellValue(formatter.format(rs.getDate(1)));
 row.createCell((short) 1).setCellValue(rs.getString(2));
 row.createCell((short) 2).setCellValue(rs.getString(3));
 row.createCell((short) 3).setCellValue(rs.getString(4));
 row.createCell((short) 4).setCellValue(rs.getString(5));
 row.createCell((short) 5).setCellValue(rs.getString(6));
 row.createCell((short) 6).setCellValue(rs.getString(7));
 String comments = rs.getString(8);
 if (comments != null) {
 row.createCell((short) 7).setCellValue(comments);
 String contact = rs.getString(9);
 if (contact != null) {
 row.createCell((short) 8).setCellValue(contact);
 String contactInfo = rs.getString(10);
 if (contactInfo != null) {
 row.createCell((short) 9).setCellValue(contactInfo);

 if (index > 1) {
 String fileName = "SurveyResponsesDailyReport-TestServices.xls";
 String to = properties.getProperty("survey.emailToDailyReport3aTest"); //from property file
 String subject = "Customer Survey 'Please Contact' Daily Summary - Test Services";
 String body = "Daily Survey Report for Test Services in Microsoft excel format.\n\n";
 emailNotification = new EmailNotification();
 emailNotification.sendEmailWithAttachment(to, subject, body, fileName, workBook, index);

 try {
 String hobiOneDirectoryPath = properties.getProperty("survey.hobiOneDirectoryPath"); // c:\\temp\\hobi\\
 FileOutputStream fileOut = new FileOutputStream(hobiOneDirectoryPath+"SurveyResponsesDailyReport-TestServices.xls");
 System.out.println("SurveyResponsesDailyReport-TestServices.xls was copied to "+ hobiOneDirectoryPath);

 } catch (FileNotFoundException fnfe) {
 emailNotification = new EmailNotification();
 emailNotification.sendEmail(emailToSystemAdmin, "Survey error from : ExportSurveyResponsesTestServicesToExcel.jar", "Environment: " + serverName + " : " + fnfe);

 System.out.println("Oops, FileNotFoundException caught. " + fnfe);
 } catch (Exception e) {
 emailNotification = new EmailNotification();
 emailNotification.sendEmail(emailToSystemAdmin, "Survey error from : ExportSurveyResponsesTestServicesToExcel.jar", "Print Stack Trace " + e);
 } finally {
 try {
 if (rs != null) {
 if (st != null) {
 if (connection != null) {
 } catch (SQLException sx) {
 }//close method


public void sendEmailWithAttachment(String recipients, String subject, String body,String attachmentFileName, HSSFWorkbook hssWorkBook, int totalRows) {

 properties = new Properties();
 properties.put("mail.smtp.host", host);
 properties.put("mail.smtp.port", port);

 if (recipients.equals("") || subject.equals("") || body.equals("") || attachmentFileName.equals("") || hssWorkBook.getBytes().length < 0 ) {
 System.out.println("Usage: sendEmailAttachemt() method parameter might be missing, you may check for the /test/local/surveyToExcel-test.properties for any recent changes");
 Session session = Session.getInstance(properties, null);
 try {
 // create a message
 MimeMessage msg = new MimeMessage(session);
 DataSource ds = null;
 msg.setFrom(new InternetAddress(from));

 ArrayList recipientsArray = new ArrayList();
 StringTokenizer stringTokenizer = new StringTokenizer(recipients, ",");

 while (stringTokenizer.hasMoreTokens()) {
 int sizeTo = recipientsArray.size();
 InternetAddress[] addressTo = new InternetAddress[sizeTo];
 for (int i = 0; i < sizeTo; i++) {
 addressTo[i] = new InternetAddress(recipientsArray.get(i).toString());
 msg.setRecipients(Message.RecipientType.TO, addressTo);

 // Parse a comma-separated list of email addresses. Be strict.
//            msg.setRecipients(Message.RecipientType.CC,
//                    InternetAddress.parse(<a href="mailto:test@aa.test">test@aa.test</a>, true));


 // create and fill the first message part
 MimeBodyPart mimeBodyPart1 = new MimeBodyPart();

 // create the second message part
 MimeBodyPart mimeBodyPart2 = new MimeBodyPart();

 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 byte[] bytes = baos.toByteArray();
 ds = new ByteArrayDataSource(bytes, "application/excel");
 }catch (IOException ioe ){
 this.sendEmail("hobione@hobione.com", "Survey excel file send error", "ByteArrayOutputStream: " + ioe);
 DataHandler dh = new DataHandler(ds);
 mimeBodyPart2.setHeader("Content-Disposition", "attachment;filename="+attachmentFileName+".xls");
 // create the Multipart and add its parts to it
 Multipart multiPart = new MimeMultipart();

 // add the Multipart to the message

 // set the Date: header
 msg.setSentDate(new Date());

 // send the message
 System.out.println("Report emailed successfully to: " + recipients +" Total rows count:" + totalRows);

 }catch (MessagingException mex) {
 Exception ex = null;
 if ((ex = mex.getNextException()) != null) {
 this.sendEmail("hobione@hobion.com", "Survey excel file send error", "Print Stack Trace: " + ex);

January 12, 2011 Posted by | Java | 3 Comments

2010 in blog review

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Wow.

Crunchy numbers

Featured image

The Louvre Museum has 8.5 million visitors per year. This blog was viewed about 93,000 times in 2010. If it were an exhibit at The Louvre Museum, it would take 4 days for that many people to see it.


In 2010, there were 4 new posts, growing the total archive of this blog to 69 posts. There were 17 pictures uploaded, taking up a total of 738kb. That’s about a picture per month.

The busiest day of the year was May 6th with 411 views. The most popular post that day was jQuery-ThickBox (Launch thickbox onload instead of onclick).

Where did they come from?

The top referring sites in 2010 were sitepoint.com, coderanch.com, google.co.in, google.com, and draptik.wordpress.com.

Some visitors came searching, mostly for tb_show, com.sun:tools:jar:1.4.2, thickbox onload, java.lang.classnotfoundexception: org.springframework.web.context.contextloaderlistener, and facesmessage.

Attractions in 2010

These are the posts and pages that got the most views in 2010.


jQuery-ThickBox (Launch thickbox onload instead of onclick) December 2007


RichFaces Tabs: switch dynamically April 2008


Missing com.sun:tools:jar:1.4.2 March 2009


dataTable and radio button in JSF May 2009


JSF: f:selectItem vs. javax.faces.model.SelectItem May 2009
1 comment

January 7, 2011 Posted by | 1 | Leave a comment

Maven Jetty-plugin and IntelliJ IDEA

Scenario: You have a maven project and you want to tie with IntelliJ 9 to make it part of IDE built-in commands instead of using command line interface.

Pre-requisite: Need to read Maven Jetty-Plugin User Guide.

Solution: Here is a skeleton project hierarchy:
You also should have a pom.xml file directly under the project.

Now, open up the IntelliJ. Go to File –> Open Project and choose the pom.xml file to bring the project into Intellij and here how it looks. Notice, Idea has created few extraneous files like .impl, .ipr and .iws.
Project in Intellij

How to configure Run command?
In the IDEA, go to Run –> Edit Configurations
You see the “Run/Debug Configurations” window. Under Parameters tab choose the directory and set the goal command:
Run/Debug Configurations

Under Runner tab, set VM Parameters to these: (You may not need to sett all these)


Runner Tab

Application is ready to run by click the play button.
Play Button
Here is the proof:
Jetty Run

How to configure Build?

It should shows the Build option to the IDEA drop down. Choose the Build option and click the play button.
Build with Play Button

How to configure clean?
Clean Project from target directory

How to configure scm bootstrap?
SCM BootStrap

Here is the final configured list looks like:
Configured List

Hopefully, this post will help me to remember and configure all my future apps with maven jetty-plugin in IntelliJ Idea.

September 22, 2010 Posted by | Maven | Leave a comment

Exadel Tiggr Mockups

I have just started using Exadel Tiggr mockups. It is an online mockup tool, very easy to use and the closest design I can deliver it to the client before develop the product. Components like, text box, table, tabs, panels are very real looking. We are using JSF Richfaces implementations so; it does make sense to use Tiggr during mockups building.
Another cool feature that I love the most; it is a pure online-based tool, which eliminates all download and configurations issues. Tiggr creates shares and collaborate mockups with any number of designers, developers, project manager, scrum master ….. you name it.

Benchstock mockup screenshot

August 25, 2010 Posted by | Mockup | 2 Comments

Spring 3.0 and ROO

Had a great training on Spring 3.0 from Craig Walls.  Here are highlighted topics.

– Wiring
– Testing
– Transactions
– Spring MVC
– RESTful Spring
– Messaging
– RabbitMQ
– Security and
– Spring ROO 1.0

It was good to see ROO (Real Object Oriented) in action, just few commands, created the whole application, entity, controller, wiring and packaged up the application which was ready to deploy. Great tutorial from Ben Alex to build wedding RSVP app using ROO. One simple command created these following basic app hierarchy.

roo> project –topLevelPackage com.hobione.roo

ROO screenshot

May 7, 2010 Posted by | Spring Framework | Leave a comment


I was honored to give a presentation at the University of Central Oklahoma Computer Science department on Java Server Faces. I was invited by Dr. Sung who teaches Java Server Programming and also he is my java guru.  I took my first java class with him 10 years ago (man I am getting old …) while I was finishing up my degree.   Anyway, it was a great experience.  I was little nervous standing front of a class specially front of Dr. Sung and preach about a java framework.  It went really well, I believe.  Dr. Sung and along with students seemed to enjoy the presentations and I was happy to deliver my materials as well.

April 16, 2010 Posted by | Java Server Faces | 1 Comment