Wednesday, April 29, 2009

How to Deploy a GWT Application to Tomcat?

Intro
OK, so you have tried the GWT (Google Web Toolkit), decided that it's cool, and you created your first application, precisely a module. You have tried it locally on your development machine, using the hosted mode and, may be, in the web mode by using the Compile/Browse button on the hosted-mode preview window. Now, you can either deploy it to Google App Engine, which is a way to try it online free and easily (make sure that your app doesn't become the IP of Google! I haven't looked at the terms of use myself.) or you decide yo want to go for it, and publish it for real. You purchase a Java hosting plan (google for it; you can find some within $12/mo.), and you're ready to deploy your application to your Tomcat server.

Deploying It
I used this re
source to help me with. Basically, follow the steps ( is the root of your GWT application,):
  • create a staging folder (let's call it deploy)
  • copy contents of /www/com.meography.EntryScreen into /deploy
  • create /WEB-INF with folders classes and lib in it
  • create web.xml file in WEB-INF. See the above resource for how to.
  • copy contents of /bin folder to deploy/WEB-INF/classes
  • copy all needed jars into deploy/WEB-INF/lib (you don't need gwt-user.jar nor gwt-dev-windows.jar, though)
  • compress all of the conents of deploy folder into a zip file and rename the file to .war.
  • upload the file to Tomcat, which can be done via browser using Tomcat manager, which is usually already installed for you by your Java hosting vendor. Once the upload finishes, the manager will show your application with options to Start, Stop, Reload and Undeploy it. The name of the app, is the base URL for your app.
Point your browser to the main .html file of the module (URL indicated by Tomcat manager + YourMainScreen.html). And, voila, you should be on. Well, if there are any problems, for example with your database setup, you'll find errors in the catalina.log file in the /tomcat/logs folder on your production server.

Re-Deploying It
To redeploy, after you have done some changes, simply repeat the steps above, but remember to preserve files you had to tweak or create for your production environment like web.xml and possibly hibernate.cfg.xml, if you happen to use Hibernate and use different database on your development machine and on your production server (Java hosting plan will usually have MySQL and PostgreSQL databases included). And, one more thing. I have found that I have to do Undeploy, upload the new .war file and then Deploy for the changes to post correctly. The reason may be, that GWT application is compiled into JavaScript cache files with random names, so the file names will be different each time you compile it, and so, just copying the new .war file over will not replace all of the old files.

Any feedback? Feel free to let me know.

Thursday, April 23, 2009

Developing for Android Platform

Why Android?
I'm a Java developer. Yes, I could enhance my C/C++ skills, get an iPhone and develop for the iDevices. But, I guess, I wasn't motivated enough. Also, I'm a strong supported of open source development. So, first, I noticed OpenMoko platform. But their development slowed down and stopped. Never got to the point when I'd be able to get a phone and develop for it. Finally, I noticed the Google's Android initiative in late 2007. Yes, I'm afraid of humongous corporations like Micstosoft and now Google. Still, I didn't see a more attractive choice. So, I waited for Google to release the Android phone. I could switch to Windows Mobile platform, but this, somehow, didn't attract me. Finally, in Jan 2009, after living with Palm for good 7 years, and I'm a heavy user of the personal organizers (several years ago, I'd create my own notebooks/calendars, so they'd fit my needs; out of paper and cardboard; I did this for good 2-3 years), finally in Jan 2009, I decided it was time to do the move and I purchased a black G1 (for the picture and a story of my other organizers, see this blog).

Does It Fulfill The Promise?
In short, yes. Is it perfect? No. I can suggest several improvements of the top of my head, even just for hardware. And for software, too, of course. Would I recommend it? Definitely. Does it have a potential? Oh, yes, sure. This section could be a topic on its own, but, it will have to wait for another time. Let's move.

So, to Cut To The Chase, How Do I Develop for Android
Simple. The list of tools I use:
  • Eclipse (3.4.2)
  • JDK (1.6)
  • ADT (0.8.0) - great tool. Can even deploy to the device over USB and monitor the app.
  • Positron aka Autoandroid - for integration testing. Unit testing doesn't work that great for fat clients. This is a great tool except for a few hick-ups.
  • jUnit - for the pieces that can be unit testing without reaching to your left year with your right foot.
Do you want more details, technical details? Sure. Here they're:

Where can I find some sample Android applications?
Well, one good sample is the Android platform itself. For example, to see the source code for the native Android calendar application, you can view it here.

Deploying onto the Device:
  • an unsigned .apk file installs with a "Application installation unsuccessful"
  • log a application crash,,, where can I find it? The ADT displays LogCat.

Using Positron aka Autoandroid:
  • If getting an error about Autoandroid "java.net.SocketException: Connection reset" problem, either:
    • rerun the Android Application and run stories again or
    • application crashed on Android
  • If you get error "Internal Error ... ShouldNotReachHere", do
    • go to the jUnit relevant run configuration, //Classpath// and remove the Android Library from Bootstrap.
    • do //Advanced//, //Add Library// and choose JRE System Library
    • add JUnit library the same way

Tuesday, February 3, 2009

To Refinance or Not To Refinance

OK. Mortgage interest rates are falling. Everyone is refinancing or at least trying to do it to benefit from the lower rates. So, I did a research myself as well. There were three distinct ways to do it. I'm describing them below.

No-Cost Refinancing Offer From My Current Mortgage Bank
The WaMu offered to reduce my mortgage by 0.25%, for no cost. The savings looked fabulous (down to $500's from almost $1200 a month), but after I looked at it carefully, it was primarily because they calculated as if for a new 15-years loan, while on my current loan I have only 10 years left. The actual savings would be only about $40 a month.

Best Deal I Was Able To Find on The Internet
I did a search for the best rates. The website (don't remember which one), took me into a lender search instead of giving me a rate. When I clicked the button that said Get Your Rate, I've got a list of lenders instead, and after 5 minutes (yes! even though it was Saturday night, around 8pm), my phone rang and one of the lenders from the list wanted to talk to me. So, in a way it worked smoothly. The thing is, that the best deal the lender had was a rate lower by 0.75% for a closing cost of some $4500. And, no, it wasn't because of my credit score. Mine is over 800, and it was him who checked and told me the score.

ING Direct EasyOrange Refinancing Deal
This deal is about a 5 year loan based on a 30-year period. So, I'd have to payback the whole loan after 5 years. But that wouldn't be a problem in our situation. Anyway, they're giving a rate of 4.75%, which is pretty good right now, for closing costs of $1750 only. Seemed a great deal. Just to make sure it makes even sense to refinance if we don't plan to live in this house more than 2-3 years, I went to timevalue.com website and compared my current mortgage with th EasyOrange deal. The image below shows the results:

It seems after all, that the EasyOrange doesn't save as any money after all.

That was it. I guess, the no-cost 0.25% is the best deal after all. But it will lock me for a year at least. What is rates go down a lot within months?

Tuesday, January 20, 2009

Brief Visual History of PDA's

Today, I had to stay home and take care of our youngest one for a couple of hours. He was very busy playing out the story of Joseph being almost killed and then sold by his loving brothers, that I decided to do some cleanup. Since my G1 phone is more or less setup, I decided to trash the older PDA I used to use and which I still kept in my drawer. I had a moment of nostalgia and so I ended up saving for some of my memories for the generations to come.

Most of my adventure with PDA's is captured by the following picture:


I have been using all these PDA's, including Treo 90, the most fun one, in addition to the cell phone. Finally, with G1, I have one device instead of two. I didn't stress it: I was actually carrying the two devices always with me, wherever I went. One in my pocket and another in a little holster. I got rid of the holster now, which made my wife happy. She never liked this extra decoration. And, besides the two functions being one fullfilled by a single gadget, I must say I enjoy the G1 a lot. It's appearance doesn't give it justice. Really.

There is much more to say about this little brief history topic, but my time is limited while I want to have some left to play with extending WikiNotes app into a more fully developed wiki application. Yes, for G1, or I should rather say, for Android.

Friday, January 2, 2009

Search Web Services or API for Commercial Use

Suppose, you need to collect some data based on Internet search for your business. What options are there to use existing web search services? Google? Yahoo? Anyone else? Here's what I have found.

Google
Here's what I have found:

  • Google SOAP search web services seem not to be available for new applications any more. In 2006, Google seems to have stopped issuing new API keys.
  • There is another option from Google: API not SOAP based. The terms don't exclude commercial use, but there is a restriction on caching the results of the search. I guess, if we process the results and store the processed data, it wouldn't be considered caching.
  • The API services have exclusivity requirement: you are not supposed to use on the same site any other search provider.
Yahoo
Here's what I have found:
  • Y! makes the search available via web services (REST but not SOAP webservices).
  • Each application has to use Application ID, which Y! issues for free. There is a rate limit for each application id.
  • Allowed usage: web search API is available to commercial use, however a form of exclusivity restraint is imposed: you are not supposed to integrate the results with results from other search providers.
  • Storage restrictions: "you may not store any user data collected through the Yahoo! APIs for more than 24 hours". Again, would storing the processed, for example aggregated data, be subject to this restriction? I suppose, not.
MSDN: Live Search WebServices API
Terms of use summary:
  • SOAP-based webservices call Silky Road.
  • No restrictions other than an application ID needed. But their license is more complex and I might have missed something.
Other
I'm sure there are/may be other search web services available, and some of them may be free. DoubleClick? I didn't analyze other options.

Tuesday, December 30, 2008

How Similar Are Two Text Files?

Suppose you are doing a job hunt (like I'm doing right now) and after applying for quite a few of jobs you see you are loosing track of jobs you have already applied for. The company name is often not shown, since most recruiting/staffing agencies don't reveal it in their job postings. The job titles are often very similar. After inquiring 2 or 3 times a recruiting company about a job you have already been submitted for by another staffing agency (and after you have already wasted your time on duplicate application process), you just wish you'd bee able to quickly detect that the job description you are looking at is very similar to one you have applied to 3 weeks earlier. What do you do? Using the diff isn't very useful, since the job descriptions are often slightly modified by the staffing agency before posting. You want to search for a similar instead of identical text.

I have found that there is research on this topic. The best short-and-sweet summary, I have found is on Y! answers. From the tools mentioned there, I chose the SIM tool by Dick Grune. DOS binary is available there, but the trick was to select command parms that will fit best comparing two html files. I have found that the following combination gives the most to the point answer: sim_text.exe -nT -r 100 job1.html job2.html. It will show only relatively large common sequences (over 100 chars), and if it does show any of those, you better check that the two files don't correspond to the same job opening.

I have also tried stripping the html tags from these html files using Lynx browser with the -dump option. DOS binaries for Lynx, after some digging, I was able to find here. I had also to create the following lynx.bat:

@ECHO OFF
set home=c:\bin\lynx\temp
set temp=c:\bin\lynx\temp
set lynx_cfg=c:\bin\lynx\lynx.cfg
set lynx_save_space=c:\bin\lynx\temp
c:\bin\lynx\lynx.exe %1 %2 %3 %4 %5

The results were not convincing. Actually, for some reason, the file similarity was less obvious when using the stripped files than when I used the original html files. Not sure why. I haven't analyzed this issue.

Monday, December 29, 2008

Struts, Hibernate Development with Eclipse

I'm developing an web application to test algorithms for Romba-like devices. I have some algorithms in mind, that I want to test, so I decided I develop an application for the purpose of testing these algorithms or any algorithms.

I wanted to use Java standard frameworks, for now Struts and Hibernate and Eclipse as the. It took me some time to figure out what free plugins to use with Eclipse to add support to Struts and Hibernate. I looked for some time and finally found the following set of plugins:
For DB development support I have used three:
  • DB Development plugin (from Eclipse.org)
  • QuantumDB
  • Derby plugin (from Eclipse.org)
Probably the first of these would be enough.

A few notes:
  • Tomcat plugin doesn't come with a documentation, but the website has a decent one. Plugin works nicely. Starts Tomcat in debug mode, unless user disables this feature in plugin preferences. Switch to Debug perspective and you can debug your application.
  • QuantumDB is a well known plugin, but I had problems with it. I couldn't find in it the tables that were in the database. Possibly, I'll learn how to use it. DB Development plugin is easier to learn it.
I'm still in early phase of the development. I'll update this blog when I have more experience with these plugins.