Category: Bugs and Problems

I’ve been a heavy user of simpleDB  from past couple of months, here’s my advise to people working with date in simpleDB ::

As we all know that everything in simpleDB is a String, hence ALWAYS use a single time zone while storing dates, otherwise results might be error prone  as sorting is lexicographical. I’ll recommend Joda-Time(ISO8601 format) to store dates as it provides a quality replacement for the Java date and time classes with simple API. Preferably use Zulu time zone (i.e. GMT)

Here’s how to do it ::

DateTime date = new DateTime(DateTimeZone.forID("Etc/Zulu"));

While using date in your application return time in milliseconds as it is easier to use.The code below expresses the datetime as milliseconds from 1970-01-01T00:00:00Z

String time = message.getDate();
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
DateTime dt = fmt.parseDateTime(time);
time = Long.toString(dt.getMillis());

For my app, i’m storing data in Amazon SimpleDB, but since SimpleDB has a 1024 character per attribute maximum so larger values should be stored in S3.

I’ve a class named Details which can store MultipartFile as private byte[] multimedia ,which is to be stored in S3. This is how to do it




private byte[] 	multimedia;

The @Lob annotation specify that the  field should be persisted as a large object

Because the @Lob annotation is really just qualifying the basic mapping, it can also be accompanied by a @Column annotation when the name of the LOB column needs to be overridden from the assumed default name.

I have also marked this field to be loaded lazily, a common practice applied to LOBs that do not get referenced often.

Now simply convert your MultipartFile multimedia to a byte array as

byte[] mediaBytes = multimedia.getBytes();

and set this property in your object and persist it in SimpleDB. The MultipartFile will get stored in S3 with Lob-key in SimpleDB.

But if there is a chance of duplicate data, you should do this  using calls to S3 rather than using @Lob annotation in order to reduce redundancy and get more control.

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. These properties make JSON an ideal data-interchange language. While working in java, i found Google-gson library to be very useful .

From the official site:

Gson is a Java library that can be used to convert Java Objects into their JSON representation.It can also be used to convert a JSON string to an equivalent Java object. Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of. There are a few open-source projects that can convert Java objects to JSON. However, most of them require that you place Java annotations in your classes something that you can not do if you do not have access to the source-code. Most also do not fully support the use of Java Generics. Gson considers both of these as very important design goals.

During my project i was having trouble converting list of json objects into list of corresponding java objects. This is how i finally did it :


String json1 = "[{\"contactName\":\"3\",\"contactNumber\":\"3\"},{\"contactName\":\"4\",\"contactNumber\":\"4\"}]";

JsonElement json = new JsonParser().parse(json1);

JsonArray array= json.getAsJsonArray();

Iterator iterator = array.iterator();

List<ContactDetail> details = new ArrayList<ContactDetail>();

    JsonElement json2 = (JsonElement);
    Gson gson = new Gson();
    ContactDetail contact = gson.fromJson(json2, ContactDetail.class);
    //can set some values in contact, if required 

Here ContactDetail class consists of String contactName and String contactNumber and their corresponding getters and setters.

Do leave a comment, in case there is any better way to do this. 🙂

As suggested by Gobs in the comments, another way to do it is

Gson gson = new Gson();
Type collectionType = new TypeToken<List<ContactDetail>>(){}.getType();
List<ContactDetail> details = gson.fromJson(json1, collectionType);

But I did it the other way coz I also wanted to set some values in that object.


When your VMware Player crashes unexpectedly upon start (i.e. GUI opens up for 1-2 seconds and then disappears), fear not.Fix is very simple  ::

#cd /usr/lib/vmware/lib
#sudo mv

That’s it !!! 🙂

That worked for me. If that does not work either…try this

#vmware-modconfig --console --install-all
#mv /usr/lib/vmware/resources/mozilla-root-certs.crt 

"certificate" crash is due to "curl" package which don't support ssl or c-ares
credits ::

Installed nvidia drivers using #yum install kmod-nvidia only to find out a blank screen with blinking cursor on reboot.This problem is due to Nouveau driver taking control of the graphic card at an earlier point in the boot procedure.To fix this problem you should make sure that nvidia proprietary drivers are used rather than nouveau driver provided by default in Fedora 11+.

Follow the steps to fix this problem, before installing nvidia drivers  ::

#vi /etc/modprobe.d/blacklist.conf

and append the following line in the bottom — “blacklist nouveau

now open grub.conf file

#vi /etc/grub.conf

and add this to end of lines starting with word kernel — “nouveau.modeset=0 vga=0x318

now perform

#yum install kmod-nvidia

If you are stuck at blank screen on reboot go for alt+ctrl+f1 and follow the first two steps.

Damn there is a red X over my speaker icon saying “no audio output device is installed”.No sound means No music and hence fixing this problem was my highest priority.Little bit of googling and guess what i found out !!! I was not alone.The two most common solutions were updating the device driver and checking for muted speakers.Unfortunately i was not among those commoners. Infact my situation was even worse, there was no sound even in my fedora 12.But this made one thing clear,the problem was either with some hardware or some configuration problem of bios. I googled for combo of no audio output and bios and found out that this problem can also occur due to disabling of on board sound in BIOS. I opened the bios and reset everything to default, restarted the system and problem was solved.