Monday, January 9, 2012

HTC Incredible S Android Update - SMS/Messages Problem

This morning I got a notification on my phone to upgrade to Android Version 2.3.5 and the new version of HTC Sense (3.0). That's great - and I'm really happy with the upgrade.

However, one annoying side-effect for me is I immediately started receiving SMS notifications which were blank (or just said "SMS message") and displayed the location I was in (for example my suburb or nearby suburbs). Each message came with the option to "save" or "cancel". If I selected 'cancel' it would just go away. If I select save, it appears in my text messages coming from the sender '50'.

The annoying part is that these messages just kept coming. As I move my phone around the house it would every minute or so get messages from the sender "50" and give me an annoying notification that I had to respond to.

It turns out that these messages appear to be "Cell Broadcast" messages. The cell broadcast forum states that:

Cell Broadcast (CB) is a mobile technology that allows messages (currently of up to 15 pages of up to 93 characters) to be broadcast to all mobile handsets and similar devices within a designated geographical area. The broadcast range can be varied, from a single cell to the entire network.

There's more information about it at Wikipedia - Cell Broadcast.

In any case, it seems that the update to Android 2.3.5 and HTC Sense 3.0 on the HTC phone has caused it to start notifying me of each Cell Broadcast messages coming from channel 50. (Presuming they didn't just start broadcasting in my area this morning at the exact time I did my update, at least!)

Solution: I decided I would leave Cell Broadcasts generally enabled on the phone, but simply disable this channel.

To do this, you go to Settings on your Android phone. Then select Call. In this menu you have the option to enable or disable "Cell broadcast". I left it enabled and clicked on the "Cell broadcast settings" option, further down the list. Here I found the broadcast channel causing the problems (50) and clicked on it to select "disable".

This fixed the problem and my phone is back to its normal, quiet self! I guess I could have disabled "Cell Broadcast" entirely, but, who knows? One day there may be a flood coming to my area and I'll be glad I left it on!

I couldn't find anything about this specific issue on the internet, so thought I'd record this for others who experience the same problem. I'd be interested in comments if others know more about this and there is a better way to handle it. Was it just me, or are others are also experiencing this problem?

Thursday, January 28, 2010

Problems with Unit Testing using GWTTestCase and GWT FlexTable()

I'm currently writing a web-application using Google Web Toolkit (GWT). To provide test-coverage for the app, I'm writing client-side unit tests that extend GWTTestCase.

Recently I found that some (previously passing) tests were failing. They threw a JavaScript Exception ( (null) null):

java.lang.RuntimeException: Remote test failed at / Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2008070208 Firefox/3.0.1
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(
at junit.framework.TestSuite.runTest(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Caused by: (null): null

The tests were failing on a GWT constructor call designed to create a new FlexTable:

FlexTable flexTable = new FlexTable();

Confused about what could be going on, I created a simple test which just called this constructor and found that it failed:

package test.client;



public class FlexTableTest extends GWTTestCase {

public void testFlexTable() {

FlexTable flexTable = new FlexTable();



public String getModuleName() {

return "test.FlexTableTester";



So - I created a completely new Project package from scratch and then found it passed just fine.

So - what was going on? Well it turns it was to do with my "myProject.gwt.xml" file. It seems that when you run the GWT tests using GWTTestCase, the code is compiled and run on a virtual browser - that may be different from the actual browser you're using to run the application in for manual testing or acceptance tests. Obvious, in retrospect!

Now, in my project, I had decided that since I was only running the application (and Selenium acceptance tests) in Internet Explorer browsers, I could save GWT compile time by only compiling one permutation of the GWT options - that for Internet Explorer.

To do this, I had introduced the following line of code into my "myProject.gwt.xml" file:

<set-property name="user.agent" value="ie6"/>

This code tells GWT to only compile one permutation - for Internet Explorer. However, it seems that the "virtual browser" used by GWTTestCase is not InternetExplorer (or at least not fully compatible with ie6 mode).

Having this property set to a particular browser (IE6) led to the problems I was having with my tests.

All I had to do was remove the <set-poroperty name="user.agent" value="ie6"/> tag and the tests worked perfectly.

Sunday, January 24, 2010

Selenium Testing GWT - upgrading to GWT 2.0 and Selenium 2.0a1

Recently, I'd written some acceptance tests for a Google Web Toolkit (GWT) based Web Application using SeleniumRC v1.0.1.

I was using GWT 1.7.1 and the tests were all working nicely. I had a Tree in the WebApp and was using GWT TreeItem elements for the nodes in this tree. I was also using GWT drag and drop ( to help with selecting and dragging TreeItems.

Over the last week I decided to upgrade the version of GWT from 1.7.1 to 2.0. As a result a bunch of Selenium functionality started failing. This included:
  • method ceased to properly select a GWT TreeItem. A manual click will make the TreeItem go blue (ie. look selected and have "gwt-TreeItem-selected" class attribute in the DOM), but the selenium test doesn't.
  • Selenium.type("//*[@contentEditable='true']", newText) method ceased to properly enter text into an editable IFrame element.
  • Multiple Selection (via Drag and Drop GWT) failed to show visibly what was selected.
After trying a bunch of things, I came to the conclusion that there is significant Selenium functionality that worked correctly when testing GWT 1.7.1 web-apps that no longer works with GWT 2.0.

A simple example was the following code (which I asked about on StackOverflow) which tests the online GWT web-page demo for TreeItems and should click() on a treeItem. However, it doesn't produce the same functionality as a manual mouse-click:
package test;

import org.junit.Before;
import org.junit.Test;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class TestTreeClick {
static Selenium selenium = null;

public void setUp() throws Exception {
if (selenium == null) {
= new DefaultSelenium("localhost", 4444, "*iexplore",

public void testingClicking() {
To try and alleviate this problem, I upgraded my selenium .jar file to the latest WebDriver backed Selenium (selenium-2.0a.1.jar) found at However, simply upgrading the .jar file and leaving the code the same doesn't actually use the WebDriver-backed Selenium compoments. To do this, I needed to modify the start-up code to be:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;

import com.thoughtworks.selenium.Selenium;

public class TestTreeClick {

public static void main(String[] args) {
WebDriver driver = new InternetExplorerDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, "");
I found that the new Web-Driver backed Selenium does fix a number of the problems I'd found (or provides alternative ways to achieve functionality) - but not easily in a single step. However, it was good to find that for the click() example above, the new code works correctly with GWT 2.0, where as the old code does not.

However, at the moment (Jan 2010) this doesn't provide a really simple solution to my testing problems. Currently Web-Driver backed Selenium (Selenium 2.0a.1) does NOT provide a full set of testing functionality as found in earlier versions of standard Selenium. Some selenium methods that work in earlier versions have slightly different commands to make them work in the new version. Of the limitations/issues I've had, the key one is that Web-Driver backed Selenium does not currently provide support for right-click (context menu), and Ctrl-Click functionality.

In addition there are a number of minor changes to make things work. For instance, typing into an editable iFrame didn't seem to work using our old code:
  • Selenium.type("//*[@contentEditable='true']", newText)
Instead, we now have to use:
  • selenium.typeKeys(elementId, newText);
In summary, if I were to stop using the Web-Driver backed Selenium, the available test functionality is more complete, but unfortunately key bits I wish to test just don't work with GWT 2.0 code. I don't want to go back to GWT 1.7, so for the time being I'm developing my application without the ability to test Right-Clicks and having to re-write bits of the test code to work properly.

It isn't a huge deal, as I should have almost all of my right-click functionality in other menus, anyway - and hopefully the main testing comes from Unit tests and Integration tests. Nevertheless, just wanted to record these experiences here in case they help others understand what's going on when they upgrade - and what the impacts might be on Selenium tests.

Wednesday, October 7, 2009

Selenium Testing page with iframe/GWT RichTextArea

Recently we've been using Selenium to do integration/acceptance testing of a new web-application.

The web-application uses Google Web Toolkit (GWT) for the view layer. One of the key components is a GWT RichTextArea for user input. GWT RichTextAreas are implemented in Javascript using an iframe with designMode=On, to allow user input.

This works fine, however when we came to testing we couldn't seem to get Selenium to input text into the RichTextArea (iframe) component.

A number of websites (for example suggested something like "select the right frame with Selenium's selectFrame, type text to //html/body and finally select the top frame again."

However, this didn't work for us. We tried a combination of options for selecting the frame and then trying to select the body (or other elements) within the iframe, but all to no avail.

In the end, we didn't need to select the iframe/richtextarea separately first (and, indeed, this selecting didn't seem to work, even though the GWT "ensureDebugId" did correctly attach the id to the iframe element).

The final solution to get selenium to type into the RichTextArea was to include in our tests the code:

selenium.type("//*[@contentEditable='true'","This text is to be typed");

The first argument of the selenium.type command is a locator that finds the correct iframe (RichTextArea) element, based on the fact that GWT creates this element with a parameter indicating the content is editable. The second command is the text you want typed in your test.

Seems so simple here, but getting that to work took hours! We tried a bunch of much more "obvious" options to locate that element (including a bunch that other bloggers said worked), but in our case this was the only thing that we could find that did the job!!

So... now ya know what worked for us, too!

Tuesday, May 19, 2009

"java.sql.SQLException: Communication link failure" when using Hibernate, Tomcat and MySQL with Spring

I have recently obtained an error after leaving my Hibernate/Tomcat/MySQL web-application running overnight (>8 hours) with the following root-cause :

Root Cause: java.sql.SQLException: Communication link failure:, underlying cause: Software caused connection abort: recv failed

Situation: When first deployed the application works fine. However, when the application is left running for a long time (eg > 8 hours) without any interactions, the connection to the MySQL database is lost and the web-app throws an exception. The full stacktrace of that exception is below, for those interested. I am using Tomcat 6.0.18 and MySQL 5.0.27-community-nt.

Aside: It is perhaps also worth noting that another computer with the same code-base does NOT throw this error - even though the MySQL time-out settings are the same. The main difference appears to be that the other computer is running Tomcat 6.0.14 and MySQL 5.0.18-nt so it is possible that these versions don't require the fix below - but I haven't confirmed that it isn't some other minor difference.


This is a fairly common problem, but a range of solutions presented elsewhere on the internet didn't fix my problem - and they aren't documented together anywhere I could find - so I'm recording some of these here, along with the one that finally worked for me.

How to test:

The first thing to note is that this is caused by MySQL closing down connections that are idle for a period of time. One fix is to just drastically increase the "Interactive timeout" and "Wait timeout" in the my.ini file that is read on startup in MySQL. Don't forget to restart MySQL each time you change these (and to stop Tomcat before restarting MySQL). A good way to test if this timeout is really your problem is to change these to a short value (eg 40) (that is, 40 seconds) and wait to see if the error occurs in a minute or so. That way you don't have to wait overnight to test whether changes fix your problem.

Proposed Solutions:

NB: Only one of these worked (or was deemed "acceptable") for my case - and that one is the last one, but I record them all here as I couldn't find one location with all these summarized.

1. One solution is to just increase the MySQL Timeout settings as described in the "testing" section above. However, while this fixed one application I was working on, in one (different) case I found that the error was occurring overnight even if I set this to a very large value (eg 604800 sec). In any case, just increasing this value isn't a great solution as you don't want the error to occur ever - so just stalling it for a week isn't great!

2. Another solution that I didn't like, but should mention, is to put a try/catch around the Java code that accesses the database. This isn't really a hibernate solution, but I thought I'd mention it. See the suggestions at the following URL if you want to try this. It's inelegant if you're using Hibernate, but might be good if you are doing your connections manually.,55337,139123#msg-139123

3. Another suggestion that I found on the web that didn't work - but might for similar problems - is to put the following into your hibernate config file:

<property name="connection.autoReconnect">true</property>
<property name="connection.autoReconnectForPools">true</property>
<property name="">true</property>

4. A related suggestion is to add autoReconnect=true to jdbc URL. I did try this and it didn't work for me, but it might be worth considering.

5. Another suggestion was to set the C3P0 connection-pooling properties as follows:
<property name=“hibernate.c3p0.acquire_increment">3</property>
<property name=“hibernate.c3p0.idle_test_period">14400</property>
<property name=“hibernate.c3p0.timeout">25200</property>
<property name=“hibernate.c3p0.max_size">15</property>
<property name=“hibernate.c3p0.min_size">3</property>
<property name=“hibernate.c3p0.max_statements">0</property>
<property name=“hibernate.c3p0.preferredTestQuery">select 1</property>

See for more details on C3PO config. This would set C3PO pooling values in the configuration - in particular setting the idle_test_period and timeout properties to be less than the values set for MySQL timeout (see 1 - I had the MySQL timeout set to 691200, so it was much longer). In fact, even before experiencing this problem I did actually already have these values set and yet the error still occurred! Still, this may be necessary /fix the problem for some people and I am still using these settings, above.

Aside: A similar set of properties for dbcp is given at

6. Solution (Actually worked for me): The final change that actually worked was to modify the Spring data-source to be:

<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" abstract="false"
lazy-init="default" autowire="default" dependency-check="default"
<property name="driverClass"> <value>com.mysql.jdbc.Driver</value> </property>
<property name="jdbcUrl"><value>jdbc:mysql://localhost/myApp</value></property>
<property name="user"> <value>myUser</value></property>
<property name="password"><value>myPassword</value></property>
<property name="autoCommitOnClose"> <value>true</value></property>
<property name="idleConnectionTestPeriod"><value>15</value> </property>
<property name="maxIdleTime"> <value>15</value> </property>

The key properties here are to set the idleConnectionTestPeriod and maxIdleTime to values that are less than the mySQL timeout values mentioned in (1) above. Setting these two new properties for the datasource in applicationContext-jdbc.xml file in my Spring config settings fixed the problem.

More StackTrace Info for Error:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin failed:

root cause:

java.sql.SQLException: Communication link failure:, underlying cause: Software caused connection abort: recv failed** BEGIN NESTED EXCEPTION ** Software caused connection abort: recv Software caused connection abort: recv failed at Method) at Source) at com.mysql.jdbc.MysqlIO.readFully( at com.mysql.jdbc.MysqlIO.reuseAndReadPacket( at com.mysql.jdbc.MysqlIO.checkErrorPacket( at com.mysql.jdbc.MysqlIO.sendCommand( at com.mysql.jdbc.MysqlIO.sqlQueryDirect( at com.mysql.jdbc.MysqlIO.sqlQuery( at com.mysql.jdbc.Connection.execSQL( at com.mysql.jdbc.Connection.execSQL( at com.mysql.jdbc.Connection.execSQL( at com.mysql.jdbc.Connection.setAutoCommit( at com.mchange.v2.c3p0.impl.NewProxyConnection.setAutoCommit( at org.hibernate.transaction.JDBCTransaction.begin( at org.hibernate.impl.SessionImpl.beginTransaction( at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin( at at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary( at org.springframework.transaction.interceptor.TransactionInterceptor.invoke( at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed( at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(

Wednesday, April 22, 2009

java.lang.UnsupportedClassVersionError: Bad version number in .class file

I was recently deploying a webApp in Eclipse (MyEclipse) using Tomcat when suddenly I got a UnsupportedClassVersionError:

java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(
at org.apache.catalina.loader.WebappClassLoader.findClass(
at org.apache.catalina.loader.WebappClassLoader.loadClass(
at org.apache.catalina.loader.WebappClassLoader.loadClass(
at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(
at org.apache.catalina.startup.ContextConfig.start(
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
at org.apache.catalina.core.StandardContext.start(
at org.apache.catalina.core.ContainerBase.addChildInternal(
at org.apache.catalina.core.ContainerBase.addChild(
at org.apache.catalina.core.StandardHost.addChild(
at org.apache.catalina.startup.HostConfig.deployDirectory(
at org.apache.catalina.startup.HostConfig.deployDirectories(
at org.apache.catalina.startup.HostConfig.deployApps(
at org.apache.catalina.startup.HostConfig.start(
at org.apache.catalina.startup.HostConfig.lifecycleEvent(
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
at org.apache.catalina.core.ContainerBase.start(
at org.apache.catalina.core.StandardHost.start(
at org.apache.catalina.core.ContainerBase.start(
at org.apache.catalina.core.StandardEngine.start(
at org.apache.catalina.core.StandardService.start(
at org.apache.catalina.core.StandardServer.start(
at org.apache.catalina.startup.Catalina.start(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(
at org.apache.catalina.startup.Bootstrap.main(

So my initial thought was "ok, a class is not loaded, but which one???".

Well - it turns out that this information would probably have led me down the wrong path anyway... and you don't need it (so don't get frustrated with whoever created that error message!).

The problem occurs, generally, when you compile a .java file with one version of JDK and then run the (compiled) .class with a different version of the Java Virtual Machine.

So... how was I doing this? Well - the .class file is being run within Tomcat and the .java file is being compiled by the preferred java compiler set in myEclipse. Ideally, these two versions would be the same - however they can be quite different. This won't be a problem AS LONG AS the Tomcat Java version (ie the Java running the .class files) is not an older version than the Java version used to compile the .class file from .java. It turns out that I had accidently set the Tomcat Java version to be an older one than the JAVA version being used to compile the code.

In MyEclipse:

Tomcat Java Version is set by:

  • MyEclipse Tomcat[*] -> Configure -> Jdk -> Tomcat JDK Name

MyEclipse Compiler Java Version is set by:

  • Project-> Properties -> Java Compiler -> Compiler Compliance Level
  • Window -> Preferences -> Java -> Installed JREs -> Selected JRE

So, all I had to do to fix this was to set both the Tomcat JDK Name and Selected JRE to jre1.6.0_05 and compiler compliance to 1.6 and I'd fixed the problem.

[*] or whichever Tomcat you are using...

Tuesday, February 17, 2009

YouTube - JavaScript Turned off or an old version of Adobe Flash Player - Bug

Earlier today I was sent a link for a YouTube video, however when I went to the link I received the error message:

"Hello, you either have JavaScript turned off or an old version of Adobe's Flash Player. Get the latest Flash player. "

I have the latest Flash player (and, indeed, did follow the link and upgrade it just to make sure). However, this kept occurring for a number of YouTube videoes I then tried to watch as a test.

A bit of investigation indicated a huge range of suggestions for how to fix this - everything from people claiming it is a bug with YouTube and "YouTube Engineers are working on it" through to those advising turning off various bits of your Internet Explorer security settings (such as any "Add blockers" etc) and deleting temporary internet files and cookies.

Given that these fixes didn't work for me - and I don't want to leave my browser in an unsafe state with popups etc, anyway - I changed all these settings back to their usual state.

SOLUTION (Well, almost!):

I did, however, come up with a way to watch the video.

Now, to be honest, I haven't actually fixed the problem - when I go to the original URL I get the same error message still - but, on the positive side, I can watch the YouTube video (which, after all was the point). To do this, you just need to modify the URL you are using slightly.

In this particular case (as embarrassing as this may be - I didn't choose this video), my friend wanted me to view the link:

This didn't (and still doesn't at the moment of writing this) work for me. However, if you modify the link to:
  • remove the words "watch?"
  • replace "=" with "/"

I obtain a new URL that does work:

So, the good news is this worked. The bad news is that had I known what the link was for I wouldn't have wasted the time :-) Ok - so maybe it isn't that bad?!?

Anyway, music taste aside, the good news is that this works on all the YouTube files I've tried so far. They're all giving me this same error message but, if I really wanted to, I could watch them by changing the URL manually...

So... it isn't a long term fix - but maybe this is a good start for others if the problem is with something at YouTube's end, or if you're just in a real hurry to watch that link you've been sent and don't wanna spend days re-installing Adobe products and Virus scanners!!!