LendKey

Wednesday, January 12, 2011

How to synchronize calendar from Lotus Notes to Google Calendar

I have missed several meetings scheduled in Lotus Notes in the past couple of days. Because I was fully relying on my iPhone to remind me of any upcoming meeting, and Notes Calendar's notification doesn't help that much at all.
So with our friend Google.com, I found the following solution, hopfully can make all we poor Notes users' life a bit sweeter:


1. Sync calendar from Notes to Google
Download this nice open source app from:
http://sourceforge.net/projects/lntogoogle/
No install is required (do need .NET framework, which most of PC already have). Once it is started, simply enter your Google account and Notes login info, then pick a calendar you want to sync the data over (recommend to create a new calendar in Google). Then it can either automatically do the sync or let you control manually. Nice!


2. Sync to iPhone
Somehow iPhone only pick one calendar from my Google account by default. Since I created a new calendar to hold the Notes calendar, I need to let iPhone pick more than Calendar. And here's the solution:
Goto https://www.google.com/calendar/iphoneselect
Pick the calendars you want to sync to iPhone and save.
Magically, all the events from my Notes Calendar are in my iPhone now.


3. Reminder
Somehow most of my Notes events don't have a reminder. To let my iPhone remind me, Google allows me to setup a default notification for all event, unless reminder has been explicitly set. So I set my default notification to popup in 10 min, which will let my iPhone popup a little message 10 min before my meetings.


Now my life is back to perfection. Hope the tip helps you too.


Li

Sunday, August 15, 2010

How to monitor Java app started as Windows Service


If you have a Java server running as Windows Service, such as Tomcat, JBoss, etc., it's not possible to run JConsole or JVisualVM to monitor those JVMs, because Windows doesn't allow those apps to see JVM started as Windows Service.

There're two ways I fund over the internet:
1. You can use Sysinternals PsExec.exe to accomplish this.
psexec.exe -i -s c:\visualvm\bin\visualvm.exe


2. Use interactive Windows Service:

1. Install a service using sc.exe - that will open a command prompt under local service account by executing this on cmd window sc create debugservice binpath= "cmd /K start" type= own type= interact 2. sc start debugservice [on a remote desktop session, this service has to be started only in console session for the command prompt window to pop up] will print message that [SC] StartService FAILED 1053: but will start a command prompt under local system account. 3. now navigate to %JAVA_HOME%/bin on the command prompt that got opened and type in jmap -dump:format=b,file=D:\temp\test.hprof  this will dump the heap to D:\temp folder. Be careful dumping heap on a live system as it will lock up the system for the duration of heap dump. 4. similarly jconsole can be started using that command prompt and connecting to the pid of the tomcat. Technical explanation: a. as tomcat service is installed under local system account, jconsole / jmap cannot connect to the service when these are started under the windows logged in user. b. So the command prompt interactive service is installed as a local system service and when that service is started, it opens the command prompt under local system account. c. And hence any process started from that command prompt will be started under local system account and hence be able to access any local system services.

Wednesday, April 21, 2010

Run Terracotta Server as Windows Service

Terracotta is a JVM-level Java clustering solution. Lots of Java frameworks and libraries, such as Ehcache, Quartz, Web Session, have been offering clustered version over this nice platform.

This document describes steps to install Terracotta Server as a Windows Service that can be managed and executed just as any other standard Windows services, including auto startup when Windows is started and management through standard service management UI and command.

Setup Procedure


Preparation

1. Download and install JDK
    Goto http://java.sun.com to download JDK 1.6.
    As of now, JDK 1.6.0_u17 is certified and recommended.
    Install JDK to c:\java\jdk_1.6.0_17

2. Download and install Terracotta
    Open source version can be downloaded from http://www.terracotta.org.
    Enterprise commercial version can be downloaded by contacting sales@terracottatech.com.
    If download is in form of tar.gz file, untar it to c:\terracotta, such as c:\terracotta\terracotta-3.2.1_1.
    If download is in jar form, double click the file to start installation. Follow installation steps to install Terracotta to to c:\terracotta, such as c:\terracotta\terracotta-3.2.1_1.

3. If Terracotta License file is needed, copy it to Terracotta Installation Folder, such as \terracotta\terracotta3.2.1_1.

4. Download Windows Resource Kit Tools
    Go to http://www.microsoft.com to search and download Windows Resource Kit Tools that is suitable to the targeted Windows version.
    Run the installer and install it to the default folder.
    Copy anysrv.exe to c:\terracotta\terracotta-3.2.1_1\bin

