2009/09/22

java NullPointerException Error

One of my cronjob running error last night, the error message is the following, java.lang.NullPointerException    at UpdtCreatePrdIndex.translateStr(UpdtCreatePrdIndex.java:648)  Trace into the code, the error is in,  private static String translateStr(String trans_str) {        trans_str = trans_str.replaceAll(""","\"");        trans_str = trans_str.replaceAll("®","");        trans_str = trans_str.replaceAll("™","");        return trans_str }  Finally, find out the reason that we updated database table yesterday, and some field has value NULL. When those fields called this method, they failed.  NULL.replaceAll("a", "b") will cause  java.lang.NullPointerException 

2009/09/14

how to ignore dollar sign in the replacement

Found the solution @ http://theserverpages.com/php/manual/en/function.preg-replace.php

If you're setting your replacement values elsewhere and your replacement value can contain a dollar sign followed by an integer eg:

$replacement = 'Dad's $7 shoes'

You'll find that preg_replace() treats this (quite rightly) as callback syntax.

So, you might want to do this:

$replacement = preg_replace("!" . '\x24' . "!" , '\\\$' , $replacement);

To your replacement string first; Putting in an escaped backslash '\\' followed by an escaped dollar sign '\$' where every instance appears.

2009/09/10

install perl module in redhat

Just found it is so easy to install a perl module using cpan in redhat.

login as root, enter the following command:

cpan


This will open a cpan shell and display the following message:

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support enabled


cpan>

The you can install a perl mdule if you know the name,

cpan> install WordPress::Post

The name of perl module is case sensitive, so if you are not sure the name, you can try

cpan> i /wordpress/

It would tell you any module whose name has 'wordpress' in there.

2009/09/08

MySQL Error: Lost connection to MySQL server at 'reading authorization packet', system error: 0

I receive this error today:
MySQL Error: Lost connection to MySQL server at 'reading authorization packet', system error: 0

I found this note below from mysql website: http://dev.mysql.com/doc/refman/5.0/en/error-lost-connection.html
So looks like myserver has the second issue.

There are three likely causes for this error message.

Usually it indicates network connectivity trouble and you should check the condition of your network if this error occurs frequently. If the error message includes “during query,” this is probably the case you are experiencing.

Sometimes the “during query” form happens when millions of rows are being sent as part of one or more queries. If you know that this is happening, you should try increasing net_read_timeout from its default of 30 seconds to 60 seconds or longer, sufficient for the data transfer to complete.

More rarely, it can happen when the client is attempting the initial connection to the server. In this case, if your connect_timeout value is set to only a few seconds, you may be able to resolve the problem by increasing it to ten seconds, perhaps more if you have a very long distance or slow connection. You can determine whether you are experiencing this more uncommon cause by using SHOW GLOBAL STATUS LIKE 'Aborted_connects'. It will increase by one for each initial connection attempt that the server aborts. You may see “reading authorization packet” as part of the error message; if so, that also suggests that this is the solution that you need.

If the cause is none of those just described, you may be experiencing a problem with BLOB values that are larger than max_allowed_packet, which can cause this error with some clients. Sometime you may see “packet too large” as part of the error message, and that confirms that you need to increase max_allowed_packet.

undefined index

$foo = array();

$foo[bar] = 'bad'; //this works but produce undefined index notice.

The reason is that this code has an undefined constant (bar) rather than a string ('bar' - notice the quotes), and PHP may in future define constants which, unfortunately for your code, have the same name. It works because PHP automatically converts a bare string (an unquoted string which does not correspond to any known symbol) into a string which contains the bare string. For instance, if there is no defined constant named bar, then PHP will substitute in the string 'bar' and use that.

-- by http://www.nusphere.com/kb/phpmanual/language.types.array.htm

//So always do:
$foo['bar'] = 'good';
//or
$bar = "bar";
$foo[$bar] = 'good';


There is another case may cause undefined index notice.

$bar = 'myindex';
if (!is_array($foo[$bar])){
   // do something;
}


Because $foo[$bar] is not defined yet, it could not be evaluated by in_array. The correct way is that

$bar = 'myindex';
if (isset($foo[$bar]) &&
!is_array($foo[$bar]) ){
   // do something;
}

2009/09/04

two errors when restart apache

I got two errors when trying to restart apache by command:

/etc/init.d/httpd graceful

1.       Cannot load /etc/httpd/modules/mod_proxy_connect.so into server: /etc/httpd/modules/mod_proxy_connect.so: undefined symbol: ap_proxyerror

Solution: LoadModule proxy_module modules/mod_proxy.so (which was turned off)

2.       Invalid command 'ExtendedStatus', perhaps misspelled or defined by a module not included in the server configuration

Solution: LoadModule status_module modules/mod_status.so (which was turned off)

gtalk windows application does not support non-gmail account

You can sign up Google service using your non-gmail email account, but you can only use gtalk widget if you are using non-gmail account.

 

I also found one interesting thing that if I mouse over my friend, who is logging thru widget with her non-gmail account, in my Google Talk window, I see she is actually using 3ux4794qhrxxx@id.talk.google.com

So looks like when you are using widget with non-gmail account, actually google assign you a special/temporary gtalk account.