Tuesday, March 15, 2011

Sending MimeMultipart emails on Google App Engine

After some trial and error, I found that the example from google (here was not sufficient.
javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Converting attachment data failed)


I then found an example suggesting adding setDispostion on the BodyPart to Part.ATTACHMENT and thought that was a step in the right direction. But still it did not work.

Then as a last resort (and because I noticed they were using a DataHandler import in the example, that they were not using in the code) I tried the ByteArrayDataSource on the data and used setDataHandler instead of setContent and that finally got sending emails with attachments to work on GAE.

Wednesday, August 18, 2010

org.eclipse.swt.SWTError: XPCOM error

I was working in Eclipse Ganymede (on Ubuntu) when a error popped up after I dragged a window to another location. This actually happend because the JavaDoc window became active. As with most errors, I just ignored it. Oops. The next time I tried eclipse with the same workspace, it would not start.

The problem reported in the .metadate/.log file was:

org.eclipse.swt.SWTError: XPCOM error -2147467262
at org.eclipse.swt.browser.Mozilla.error(Mozilla.java:1638)
at org.eclipse.swt.browser.Mozilla.setText(Mozilla.java:1861)
at org.eclipse.swt.browser.Browser.setText(Browser.java:737)
at org.eclipse.jdt.internal.ui.infoviews.JavadocView.doSetInput(JavadocView.java:928)
at org.eclipse.jdt.internal.ui.infoviews.JavadocView.refresh(JavadocView.java:776)
at org.eclipse.jdt.internal.ui.infoviews.JavadocView.setBackground(JavadocView.java:763)

Quickly I entered it in Google and came to the answer.

1) sudo apt-get install xulrunner

2) Append the following line to your eclipse.ini file:
-Dorg.eclipse.swt.browser.XULRunnerPath=/usr/lib/xulrunner

Violla.

It worked.

Monday, October 5, 2009

Type was not serializable and has no concrete serializable subtypes

The internet has really helped to speed up development. I remember when I first started programming and you had to decipher what you had done wrong and wasted hours and sometimes days to figure it out.

Again I came across an error in my GWT RPC application where the message is not exactly clear as to what it is that is not correct.
[ERROR] Type 'a.b.c.client.model.Activity' was not serializable and has no concrete serializable subtypes
[ERROR] Line 30: Failed to resolve 'a.b.c.client.rpc.ActivityService' via deferred binding


Luckily I remember something about a no-argument constructor in my class and that was it. Searching in GOOGLE one also finds the answer immediately.

Monday, August 31, 2009

IllegalStateException: SimplePanel can only contain one child widget

I have been struggling (wasted time) for about a week trying to figure out why my GWT admin application is giving an IllegalStateException. The full error is :
Error: uncaught exception: java.lang.IllegalStateException: SimplePanel can only contain one child widget

The application runs on Google App Engine with Struts 2 and GWT - "Namibia my African Destination".

After doing some research and determining (incorrectly) that the problem was my DecoratorPanel and that I should use the method setWidget and not the add method, I realized that the error was actually not from the DecoratorPanel, but from the FormPanel that I have as a child of the DecoratorPanel.

Both FormPanel and DecoratorPanel comes from the Base class SimplePanel and can only have one child.

Yay, it finally works.

I probably would have known exactly where the problem was, if I was running it in hosted mode.

Tuesday, June 23, 2009

Video file image capture with ffmpeg

In my work yesterday I had to fix a flash preview option for a website I was doing.
(Cant name the site.) The people (pronounced 'poephol' ) were making the web user who visited their site automatic download loads of video content.

This made the client's website a bit slow, and created lots and lots of bandwith consumption. Anyway. They realized their mistake asked me to send thumbnails of the vidoes.

At first I asked the account manager to send me screenshots of the videos. But this was not going to work, as she pasted it into a word document. Then I thought - "There should be an easier way todo this." - and there is.

1) Install ffmpeg
Debian, Ubuntu:
sudo apt-get install ffmpeg

2) Replace the video and image filenames in the command listed below with your video and image and paste into a terminal.

ffmpeg -y -i video.flv -vframes 1 -ss 00:00:05 -an -vcodec png -f rawvideo framepic.png

3) You may have noticed that the "-ss 00:00:05" indicates to capture the image after 5 seconds. You can change this to the frame you want to capture.

4) After creating the PNG, I used the convert function of ImageMagick to make the file a JPG.

Tuesday, June 16, 2009

ImageMagick converts your images from the command line

I am sure there are many image converting programs on the internet and some are probably a lot more user friendly, but I recently used ImageMagick to resize some family photos to send to my family. (I know putting this on Facebook or Picassa would have solved this issue, but not everyone use these as often as email)

As I am sure most users know that image from cameras can be quite big and this tool will convert those images to the size and quality you desire.

All you need todo is install ImageMagick
Debian, ubuntu:
sudo apt-get intstall imagemagick

then run the convert command with your preferences
convert image.jpg -resize 800x600 -quality 70 -interlace PLANE image2.jpg

Violla.

Monday, June 15, 2009

Terminator Terminal

I have been using "terminator" for a while now a find it a very useful tool when monitoring logs on remote servers. Terminator enables you to have several terminal clients open in the same window. Just right click the window and select "split vertical" or "split horizontal" and it splits your window.

Debian, ubuntu:
sudo apt-get install terminator