5. Make sure sc.exe is included in your Windows installation. Otherwise, download it from Microsoft’s website

Configuration

1. Create tc-config.xml to be used by Terracotta Server, place it to bin folder under Terracotta installation home folder.

2. Create Registration file
    Create a text file with any text editor, copy paste the following text into the file and save it as tcservice.reg.

REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Terracotta\Parameters]
"Application"="\"C:\\Java\\jdk1.6.0_17\\bin\\java.exe\\"
"AppParameters"="-cp c:\\terracotta\\terracotta-3.2.1_1\\lib\\tc.jar -server -Xms4G –Xmx4G -XX:+HeapDumpOnOutOfMemoryError -Dtc.install-root=c:\\terracotta\\terracotta-3.2.1_1 com.tc.server.TCServerMain"
"AppDirectory"="c:\\terracotta\\terracotta-3.2.1_1\\"


Note:
If you need to pass more parameters to TC server, yon can do so by appending them to the AppParameters section. For example, if I want to specify a tc-config.xml and a server name, I can change the AppParameters to:
"AppParameters"="-cp c:\\terracotta\\terracotta-3.2.1_1\\lib\\tc.jar -server -Xms4G –Xmx4G -XX:+HeapDumpOnOutOfMemoryError -Dtc.install-root=c:\\terracotta\\terracotta-3.2.1_1 com.tc.server.TCServerMain -f c:\\terracotta\\my-tc-config.xml -n Server1"


Install Service

1. Create Windows Service
    Open a command prompt window as System Administrator.
    Run the following command:
sc.exe create Terracotta binPath= “c:\terracotta\terracotta-3.2.1_1\bin\srvany.exe” type= own start= auto DisplayName= “Terracotta Server 3.2.1_1”
    It will create a new Windows Service named Terracotta which will be started automatically when Windows is started.

2. Modify service parameter, so it will start Terracotta Server
    In the same command prompt box, run:
regedit tcserver.reg
    It will modify the newly created service to run Terracotta Server as a Java application.

Test

1. In Windows Service Management window, start the service. Make sure there’s no error popped up

2. Run dev-console.bat from Terracotta Installation folder and connect to server_name 9520. Developer’s console should be able to login and display the standard Terracotta management interface.

Trouble Shooting

1. Pay attention to quotation signs and garbage characters when copy&paste code snippet from this article


2. To test run the service manually
Since Windows doesn't provide any console based information when starting service, it could be very difficult to trouble shoot problems.
If your service does not start as expected, it is highly recommended to run the service manually just to make sure everything is configured correctly.
To do so, you can follow the following steps:

  1. Open a Commend Shell
  2. Go to folder defined by AppDirectory
  3. Run the Application with AppParameters
In my example, it will be:

CD c:\terracotta\terracotta-3.2.1_1
C:\Java\jdk1.6.0_17\bin\java.exe -cp c:\terracotta\terracotta-3.2.1_1\lib\tc.jar -server -Xms4G –Xmx4G -XX:+HeapDumpOnOutOfMemoryError -Dtc.install-root=c:\terracotta\terracotta-3.2.1_1 com.tc.server.TCServerMain

Friday, March 26, 2010

Install ColdFusion 8 on Snow Leopard

I need to test something in ColdFusion 8 on my MacBook Pro with Snow Leopard. After I downloaded and unzipped the installer, the installer simply did not run. I double click on the ColdFusion 8 Installer.app from Finder, nothing happened. I guess the Install Anywhere script which was used to create installer for CF 8 might have issue with Snow Leopard.

From internet, there're lots of articles about how run CF8 in Snow Leopard, no one really talked about installation part. Hope I'm not the only one that had this problem.

Anyway, I do managed to find a way to do the installation. Here's what I did:
1. Open a Terminal
2. cd ColdFusion\ 8\ Installer.app
3. cd Contents/Resources/Java
4. java -cp ./IAClasses.zip:Execute.zip:installscript.zip:. com.zerog.ia.installer.Main
5. Follow the steps and I was able to finish setup and run CF8

Cheers!

Li

Monday, November 16, 2009

PHP cannot connect to mysql when run inside Apache

I ran into a very strange issue when Apache/PHP/MySQL.
What happend was my php code suddenly cannot connect to mysql on another machine any more. The error message is:
mysqli_connect() [function.mysqli-connect]: (HY000/2003): Can't connect to MySQL server on '218.241.156.222' (13)
The strange thing was that if I connect mySQL from command line, even run the same code by php directly from command line, it worked just fine.

After searched around, I finally found the answer. Looks like it has something to do with SELinux settings.

To fix the issue, I only need to run:
setsebool httpd_can_network_connect_db 1

Before I ran the script, the file content of /selinux/booleans/httpd_can_network_connect_db was:
0 0

After I ran the script, content changed to:
1 1

Saturday, November 7, 2009

Trick to let iTune handle Chinese song names and tags correctly in Mac OS X

When play Chinese songs in iTune, it always tends to show the song information, such as name, artist, album, etc. as garbage text.

When I was running Mac OSX Tiger and Leopard, the trick I used was to open iTune application information by right-click and choose Get Info.
In the information windows, remove all languages except Chinese. So next time, when iTune is started, it starts in Chinese mode. And it handles all Chinese songs correctly.

In Snow Leopard, the language selection is missing in Get Info dialog. It took me a few weeks to find the new trick.
cd /Applications/iTunes.app/Contents/Resources
mkdir lang_bak
mv *.lproj lang_bak
cp -r lang_bak/zh_CN.lproj .

Then start iTune, you will get it in Chinese mode again and just as the trick before, all Chinese songs are handled correctly.

Hope these tricks can be helpful to Chinese Mac users.

Enjoy!

BTW: If you speak other language and suffers the sames kind of problem, I guess you can try to delete all other languages other than your preference. Hopefully that will work for you too.

Sunday, May 17, 2009

Monitor detailed SQL transactions issued by Hibernate

Hibernate help us translate access to Java objects from HQL to native SQL and automatically take care of object relationships, which saves developers lots of time, but at the same time, hide lots of details, such as how cross table queries are created, how tables are related and, very important, what data parameters are used for each prepared statetment is called.
To show SQL commands generaeted by Hibernate, we can normally use Hibernate config:
true
With this setting, Hibernate dumps all SQL it executed against DB as below:


Hibernate: select device0_.iid as iid1_0_, device0_.iname as iname1_0_, device0_.iip as iip1_0_, device0_.iinfourl as iinfourl1_0_, device0_.istate as istate1_0_, device0_.irecordState as irecordS6_1_0_, device0_.idevlocation as idevloca7_1_0_ from ieai_device device0_ where device0_.iid=?


However, if you want to see what exact value is passed into the SQL statement, and further more, what result was returned from the SQL command, we need to do more.
Basically we need to set log4j settings of the follow two Hibernate classes into DEBUG:

org.hibernate.SQL
org.hibernate.Type


So the log4j.properties file will have the following settings:

log4j.logger.org.hibernate.SQL=DEBUG,console
log4j.logger.org.hibernate.type=DEBUG,console


Then Hibernate will dump debug information as below:

76033 [DEBUG] AbstractBatcher.log(): - select device0_.iid as iid1_0_, device0_.iname as iname1_0_, device0_.iip as iip1_0_, device0_.iinfourl as iinfourl1_0_, device0_.istate as istate1_0_, device0_.irecordState as irecordS6_1_0_, device0_.idevlocation as idevloca7_1_0_ from ieai_device device0_ where device0_.iid=?
Hibernate: select device0_.iid as iid1_0_, device0_.iname as iname1_0_, device0_.iip as iip1_0_, device0_.iinfourl as iinfourl1_0_, device0_.istate as istate1_0_, device0_.irecordState as irecordS6_1_0_, device0_.idevlocation as idevloca7_1_0_ from ieai_device device0_ where device0_.iid=?
76033 [DEBUG] NullableType.nullSafeSet(): - binding '3' to parameter: 1
76043 [DEBUG] NullableType.nullSafeGet(): - returning 'Device3' as column: iname1_0_
76044 [DEBUG] NullableType.nullSafeGet(): - returning '192.168.0.12' as column: iip1_0_
76044 [DEBUG] NullableType.nullSafeGet(): - returning 'http://www.infolexllc.com/site/' as column: iinfourl1_0_
76047 [DEBUG] NullableType.nullSafeGet(): - returning '1' as column: istate1_0_
76047 [DEBUG] NullableType.nullSafeGet(): - returning '2' as column: irecordS6_1_0_
76048 [DEBUG] NullableType.nullSafeGet(): - returning 'test device location' as column: idevloca7_1_0_


If you are a newbie in Hibernate, you will be amazed to see what is going on underneath by Hibernate, either in a positive and encouraging way or a very bad negative way.

Cheers!