Saturday, December 26, 2009

Website monitoring services

Uptime Party, Pingdom, Watch Mouse, Site Uptime and Zoho’s Site 24×7

http://www.labnol.org/internet/tools/best-website-monitoring-services-for-site-uptime/4742/

http://www.labnol.org/internet/website-down-alerts/12096/

in reference to:

"Uptime Party, Pingdom, Watch Mouse, Site Uptime and Zoho’s Site 24×7"
- The Best Website Monitoring Services for Tracking Your Site’s Uptime (view on Google Sidewiki)

5 Useful Websites To Send Large Files Over the Internet

1. YouSendIt
2. FileDropper
3. WeTransfer
4. TransferBigFiles
5. FileBanker

in reference to: 5 Useful Websites To Send Large Files Over the Internet | Techtites (view on Google Sidewiki)

Wednesday, December 23, 2009

How to configure Oracle OCI Driver and connect to Oracle Database using OCI ( Type II ) Driver.

Oracle OCI driver is also called the 'thick' driver, because of its thick native code it uses to communicate with the database. OCI expands to Oracle Call Interface, its written in C language and all the Java calls use JNI to direct the calls to the C layer. The C layer does the talking with the database and returns the results to the Java layer. Even thoug C is the fastest way to communicate with database, the overhead incurred during in the JNI layer makes it a bit slower than the 100% Java thin driver. But in some cases the OCI driver beats the thin driver, i am yet to a performance analysis on that.

In a nutshell, the Oracle OCI (thick) driver uses Oracle Call Interface (written in C and is native code ) to communicate with the database. Hence, all Java calls have to be mapped to the C calls in OCI. Due to this mapping, the driver classes must be in sync with the OCI files - this results in connection problems which are listed and solved below.

Here are the steps that have to be done to Connect to Oracle database using Oracle OCI driver.

ORACLE_HOME : This refers to the folder where Oracle Client or Database has been installed.
Example D:\oracle9i , /home/oracle/orahome. This folder will have sub-folders such as bin, sqlj, network, rdbms, jdbc, jlib, lib, ...etc.

Windows

1. Set ORACLE_HOME environment variable
2. Add ORACLE_HOME\lib to System PATH
3 Set CLASSPATH environment variable to use Oracle JDBC driver from ORACLE_HOME\jdbc\lib

*nix ( Linux / Unix )

1. Set ORACLE_HOME environment variable
2. Add ORACLE_HOME/lib to LD_LIBRARY_PATH env variable
3 Set CLASSPATH environment variable to use Oracle JDBC driver from ORACLE_HOME/jdbc/lib.

While connecting to Oracle Database using OCI driver, here are some of the error messages that you might encounter. If the error message matchs, then the answer to the checklist question must be 'yes', else perform the nesseccary operation to answer 'yes'.

Example :

Is the jdbc driver from ORACLE_HOME/jdbc/lib ?

- If you are using a classes12.jar taken from an other location other than this, then your answer will be no. Hence you will have to use the jdbc driver from ORACLE_HOME/jdbc/lib.

Error Messages and Solutions For Windows Platform

Error Message : Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc9.dll in java.library.path
Checklist :
1. Is ORACLE_HOME environment variable set
2. Is ORACLE_HOME\bin added to System path
3. Is ORACLE_HOME\lib added to System path

Error Message : Exception No Such Method : make_c_state error
Checklist :
1. Is ORACLE_HOME\lib added to System path
2. Is the JDBC driver used to connect to database is taken from ORACLE_HOME\jdbc\lib

Error Message : Exception in thread "main" java.lang.NoSuchFieldError: envCharSetId
Checklist :
1. Is ORACLE_HOME\lib added to System path
2. Is the JDBC driver used to connect to database is taken from ORACLE_HOME\jdbc\lib

Error Messages and Solutions For *nix (Linux / Unix) Platform

Error Message : Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
Checklist :
1. Is ORACLE_HOME environment variable set
2. Is ORACLE_HOME/lib added to LD_LIBRARY_PATH

Error Message : Exception in thread "main" java.lang.NoSuchFieldError: envCharSetId
Checklist :
1. Is ORACLE_HOME environment variable set
2. Is the JDBC driver used to connect to database is taken from ORACLE_HOME/jdbc/lib

Error Message : make_c_state error
Checklist :
1. Is ORACLE_HOME/bin added to System path
2. Is the JDBC driver used to connect to database is taken from ORACLE_HOME/jdbc/lib

Error Message : Error connecting to database : java.sql.SQLException: internal error: oracle.jdbc.oci8.OCIEnv@291aff
Checklist :
1. Is ORACLE_HOME environment variable set

I am just putting down the stack trace down here so that search engines will index them too.

Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

-- Set classpath to Oracle JDBC drivers

---------------------
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path

Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:300)
at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:370)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:505)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:342)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at JDBCOCITest.dbconnect(JDBCOCITest.java:40)
at JDBCOCITest.main(JDBCOCITest.java:30)

-- LD_LIBRARY_PATH has not been set, set LD_LIBRARY_PATH to ORACLE_HOME/lib
---------------------

Error connecting to database : java.sql.SQLException: internal error: oracle.jdbc.oci8.OCIEnv@291aff
Refer to http://myjdbc.tripod.com/basic/jdbcoci.html for the appropriate solution to this error
Exception in thread "main" java.sql.SQLException: internal error: oracle.jdbc.oci8.OCIEnv@291aff
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:188)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:230)
at oracle.jdbc.oci8.OCIEnv.getEnvHandle(OCIEnv.java:79)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:390)
at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:370)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:505)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:342)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at JDBCOCITest.dbconnect(JDBCOCITest.java:40)
at JDBCOCITest.main(JDBCOCITest.java:30)

-- ORACLE_HOME not set

---------------------

Connecting with URL=jdbc:oracle:oci8:@ias904 as scott/tiger
Exception in thread "main" java.lang.NoSuchFieldError: envCharSetId
at oracle.jdbc.oci8.OCIEnv.get_env_handle(Native Method)
at oracle.jdbc.oci8.OCIEnv.getEnvHandle(OCIEnv.java:70)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:390)
at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:361)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:485)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:337)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at JDBCOCITest.dbconnect(JDBCOCITest.java:40)
at JDBCOCITest.main(JDBCOCITest.java:30)

-- wrong version of classes12.jar is being used, use classes12.jar from ORACLE_HOME/jdbc/lib

---------------------


Connecting with URL=jdbc:oracle:oci8:@ias904 as scott/tiger
Error connecting to database : java.sql.SQLException: ORA-12154: TNS:could not resolve service name

Refer to http://myjdbc.tripod.com/basic/jdbcoci.html for the appropriate solution to this error
Exception in thread "main" java.sql.SQLException: ORA-12154: TNS:could not resolve service name

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2321)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:477)
at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:346)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at JDBCOCITest.dbconnect(JDBCOCITest.java:40)
at JDBCOCITest.main(JDBCOCITest.java:30)

-- The tnsname specified in jdbc url is incorrect, check if the names match in ORACLE_HOME/network/admin/tnsnames.ora

OCI Issues: Closed connection error when connection isn't being closed

java.sql.SQLException: Closed Connection
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:439)
at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:653)
at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:338)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:490)
at oracle.jdbc.driver.T2CConnection.(T2CConnection.java:133)
at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:53)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:474)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)

in reference to:

"java.sql.SQLException: Closed Connection at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:439) at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:653) at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:338) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:490) at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:133) at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:53) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:474) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:185)"
- OTN Discussion Forums : Closed connection error when connection ... (view on Google Sidewiki)

Saturday, December 19, 2009

One button to merge all duplicate contacts

Managing a big address book can be a challenge, so it's no surprise that the top request for Google contacts is a fast, easy way to merge duplicate contacts. You've been able to merge contacts one-by-one for a while, but now we've added a single button that merges all your duplicate contacts at once. To clean up your contact list in one fell swoop, just click the "Find duplicates" button in the contact manager, review the merge suggestions (and uncheck any suggestions you don't want merged), and hit the "Merge" button.

in reference to:

"Managing a big address book can be a challenge, so it's no surprise that the top request for Google contacts is a fast, easy way to merge duplicate contacts. You've been able to merge contacts one-by-one for a while, but now we've added a single button that merges all your duplicate contacts at once. To clean up your contact list in one fell swoop, just click the "Find duplicates" button in the contact manager, review the merge suggestions (and uncheck any suggestions you don't want merged), and hit the "Merge" button."
- Official Gmail Blog: One button to merge all duplicate contacts (view on Google Sidewiki)

Amit's Gmail Account and Google Apps Got Hacked

My Gmail and Google Apps accounts were hacked recently but Google restored access in the next three hours. Here are lessons learned and tips that might prevent your Google Accounts from getting hacked.

in reference to: Gmail and Google Apps Account Hacked But Restored Soon After (view on Google Sidewiki)

What To Do When Your Gmail or Google Account is Hacked

Recover Google Account and Gmail access

in reference to: What To Do When Your Gmail or Google Account is Hacked (view on Google Sidewiki)

Friday, December 18, 2009

Speed up Grails in local environment

Typical error received in Grails:-
Running Grails application..
loading security config ...
2009-07-07 12:10:12,224 [main] ERROR plugins.DefaultGrailsPluginManager - Error configuring dynamic methods for plugin [validation:1.1.1]: java.lang.OutOfMemoryError: Java heap space
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.OutOfMemoryError: Java heap space
at _GrailsBootstrap_groovy$_run_closure2_closure13.doCall(_GrailsBootstrap_groovy:86)
at _GrailsBootstrap_groovy$_run_closure2_closure13.doCall(_GrailsBootstrap_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:274)


Grails can seem very slow in development mode, with pages taking more than a second to load. If this applies to you, then try increasing the maximum heap size by setting the

JAVA_OPTS

environment variable to something like this: '-Xmx512m' - this will set the maximum heap size to 512Mb when running Grails and should result in a noticeable improvement in response times.

As a workaround you can edit startGrails.bat and unconditionally put -Xmx to
JAVA_OPTS (search for related lines).

set JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx512m -XX:MaxPermSize=1024m

in reference to:

"Grails can seem very slow in development mode, with pages taking more than a second to load. If this applies to you, then try increasing the maximum heap size by setting the JAVA_OPTS environment variable to something like this: '-Xmx512m' - this will set the maximum heap size to 512Mb when running Grails and should result in a noticeable improvement in response times."
- Grails - Quick Start (view on Google Sidewiki)

Find Your IP

If you want to connect to a PC via Remote Desktop (RDC), you need to know the IP address provided by your ISP. This page is an easy way to see the IP address provided by your ISP.

If you need to know the IP address of your computer on your home network, click Start > Run type cmd in the Run open box and click OK. When the command prompt window opens, type ipconfig -all to see your computer's IP address on the network, your default gateway (the IP address of your router), and the MAC address of your network card (which comes in handy for MAC address filtering on your router).

in reference to:

"If you want to connect to a PC via Remote Desktop (RDC), you need to know the IP address provided by your ISP. This page is an easy way to see the IP address provided by your ISP. If you need to know the IP address of your computer on your home network, click Start > Run type cmd in the Run open box and click OK. When the command prompt window opens, type ipconfig -all to see your computer's IP address on the network, your default gateway (the IP address of your router), and the MAC address of your network card (which comes in handy for MAC address filtering on your router)."
- What is My IP Address - IP Devil Girl - IP Address Lookup (view on Google Sidewiki)

Google Toolbar 6.1.2009.1007b (Firefox)

I like the SideWiki feature. In fact, this post is from the SideWiki! It is in beta stage version is 6.1.2009

in reference to:

"Google Toolbar 6.1.2009.1007b (Firefox)"
- Google Toolbar 6.1.2009.1007b (Firefox) « netVietnam (view on Google Sidewiki)

Error in Pulse Explorer

Typically downloading the new Pulse installer and running it twice will recover broken Pulse Explorer installations. You can also use --repair on the installer to force a clean install

in reference to:

"Typically downloading the new Pulse installer and running it twice will recover broken Pulse Explorer installations. You can also use --repair on the installer to force a clean install"
- MyEclipse :: Eclipse plugin development tools for Java, JSP, XML, Struts, HTML, CSS and EJB (view on Google Sidewiki)

Java Melody : monitoring of JavaEE applications

I came across this tool http://code.google.com/p/javamelody/ which involves monitoring a Java/J2EE application by adding couple of JAR files and a few lines of code in web.xml. This allows us to monitor various aspects of application performance, session details, logging information etc in Testing and even Production environment. The information can be viewed in day/week/month format and also can be configured to send a weekly email report to the admin/developer about the application performance.

This does not perform any profiling or stores into database, so is considered lightweight i.e. should not degrade a lot performance-wise. ( http://groups.google.com/group/javamelody/browse_thread/thread/dfdb7101217ffcbc )

I decided to use it in my application which is a Struts based application in Test environment. I gave it a try by installing the required jars and modifying the web.xml Then I deployed the application and logged in to the application. I was not able to login due to some error. So I decided to check if the Java Melody page shows up. To access this I simply had to use http://server:9090/appname/monitoring and I was able to see the page. Then I scrolled down the different graphs to see a section Statistics System Error Log which shows me the SQL executed!!

So this gave me the error I would have otherwise searched in my log file. After fixing the error (database synonym grant issue), I played with the application and turned back to monitoring page. It gave me pretty good http and sql statistics. I also liked the way it can drill down to all SQL queries


You can check out the monitoring page at http://server:9090/appname/monitoring . You can click various graphs and also hit the Details to get more detailed information.

It can be used it to monitor application with respect to their performance, logging data etc. in real-time.

in reference to:

"monitoring of JavaEE applications"
- javamelody - Project Hosting on Google Code (view on Google Sidewiki)

Use title attribute in HTML for Tooltips

title attribute described here can be used for tooltip. The text would show up on the tooltip

in reference to: H65: Using the title attribute to identify form controls when the label element cannot be used | Techniques for WCAG 2.0 (view on Google Sidewiki)

Tuesday, December 15, 2009

Subversion issues with Netbeans 6.8 upgrade

Upgraded to Netbeans 6.8

This client is too old to work with working copy 'C:\Projects\ProjectName'; please get a newer Subversion client
We strongly recommend to either install a newer Subversion client or downgrade your working copy.
Any local changes might corrupt your working copy and some file operations as copying, renaming and deleting will not work correctly.

Installed http://www.collab.net/downloads/netbeans/ to fix the issue

Saturday, December 05, 2009

Hide your Email Address with the help of Facebook

Another excellent post by Amit where he shows us how to use face book to generate image of the email address in different sizes and hide it!

Hide your Email Address with the help of Facebook

Simple Desktops

What Box Self Referential
Blue Pixels Simple Acorn
Expletive Wallpaper Victrola Gradients

Do you ever feel like the only good desktop wallpapers you can find are the either the basic 15 or 20 Apple provides or solid colors? Do you often find yourself spending time looking for something that isn't a beautiful photograph but also isn't a gradient and drop shadowed mess with a little lens flare and some annoying copyright information in the corner?

Do you want less, but not boring? Then you want Simple Desktops.

Simple Desktops: a collection of bling, drop shadow, and gradient free desktops to help keep you stay focused but also provide just enough eye candy to not be bored. It's here because finding these around the web is just too hard.

Attribution for the creation of these is given to the creator on the site, but it doesn't extend onto your personal desktop. Use of these desktop wallpapers is for personal use only and shouldn't be sold or reposted without the expressed written consent of the desktop wallpaper's creator.

Friday, December 04, 2009

MyEclipse does not build class files for web project

I had an interesting situation with MyEclipse not building new class files out of changed java code. It was trying to run an old copy of my application. There are a number of things you can do to fix this. Check which one works for you…

Solution:

Try and restart using -clean and see if that helps. On Mac, you will have to select the Eclipse executable and do "Show Contents" then edit the eclipse.ini file in there and add it at the top line.
Also, remove the deployment, clean your project and re-create the deployment. If it's still not working, clean the <workspace>/.metadata/.log file and retry it and see if an exception is getting reported.

Pop open your project properties for the troubled web project, and go to MyEclipse > Web and make sure the two text fields have valid Web Root and Context Root directories set.
Then go to the Java Build Path properties node and click the "Source" tab. Now double-check that your source directory or directories are setup correctly and that your output dir is set to the correct WEB-INF/classes output dir (you can use Browse to re-select it if it's blank).
Now go to Project menu, and select Clean. Make sure the project rebuilds completely without errors.
If you have errors, double-check them, they might be invalid library or project references, which will stop project building dead in it's tracks.

Project layout supported in MyEclipse: (Hopefully will be more flexible in the future)

/<project root>
   +/src <-- Java source code for web project (servlets, actions, forms, beans, etc.)
   +/docs <-- license files, readme's, etc
     +/api <-- Target for your Javadoc source generation
   +/lib <-- extra libs that the web app doesn't need while running
   +/webroot <-- this is the base of the webroot, this will be the root when deployed to Tomcat, etc.
     +index.jsp <-- example jsp file in root
     +/images <-- images for the website
     +/WEB-INF
       +/classes <-- build output directory
       +/lib <-- libs required for your webapp to run (i.e. struts.jar, etc.)
       +/conf <-- your custom conf files that you need for your app
       +/tld <-- taglibs

Friday, November 27, 2009

LG Xenon: turn off the irritating "Call from (name)" and "Message from (name)"

How to turn off the irritating "Call from (name)" and "Message from (name)"

If you have the issue with the phone saying “message from (and the name)’ or “call from (and the name)” even on silent, here is the solution:
- Tap the “Settings” icon
- Tap the “More” icon
- Tap the “Application Settings” icon
- Tap the “Voice Command” icon
- Tap the “Call Alert” icon
- Select the “Ring Only” option
Hope this helps!

Saturday, November 21, 2009

Gmail helps you unsubscribe from unwanted lists!

Since my email address is shared on many web sites I get a lot of emails. I am very careful to set a lot of filters and follow up every Spam that escapes these filters and catches my attention. One such email is as below. But this time when I clicked the “Report Spam” button Gmail offered to unsubscribe from the list. Wow! what a feature. Although, it does not work with all the mailing lists.

From the Gmail help pages: http://mail.google.com/support/bin/answer.py?hl=en&ctx=mail&answer=80405

We don't think you should be burdened with managing messages you don't want to receive. We do our best to put messages in Spam when we're pretty sure you won't want or need them. But everyone has different preferences about the mail they want to see. You may not want to read any messages sent by a certain company or mailing list, while another Gmail user finds these same messages to be valuable.

To help solve this problem, we're providing you with an unsubscribe tool for some messages. You'll see the unsubscribe tool when you mark a message from particular types of mailing lists as spam. If the particular message is a misuse of a mailing list you like to receive, you can Report spam as usual. But if you never want to receive another message or newsletter from that list again, click Unsubscribe instead. We'll send a request to the sender that your email address be removed from the list. It's that simple!

Gmail unsubscribe

Friday, November 20, 2009

input:focus for Internet Explorer

The :focus class can be used to apply styles to a page element that receives focus. So, for example, if you wanted the background color of input boxes to change when they are in use by the user, you can simply do:
input:focus { background: orange; }

But this does not work for IR and hence

select:focus, textarea:focus, input.sffocus {

border: 1px solid #b2d1ff;  background-color: yellow; color: blue;

}

Ref: http://www.htmldog.com/articles/suckerfish/focus/

Sunday, November 15, 2009

Find a mutually agreeable time

An easy way to find out when everyone is free for your next meeting or event. Click the grid for all the times that are good for you - you get a link to email to your invitees. They see your proposed times and click on when they are free. You visit your results page and see when everyone can do. No sign-up form. No password to choose. No fuss at all.
Website:- http://WhenIsGood.net/
Quick preview video:-






Doodle does a pretty good job too!

Monday, November 09, 2009

Never Miss a Game or Birthday: Google Calendar Adds Sports & Birthday Schedules

Here’s a great new idea from Google: sports schedules for pro and college sports teams, integrated into Google Calendar.

The feature was rolled out yesterday, and allows users to browse for their favorite teams (including international soccer and rugby clubs) in a variety of sports and see their schedules alongside other meetings, tasks, and reminders.

If you’d like to activate a calendar, you should see a “New: Sports Calendars” link on the top right of Google Calendar that you’ll want to follow. From there, once you’ve found your team, click “subscribe” and that team’s games are automatically added as events in their respective date and time.

Along with the sports update, there’s now also a birthday calendar, which will “add all of your contacts’ birthdays to Google Calendar. Data is pulled from your Gmail contacts and your friends’ Google profiles.”

Redirect from Struts Action

request.sendRedirect does not work in Struts action. You can use it in jsp (view layer) but not in the Struts Action

Action:-

request.setAttribute("url", "http://dynamic_url.com");

return mapping.findForward("redirect");

struts-config.xml

</global-forwards>

<forward name="redirect" path="/redirect.jsp" redirect="false" />

</global-forwards>

redirect.jsp

<% String url = (String)request.getAttribute("url");

response.sendRedirect(url);

%>


Monday, October 26, 2009

Google Timeline

A (very) quick look back at the Google story over the last 11 years. From Stanford to Mountain View and around the world, featuring many different products, starting with BackRub (Search) up to Google Wave, StreetView and Chrome.

Sunday, October 25, 2009

Difference between SWF and FLV

I will find people confuse with the difference between SWF and FLV. I am willing to reply people's question as long as I know its answer. In fact, this question can be replied by one sentence, that is, SWF (acronym of “Shockwave Flash”) actually is a Flash movie, and it can be viewed as a Flash animation format, while the FLV is Flash Video, which is a Flash video format. Both of them can be created by Adobe Flash.


More specifically, SWF is a proprietary file format for multimedia and especially for vector graphics. It can contain animations or applets of varying degrees of interactivity and function in order to be small enough for publication on the Web. Therefore, SWF is currently the dominant format for displaying animated vector graphics on the web which is very popular and be commonly used. What's more, SWF is sometimes used for creating animated display graphics and menus for DVD movies, and television commercials.


FLV, as a Flash video format, is also very popular on the web. You can always see the videos on the website like YouTube, Google Video, MySpace TV. After you download the video from YouTube, you will find the downloaded video's file extension is .flv, which means it is the FLV video. It is also in a small size and can be loaded on the web easily. We can take the YouTube video as an example, the video on the website we can consider as a FLV files with a player in it.  Once you download it to your local computer, you just download the content, that is the FLV, to your website, but the player is still on the YouTube website. If you want to play the FLV on your website, you need to embed it to a player. While the SWF can be seen as a container and we can embed the FLV files into SWF and play it. So, under some conditions, SWF file can be divided into two parts, the Flash Video (animation content) and the SWF player (Adobe Flash Player is commonly used to play the SWF).


Generally, SWF file is a completed, compiled and published file and can not be edited by Adobe Flash, however, many SWF converters or FLV encoders do exist. These little tools will help us convert the video to Flash Video (FLV) or Flash Movie (SWF) to be published in the website for sharing. As we all know, because of the widely use of Flash player 8 and Flash player 9, nearly any Flash Movie can be easily played on every browser.


Therefore, it is not surprising to find many people Google for the FLV encoder, FLV converter, or SWF converter.  Now the video sharing websites like YouTube have attracted people's attention, and then follows the popularity of the FLV downloader and FLV player, which has become a fashion today.  Even if you are not familiar with Flash making, you can get Flash video or movie as well. Just choose a Flash Converter. It can help you to upload your video with a small size in the form of FLV.

Saturday, October 17, 2009

Book Review : Grails 1.1 Web Application Development

 
Grails 1.1 Web Application Development(Jon Dickinson - $35.99 Amazon)
(https://www.packtpub.com/grails-1-0-web-application-development/book)
Table Of Contents http://www.packtpub.com/article/grails-1-0-web-application-development-table-of-contents
Preface
Chapter 1: Getting Started with Grails
Chapter 2: Managing Users with Scaffolding
Chapter 3: Posting Messages
Chapter 4: Introduction to Groovy
Chapter 5: Authentication with JSecurity Plug-in
Chapter 6: Testing
Chapter 7: File Sharing
Chapter 8: More GORM and Criteria
Chapter 9: Services
Chapter 10: Managing Content through Tagging (sample chapter)
Chapter 11: AJAX and RIA Frameworks
Chapter 12: Searching, RSS, and REST Services
Chapter 13: Build Your Own Plug-in
Chapter 14: Deployment and the Real World
Index


Tag Line: Reclaiming Productivity for Faster Java Web Development
The target audience are Java developers looking for ways to develop web applications faster and more easy without throwing away their previous knowledge or leaving the java platform. Grails utilizes Java and other related proven technical libraries under the covers. With very simple explanation of basics the author tries to lure the average Java programmer to take a second look. But the book gets too technical and complex in some parts as it touches unwanted territory. Prior knowledge of java web application development is required.


Chapter 1: Getting Started with Grails
Right upfront an argument is given as to why Grails should be used and how it is based on proved technologies like Hibernate and Spring. The chapter lists the following important points in favor of Grails:-

  • Requiring less configuration
  • Faster setup
  • Shorter develop/test cycle
  • Consistent development environment
  • Domain-specific language for web development
  • Fewer dependencies

Perhaps some of the points would have been Grails v Java or Grails v Rails.
This is followed by installation of Grails. I think this is a very important and many books do not cover such topics. This part is has Windows and Mac screen shots. This follows creation of a new application called teamwork using create-app command. This creates the skeleton for domain, views, controller, conf, i18n, helper services, taglibs. To run this application run-app command is used.
Throughout the book a team communication portal application is used. The requirements and architecture of this application is explained in brief.


Chapter 2: Managing Users with Scaffolding
This explains the use of scaffolding and what pages and actions to expect as a result. Domain classes are created for the application using create-domain-class command. Controllers are created for all the domain classes using create-controller command. The def scaffold =DomainClassName magically creates all the CRUD code necessary for the application to work.
Grails uses in-memory HSQLDB database by default and at this point no configuration is necessary to get this started. Introducing static constraints helps in basic validation of data and to determine which input type is used when rendering a form. This is to get your application running quick but I hardly find a real-life example of this. Most databases are full of complex composite keys and foreign keys which cannot be modeled with scaffolding and need a lot of customization in Grails.
Relationships are created in this application. Since Grails uses hibernate under the covers the supported types of relationships are: One-to-one, One-to-many, Many-to-many, Many-to-many. Bootstrapping of data is done though grails-app/conf/BootStrap class which helps in loading data into the application on start up.
In short a fully loaded chapter to get started.


Chapter 3: Posting Messages
I find the title of this chapter irrelevant to Grails. Chapters should be given names relevant to Grails context and not application/example context. In this chapter the author talks about basic building blocks of grails - more domain classes, respective controllers and views, validation and GORM (Grail's Object Relational Mapping). dateCreated and lastUpdated are very special properties of type Date in Grails and they are handled automatically. This time the controller is not created with create-controller command but rather a file is directly created in the appropriate directory.
Groovy Server Pages (GSP) are introduced as being similar to JSP. The view code is then provided and again the command is not used for create.gsp. Grails uses simple yet powerful SiteMesh layout mechanism which uses tags g:layoutTitle, g:layoutHead, and g:layoutBody. There is more manual code to get the form appropriately displayed along with a short note about grails form tags g:form
The Grails input form, Grails form binding, validation and save cycle of Grails is explained briefly. The flash scope which holds the success or failure message between two consecutive HTTP requests is added. redirect is used to forward the user after a successful operation while render is used to show error information back to the user in order to correct it and re-send it.
The application home page creation is explained - domain, controller and views. Detailed explanation is provided of listing all messages by querying the database as well as the valid parameters for the list method. The author then explains how to change the default home page to go through the home controller index action. This is important when using plug-ins like cas for Single Sign On. The css style sheets are updated with the code available with the book. The author ends with an excellent section on cross-site scripting and validation. Grails provides a g:message tag that is used to look up messages in a message bundle based on a message code. This explains how i18n can be used in Grails.


Chapter 4: Introduction to Groovy
Groovy is the primary language used in Grails. This chapter covers some high level basics of Groovy with respect to Java, installation, data structures, closures, POGO, metaprogramming, builders. Definition of Groovy along with explanation of its properties are explained - Object Oriented, Dynamic and functional loosely typed. Similarly there are questions why Groovy makes software development simpler : familiar syntax like Java & direct integration into Java. The next phase takes us into how to install and configure Groovy on local PC and Mac. Groovy shell is a command line where you can type up some Groovy code. The Groovy console is a Swing application which allows user to write and execute Groovy scripts. This follows an explanation of difference between Groovy classes v scripts - Groovy scripts having less overhead and simpler to write.
All the basic features of Groovy language are explained including-
Optional Semicolons, different ways to express String, Numbers and utility methods, easier way to work with List, enhanced Maps, Range - which is a new data type to simplify iteration and work with collections, slightly different way to operate with Truth and equality, Closures - blocks of code which can be passed as arguments and executed, Plain Old Groovy Objects (POGO) whose properties are published as getters and setters automatically, Metaprogramming - also called Dynamic Groovy or compile-time metaprogramming and builders. All these features are well explained with simple examples which makes for good understanding of concepts.
This chapter was a welcome adding to the Grails book.


Chapter 5: Authentication with JSecurity Plug-in
This is where the power of Grails lies - the plug-ins! Some basic functionality would be developed as modules by programmers and made available to the world as plug-in. Installing a plug-in and following some simple configuration would give your Grails application some new features with cheap coding. Firstly, I would advise you to be careful of plug-ins since they are a double edged sword - in terms of who have developed them and the testing. Secondly, some plug-ins just don't work as advertised!!
The author has given example of JSecurity plug-in. This can be an excellent start for someone who is yet to think of a security strategy. Honestly it is scary for those who are new to plug-ins and find it so many pages to go through to get started. I would have loved to play with simple plug-ins like searchable, cas, filter pane. Such plug-ins are more commonly used. The author has used basic idea of users and roles. JSecurity system covers users, roles, permissions, subject, principle and realms (Realm class) . A method is defined to allow authentication. This is where the concept of dynamic finders is introduced. These methods do not exist but the name of method is used by Grails to query against database. There is good coverage of this topic including the operators that can be used for constructing the method name and their limitations. Querying by Criteria is explained with hasRole method which tests if a user has a particular role. Such queries are more complex and more widely used. But the explanation is short. Authentication is added to the Grails application using a Grails Filters which is quick and easy. Password encryption is achieved through Sha1Hash. This spins my head into thinking whether I want to really learn JSecurity or stick with my good old cas filter. It feels I am learning cryptography and not grails! Three more things are discussed which are: 1. Encryption of users' password: This uses the 'Open Session in View' pattern of hibernate which means the object is not persisted until all server-side operations have finished and the author actually changes the password after calling save method - Neat! 2. Permission denied page: This is done by implementing the unauthorized action in AuthController and creating unauthorized.gsp view. 3. Sign Out: This uses the signout tag provided by JSecurity which leads to a table listing of all JSecurity tags. The service layer of Grails and how to inject the service is discussed very briefly.
Hibernate's lazy loading property and how it affects the relationships in an application is discussed. The n+ 1 problem can be solved with eager loading (lazy:false)
In short, I feel this chapter was more a case study. There is a potpourri of new topics which are all discussed in short - plug-ins, JSecurity, authentication, authorization, encryption of passwords, services, lazy loading, eager loading, relationships to name a few - phew!


Chapter 6: Testing
This chapter starts with a background of testing. A couple of the links were very weird - pointing to a yahoo group? The chapter then goes on to define why tests are needed and how to write tests. There is a basic review of JUnit concepts before diving into how Grails leverages JUnit and extends it with some useful methods. The focus of the chapter is on unit testing, mocks, integration and functional testing (Functional Test plug-in) The author goes into detail to explain what makes a good test which touches the assumption of your libraries to be perfect, testing production code and using descriptive test names. A listing of all assertion methods and Grails provided assertion methods are provided. Most of this is self-descriptive but the shouldFail and shouldFailWithCause are explained with examples since they take a closure. When create commands are executed a test case is automatically created. A testcase is created by extending GrailsUnitTestCase. Running the test creates an HTML report.
An important point brought out is that the dynamic methods and properties supported by Grails framework are not available when running unit tests since they do not run within the Grails container. Mocking support helps us solve this issue. An in-depth example explains this behavior. This example also uses the delegate property on the closure. After testing the metacontroller the next test is of validations. Unit testing limitations are explained which leads to Integration testing. Integration testing is explained with only one example.
Limitations of Integrations test brings us to functional test. Functional testing is achieved in Grails through plug-ins eg. HtmlUnit. The book takes us through the installation of the functional-test plug-in and creation of functional test case for login.
I had a few issues getting the code to work. But overall a good attempt has been made to demystify the details of why we need tests, what are the different types of tests available and how to best take advantage of them.


Chapter 7: File Sharing
Grails has good support for file upload and download. To accomplish this a File domain is created with necessary attributes like data, name, size etc. Two methods of uploading are discussed 1. Using data binding, 2. Using Spring MultipartFile interface. The code uses the latter to achieve desired results. This model results in a file being loaded into the memory. Using the fact that relationships between domain objects are lazy by default the author then creates a more efficient model by extracting data out of the model thus creating a new domain called FileData containing this binary data. Thus FileData belongsto File. The last piece is the downloading controller and gsp. I found some glitches in the code.


Chapter 8: More GORM and Criteria
This talks about maintaining version history and advanced query techniques through GORM. Through Data Modeling, existing responsibilities of File class are extracted into FileVersion domain and FileData now belongsTo FileVersion. This makes the File class simply a container of FileVersion. (hasMany FileVersion). The explicit declaration of the version property as a SortedSet tells Grails that the items contained in this relationship must be ordered. This moves the discussion to criteria queries which help to retrieve data. This is where Grails taps into the power Hibernate (HibernateCriteriaBuilder) which is built on top of Hibernate criteria API. Dynamic finders in Chapter 5 are replaced with criteria equivalents. Each node is used to build on the criteria. Logical operators and Querying across relationships is explained next. The change in code affect the Hibernate EAGER fetch. There is discussion of fetchMode.EAGER which can be used to restore it. Table containing a full list of available criteria and logical operators for nodes is listed. There is not a lot of discussion of properties of criteria except for maxResults but links to Projections and Scrollable Results are provided.
This discussion leads to code changes in other layers. Updates to create method in controller and view are explained. Due to the domain changes, the save method in controller also needs to be changed. I observed that there is no error handling in the code and view.


Chapter 9: Services
Introduction explains why we need the service layer so that we can leave the controller to just handling the control of flow. This makes the service layer more testable and reusable and there is clear boundary where the business logic is placed. The command to create a Service is given which results in a Service class in appropriate directory. Grails uses Spring's declarative transactions. boolean transactional = false removes this transactional behavior. Similarly, Grails uses Dependency Injection mechanism to inject services into domain objects. This is an interesting and detailed discussion since Grails uses convention over configuration. It is so simple to write def fileService and inject an instance of FileService using loose typing without reloading application.
Strongly typed property FileService fileService can be injected but needs application restart. Services by default are singletons, and hence not thread-safe. Scopes of the Service can be changed using property static scope='prototype'. There is a table listing all scopes. The code is then modified to extract as much business logic from Controller into service as possible. How and why this is extracted and modified is explained. Thus the Controller is simplified.

Chapter 10: Managing Content through Tagging (sample chapter)
Being a Grails book, I would have thought of a better Chapter title. Check out this chapter online with the link given above.
The concepts discussed here are :

  • Working with inheritance in the domain classes, and looking at which strategies GORM supports for persistence
  • Using polymorphic queries over a domain inheritance hierarchy
  • Encapsulating view-rendering logic in GSP templates
  • Manipulating collections with the Groovy collect and sort methods

The Tagging Domain model is discussed and a new directory is created to separate the tagging classes from application domain classes.
Tag—to store the name of the tag
Tagger—to store the relationship from domain objects to a tag.
The domain classes are created and a service is created TagService having methods to create tag relationships. The collect method is used here as explained in Chapter 4. Elvis operator of Groovy is used in one of the methods.
Integration tests are created to make sure the relationships are working before introducing in application. During the integration tests the setUp method id overloaded and BootStrap class is used to create test data. Relationship with Message is created and TagService is injected. This is a very good and simple example of running Integration test.
Chapter 11: AJAX and RIA Frameworks
AJAX and rich applications have been the buzz word recently. This chapter touches on some plug-ins used for UI design in Grails. Grails uses Prototype framework for this support. remoteLink and formRemote tags of Grails are introduced and a complete listing of attributes and usage is provided. For inline editing of tags in the application Taggable controller is created. The author then takes us through the explanation of how this is to be done. I think this is an excellent start.
The next trick in UI design is the auto-complete of tags. There are two plug-ins: GrailsUI and RichUI out of which RichUI is explained in detail. Both these are developed on top of YUI. After installation, dynamic finder is used to match partial tag and come up with options. These options are converted to XML using renderAsXml method which take in a closure. This output is then used by the RichUI auto-complete widget richUI:autoComplete to create the autocomplete input field. Required gsps are created we are up and running. Beautiful example!
Another fashion is the the cloud of tags representing popularity. RichUI provides a component that handles all the client-side presentation work. The tag is richui:tagCloud. After a look at the available options we conclude that we need a map of tag and occurrences for this functionality. By adding another method to the service layer we get this matrix and controllers are changed to reflect this. listDistinct method is used on CriteriaBuilder inorder to get a distinct list. Clouds are then rendered using richui:tagCloud in appropriate gsps.
This chapter is beautifully written to capture user attention by tagging and then using these tags for auto-complete and clouds. This also helps in organizing and filtering content.

Chapter 12: Searching, RSS, and REST Services
This chapter introduces some more excellent techniques to help customers. Grails has an excellent plug-in for search : searchable plug-in which uses Lucene as the back-bone. This plug-in is easy to install and use. But people have just seen the tip of the iceberg. When I tried this plug-in on some complex projects with composite key relationships it wouldn't work. The project is pretty active and I hope all bugs get fixed. But by just including one line in the domain we can make a class searchable static searchable = true. Honestly, I used this section to make my first site-wide search and integrate it into my grails application. I was very pleased with the explanation. The trick is to create a search box in main.gsp and then create search controller which uses the search service to provide results. The results can be viewed by creating index.gsp in the search directory. The book then takes us into how to integrate this search in the application by adding code to main.gsp which is shared across pages as a header and creating a search controller which get its results from a search service. This SearchableService (provided by the plug-in) is injected into the controller. There are further changes to views and templates to display the search results.
This takes us into RSS feeds which is useful for customers to track new content. Grails has a Feeds plug-in built on ROME API. But the author takes this opportunity to introduce Builders in Grails rather than using this plug-in. Surprisingly, there is no definition about builders or why we use them!! To get around the problem of dynamic methods in controllers a separate utility class is created with a collection of items and closure. This is then called the controller to achieve desired results. Authorization is removed from this RSS which in terms of design seems wrong.
The last part takes us through REST support in Grails which is url based. This just involves tweaking the url mappings, controllers and security for handling HTTP method and XML data. Various URL mapping configurations in Grails are explained by snippets of code. The controller makes use of Grails converters (as XML). This should be used carefully when providing interfaces to clients. This follows  a scheme for authentication of REST API messages through the same JSecurity scheme. The credentials are passed in the header of the request through the Spring application context. A script is used to test REST.


Chapter 13: Build Your Own Plug-in
Plug-ins are the selling point of Grails and they want you to write plug-ins! The book takes you into how to develop a tagger plug-in. Grails plug-ins are created similar to an application using grails create-plug-in command which creates a directory structure of an application plus a configuration file for the plug-in. This configuration file contains version, author and lifecycle details. The code previously used in the application is stripped out and plugged into this plug-in application. The plug-in templates are then exposed as tag libraries to applications so that the GSPs can render the appropriate templates. Similarly these templates can also be rendered through controllers.
The author then exposes an ugly flaw in the plug-in which is the domain classes need to extend the Taggable class for the plug-in to work. Later we are taught how to package a plug-in and create a distributable zip file which can then be installed using install-plug-in command.
The rest of the chapter talks about how to tap into the lifecycle events- (build time and run time) through Grails plug-ins. The Build events are not described in detail but the runtime events are explored in detail with regards to what they do and how they can be used. Runtime event handlers are enabled by declaring a closure with the relavant name in *Plugin descriptor class. The book then talks about inspecting Grails artifacts in this case all Grails classes to find a static property value of taggable. If found means the domain is taggable. The rest of the chapter talks about how to re-model the relationships between a domain object and its tags to remove the dependency and how to add taggable behavior into the application. This gets very complex and is beyond the scope if you are new to Grails.
I wish writing plug-ins was as easy as described in this chapter! Writing plug-ins is a major investment and even I would say half of the Grails plug-ins have unsolved issues with them. This also requires deep understanding of Groovy and meta-programming. The benefit is of course you have made a reusable component for the future.

Chapter 14: Deployment and the Real World
This chapter deals with installing and configuring MySQL and Tomcat to run on your system. The DataSource definitions in Grails are extracted out to DataSource.groovy with clear distinction between development, test, production.
To summarize, it was a good read. There are simple running examples of code tutorials. I would have liked advanced examples of the plug-ins like searchable. Filter pane which is an important plug-in is missing in the book. The Grails web site also has pretty simple and straightforward examples to learn from. Unfortunately for the book, plug-ins are the heart of Grails and keep updating. I wouldn't be surprised if the code runs out of date in a short period. I would have definitely liked more structured matter. Working in Grails - I find the biggest challenge is interacting with legacy database. There might be doubts about the correctness of the code and pattern used but it is important to remember that this is a starter book.


Who can use the book:
Starters who want to learn Grails. It assumes prior web development experience with Java & web applications. It contains a robust example of a web application being developed – a team communication portal.
You can visit http://www.packtpub.com/support/book/grails-1-0-web-application-development to directly download the example codes in the book

Language English
Paperback 328 pages [191mm x 235mm]
Release date May 2009
ISBN 1847196683
ISBN 13 978-1-847196-68-2
Author(s) Jon Dickinson
Topics and Technologies Open Source, Java, Web Development

About the Author (As on the site)
Jon Dickinson is the principal consultant and founder of Accolade Consulting Ltd. (http://www.accolade-consulting.co.uk) and can be contacted at jon@accolade-consulting.co.uk. He specializes in developing web applications on the Java platform to meet the goals of users in the simplest and least obtrusive way possible.

Thursday, October 08, 2009

The Spring Framework - Powering Enterprise Java Development


Seminar presented by Greater Boston Chapter of the ACM


From it's not-so-humble start, the Spring Framework set its aim on reducing complexity in Java development. Now, as Spring celebrates its seventh birthday, it has become the de facto standard enterprise Java framework and continues its mission of providing great power with minimal effort.
On November 14-15, Craig Walls and Ken Sipe will be your guides to Spring. You'll start by learning the principles of Dependency Injection and AOP, the basis of much of Spring's power. Then you'll see how to employ Spring in building enterprise applications that are maintainable, testable, and efficient. The weekend will conclude by giving you an opportunity to openly ask any questions that you may have about Spring.
When:     November 14-15, 2009
Where:    Maxwell-Dworkin Building
               Harvard University, Cambridge, MA
Details:     www.gbcacm.org
Special offer: Through November 10 receive a $50 discount using discount code GBCACMSF02-09

What is the Spring Framework?

Spring is a widely used open source framework that helps developers build high quality applications faster. Spring provides a consistent programming and configuration model that is well understood and used by millions of developers worldwide. Spring provides a range of capabilities for creating enterprise Java, rich web, and enterprise integration applications that can be consumed in a lightweight, a-la-carte manner.

Spring provides the ultimate programming model for modern enterprise Java applications by insulating business objects from the complexities of platform services for application component management, Web services, transactions, security, remoting, messaging, data access, aspect-oriented programming and more. Spring is built on an Inversion of Control (IoC) container that enables Java components to be centrally configured and wired together—resulting in code that is more portable, reusable, testable and maintainable.

 

Seminar Topics

Agenda - Saturday

Welcome/Sign-in (8:00am-9:00am)

Get your badge, enjoy a continental breakfast, pick out a seat and take advantage of the opportunity to meet people facing the same challenges you are.

Introduction (9:00am-9:10pm)

A quick overview of what we will be covering in these two days.

Morning Session (9:10am-12:00 noon)
Spring in Action (Craig and Ken)

The key to building maintainable and easily testable software is to keep coupling low between application objects. Although there are many facets to the Spring Framework, at its core Spring offers loose coupling through dependency injection and aspect oriented programming. In this introduction to the Spring Framework, we'll profile the entire Spring portfolio before diving into a deeper examination of Spring's dependency injection and AOP facilities. This will not only equip you to write more loosely coupled code around plain-old Java objects (POJOs), but also set the stage for working with the rest of Spring.

Spring 3 without XML and the ADD Developer (Ken)

Java projects have been plagued for sometime with a large amount of configuration information being pushed to XML.  This includes the configurability of classes and components which would make no sense for an administrator to reconfigure, as well as causing frustration in development over version code thrashing for the most commonly used shared files. Since Java 5 there has been a push for using annotations to describe metadata.  This removes the bottleneck associated with a common XML and increases productivity and opens up new challenges.  Annotation driven development (ADD) is enabled through Spring 2.5 / 3.0.  This session will expand upon the Spring in Action session and will discuss what belongs in the xml file and what should be annotated.

Lunch (12:00-1:00pm)

Lunch is provided, so you can sit with your fellow attendees and discuss the morning's topics.

Afternoon Session (1:00pm-4:45pm)
Graph Problems [50 mins]
BuildingWeb Applications with Spring @MVC (Craig)

Many applications present themselves to their users through browser-based user interfaces. Building those web applications has never been simpler.  Spring has always offered an MVC web framework, but more recently Spring's web framework has evolved to use of Java 5 annotations to offer a lighter, more POJO-like programming model. In this session, we'll look at Spring's annotation-based web MVC framework (commonly known as Spring @MVC).

Spring + JPA + Hibernate (Ken)

Most applications have some requirement to persist data.  The most popular two frameworks in the Java space for light-weight persistence is JPA and Hibernate.  This session will detail the core of JPA and Hibernate with a focus on what Spring provides to enhance productivity in leveraging these frameworks.

Agenda - Sunday

Welcome/Sign-in (8:00am-9:00am)

Enjoy a continental breakfast, pick out a seat and take advantage of the opportunity to meet people facing the same challenges you are.

Morning Session (9:00am-12:00 noon)
Spring Security (Craig)

Security is an essential element of many applications. Spring Security (formerly known as Acegi Security) is a very powerful and flexible security framework for Java. Based on the Spring Framework, Spring Security provides declarative method and web level security including a wealth of options for meeting your application's specific security needs. In this session, we'll explore the Spring Security framework and see how easy it is to use the new configuration elements and annotations to enable security in Java based applications.

Grails (Ken)

Grails is the fasting growing web framework in the Java web development space.  Grails brings together the best of breed Java frameworks, such as Spring, Spring Web Flow, Hibernate and Quartz and ties them together with a new language called Groovy.  This session provides a number of benefits relative to Spring; First, it is the most mature and advance use case of the Spring framework publicly available. Second, it is completely Java and third, developers are massively more productive using the Grails framework, craving a typical 30% - 40% off estimates.  This session will include an introduction to Grails, the build out of a web application, including how Spring injects work.

Lunch (12:00-1:00pm)

Lunch is provided, so you can sit with your fellow attendees and discuss the morning's topics.

Afternoon Session (1:00pm-4:45pm)
In Pieces: Building modular applications with Spring Dynamic Modules and OSGi (Craig)

The secret weapon for attacking complexity in any project is to break it down into smaller, cohesive, and more easily digestible pieces. Unfortunately, Java lacks critical elements for building modular applications.  To address these shortcomings, OSGi brings true dynamic modularity to the Java platform and Spring Dynamic Modules (Spring-DM) bridges OSGi with the Spring Framework to offer a declarative programming model for working with OSGi services. In this session, we'll see how to develop applications that are composed of smaller, more cohesive, and more loosely-coupled modules.

Panel Discussion (Craig and Ken)

This is a "stump the expert" panel.  This session purposefully lacks formal organization and is setup as a Q&A session.  Laptops will be present for live on the fly coding to provide coverage in areas of interest in the Spring space for which their wasn't a formal session presented.

 

Key Modules

The Spring Framework comprises several modules that provide a range of services:

Inversion of Control container: configuration of application components and lifecycle management of Java objects

Aspect-oriented programming: enables implementation of cross-cutting routines

Data access: working with relational database management systems on the Java platform using JDBC and object-relational mapping tools

Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects

Model-view-controller: an HTTP and Servlet-based framework providing hooks for extension and customization

Remote Access framework: configurative RPC-style export and import of Java objects over networks supporting RMI, CORBA and HTTP-based protocols including web services (SOAP)

Batch processing: a framework for high-volume processing featuring reusable functions including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management

Authentication and authorization: configurable security processes that support a range of standards, protocols, tools and practices via the Spring Security sub-project (formerly Acegi).

Remote Management: configurative exposure and management of Java objects for local or remote configuration via JMX

Messaging: configurative registration of message listener objects for transparent message consumption from message queues via JMS, improvement of message sending over standard JMS APIs

Testing: support classes for writing unit tests and integration test.

 

You Will Learn

From it's not-so-humble start, the Spring Framework set its aim on reducing complexity in Java development. Now, as Spring celebrates its seventh birthday, it has become the de facto standard enterprise Java framework and continues its mission of providing great power with minimal effort.

In this weekend seminar, Craig Walls and Ken Sipe will be your guides to Spring. You'll start by learning the principles of Dependency Injection and AOP, the basis of much of Spring's power. Then you'll see how to employ Spring in building enterprise applications that are maintainable, testable, and efficient. The weekend will conclude by giving you an opportunity to openly ask any questions that you may have about Spring.

Whether you're already working with Spring or are just getting started, you'll leave this weekend equipped with greater understanding of Spring and new tricks and techniques that you can begin applying immediately to your projects

Wednesday, October 07, 2009

Getting started with Ruby on Rails

Here is a very simple tutorial to get started : http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials. First 2 links on that page are a good start:

Rolling with Ruby on Rails : http://oreilly.com/pub/a/ruby/archive/rails.html?page=1

Rolling with Ruby on Rails, Part 2 : http://oreilly.com/ruby/archive/rails2.html

Points below are some issues I faced and how I resolved them. I installed Ruby with the one-click installer for Windows : http://rubyforge.org/frs/?group_id=167. This also installs gem which can be thought of as a package manager.

C:\Projects>gem install rails --remote
Install required dependency actionpack? [Yn]  Y
Install required dependency rack? [Yn]  Y
Install required dependency fcgi? [Yn]  Y
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install rails --remote
checking for fcgiapp.h... no
checking for fastcgi/fcgiapp.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --srcdir=.
        --curdir
        --ruby=c:/ruby/bin/ruby
        --with-fcgi-dir
        --without-fcgi-dir
        --with-fcgi-include
        --without-fcgi-include=${fcgi-dir}/include
        --with-fcgi-lib
        --without-fcgi-lib=${fcgi-dir}/lib

Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/fcgi-0.8.7 for
inspection.
Results logged to c:/ruby/lib/ruby/gems/1.8/gems/fcgi-0.8.7/ext/fcgi/gem_make.out

The problem was that the one click installer for the Ruby on Windows installs version 0.9.4 of gems. An update via

gem update --system

brings it up to 1.3.4 which then allows successful install.

C:\Documents and Settings\VSanzgiri>gem update --system
Updating RubyGems...
Attempting remote update of rubygems-update
Install required dependency session? [Yn]  Y
Install required dependency hoe-seattlerb? [Yn]  Y
Install required dependency hoe? [Yn]  Y
Install required dependency rubyforge? [Yn]  Y
Install required dependency minitest? [Yn]  Y
Install required dependency hoe? [Yn]  Y
Successfully installed rubygems-update-1.3.5
Successfully installed session-2.4.0
Successfully installed hoe-seattlerb-1.2.1
Successfully installed hoe-2.3.3
Successfully installed rubyforge-2.0.0
Successfully installed minitest-1.4.2
Successfully installed hoe-2.3.3
Installing ri documentation for rubygems-update-1.3.5...
Installing ri documentation for hoe-seattlerb-1.2.1...
Installing ri documentation for hoe-2.3.3...
Installing ri documentation for rubyforge-2.0.0...
Installing ri documentation for minitest-1.4.2...
Installing ri documentation for hoe-2.3.3...
Installing RDoc documentation for rubygems-update-1.3.5...
Could not find main page README
Could not find main page README
Could not find main page README
Could not find main page README
Installing RDoc documentation for hoe-seattlerb-1.2.1...
Installing RDoc documentation for hoe-2.3.3...
Installing RDoc documentation for rubyforge-2.0.0...
Installing RDoc documentation for minitest-1.4.2...
Installing RDoc documentation for hoe-2.3.3...
Updating version of RubyGems to 1.3.5
Installing RubyGems 1.3.5
RubyGems 1.3.5 installed

n++=== 1.3.5 / 2009-07-21

Bug fixes:

* Fix use of prerelease gems.
* Gem.bin_path no longer escapes path with spaces. Bug #25935 and #26458.

Deprecation Notices:

* Bulk index update is no longer supported (the code currently remains, but not
  the tests)
* Gem::manage_gems was removed in 1.3.3.
* Time::today was removed in 1.3.3.

------------------------------------------------------------------------------

RubyGems installed the following executables:
        c:/ruby/bin/gem

RubyGems system software updated

 

Then you may install rails:-

C:\Documents and Settings\VSanzgiri>gem install rails --remote
Successfully installed rack-1.0.0
Successfully installed actionpack-2.3.4
Successfully installed actionmailer-2.3.4
Successfully installed activeresource-2.3.4
Successfully installed rails-2.3.4
5 gems installed
Installing ri documentation for rack-1.0.0...
Installing ri documentation for actionpack-2.3.4...
Installing ri documentation for actionmailer-2.3.4...
Installing ri documentation for activeresource-2.3.4...
Installing ri documentation for rails-2.3.4...
Installing RDoc documentation for rack-1.0.0...
Installing RDoc documentation for actionpack-2.3.4...
Installing RDoc documentation for actionmailer-2.3.4...
Installing RDoc documentation for activeresource-2.3.4...
Installing RDoc documentation for rails-2.3.4...

The tutorial assumes you have installed sqlite3 adapter. If not then you will have to modify /cookbook/config/database.yml to point to mysql installation.

Wednesday, September 30, 2009

Ruby

I am capturing some conversation from JavaRanch on Ruby:-

Performance Ruby v Java

Ruby vs Java


It would take 5 min to read this as well.

Why Ruby?

Ruby is a strongly, but dynamically, typed, "dynamic," object oriented programming language. That's the official spiel but I suspect that's just a list of buzzwords to many. Being practical, if you're familiar with Python, it's a little like that in terms of its scope (i.e. not high performance, can be used as a "scripting" language, object oriented). Ruby is often called a "pure" object oriented language because everything is an object. This is not strictly true (e.g. a lot of the basic syntax isn't OO) but is a good way to compare it with other languages.

Ruby isn't verbose (if you consider Java to be a 7 out of 10 on the verbosity scale, Ruby's perhaps a 2) and it "gets out of the way" and lets you simply code your logic and features with as little architectural work as necessary (of course, if you want to, you can write Ruby in a very anal way, but it's not necessary to start with).

Inspiration (similar languages)
Python is quite similar to Ruby in some ways, but it's not quite as dynamic and consistent. Ruby takes a lot of influence from Smalltalk, so that's going to be quite similar too.

Major Projects
The Human Genome project uses Ruby and RoR. Check out some slides on the project here
. See this list of some companies that use Ruby/Rails. Frank Carver used a great quote describing Ruby (low ceremony). Ruby feels a lot less like "coding", and more like "trying out ideas".

As far as the Rails framework itself, it's a lot of the things you DON'T do:

configure the webapp
parse xml to objects/ objects to xml/json/html
write a ton of validations
type and tune a bunch of SQL (DDL or queries)
hand-write Ajax or Prototype
bind form elements, parse URL parameters
spend time searching for existing solutions only to have to search out their dependencies (this jar needs these three jars which need...)
pluralize, singularize, capitalize, camelize, humanize, turn into a sentence, format date and time
configure dev v test v prod environments


Plus, you get a lot of advantages that come with using Rails (or gems along with rails):

restful services/web-app urls
easy gem integration
great testing support (unit, functional, integration, performance)
rails application bootstraps (boostrap a: social media site, blog, etc)
a vibrant community
ever expanding platforms (JRuby/Java, IronRuby/.net, etc)
unobtrusive JavaScript (soon)
deployment with capistrano

IDE Support
Aptana RadRails is probably the way to go. It's based on Eclipse. Despite the name it's not just for Rails development and can be used for pure Ruby development if you want. It's a reasonable IDE as long as you like Eclipse

More celebrated is JetBrains' (of IntelliJ IDEA fame) RubyMine but it's a commercial product. I suspect a lot of Java-heads will love it though, and it gets the best reviews overall. I don't use it because I'm cheap.

Ruby In Steel is definitely a good option on Windows. I've given it a go and it feels really nice. Despite not being a Windows user anymore, I still appreciate how well constructed Visual Studio is I wish there were an IDE as good as VS on other platforms. Eclipse just doesn't cut it for me.

Testing
There are a lot of ways to do testing, load testing, and Web application testing from Ruby. The Ruby community seems to be a little bit nuts over testing - almost religious about it - so the number of testing libraries is.. quite large for the size of the community ;-)

One of the best known libraries is Watir. To steal some info: "Watir is an open-source library for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible. Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page. Watir is a family of Ruby libraries. They support Internet Explorer on Windows, Firefox on Windows, Mac and Linux, Safari on Mac, Chrome on Windows and Flash testing with Firefox."

There's also an attempt to port Selenium to Ruby.

If you want something that's lower level and doesn't rely on a browser, there's also WebRat which provides an API for mechanizing Web requests and browser features using Ruby methods. With this you can put together scripts to perform whatever actions are necessary on your sites.

Deployment and Hosting

"Deploying Rails Applications: A Step-by-Step Guide by Ezra Zygmuntowicz, Bruce Tate, and Clinton Begin" is a popular book to understand the deployment process in detail. Here is another link to understand deployment process in Ruby-on-Rails application. Either you use JRuby or not. Mongrel and Apache are the popular Web Servers I know. This link describes the Popular Web Hosts for Rails

Passenger, a.k.a. mod_rails or mod_rack, is the most common way to deploy Rails (and other Ruby web framework) applications nowadays. It works on both Apache and nginx. It's reliable, good with memory, and runs like a champ. It's easy to install on your own Apache-powered server, of course, but some shared hosts run it too, such as Dreamhost. An older technique is to use fcgi/FastCGI. Most hosts are moving to Passenger, but it's still possible to deploy apps via FastCGI and on some setups it works just great.

Conclusion
If Rails is the drug, Ruby is the addiction!!

Resources

  1. http://www.javapassion.com/rubyonrails/ruby_jruby.pdf
  2. http://www.coderanch.com/forums/f-97/Ruby (JavaRanch Ruby Forum)

Monday, September 28, 2009

Google Docs now performs OCR!!

Google is constantly working on new features for their online services like Gmail or Google Docs. The latest feature is currently available as a demonstration only and not yet integrated into Google Docs. The Google Docs OCR demonstration can OCR the three digital image formats jpg, png and gif. Google lists the following limitations that are currently in place:

  • Files must be fairly high-resolution — rule of thumb is 10 pixel character height.
  • Maximum file size: 10MB, maximum resolution: 25 mega pixel
  • The larger the file, the longer the OCR operation will take (500K: ~15s, 2MB: ~40s, 10MB: forever)

You can upload an image containing typewritten or printed text (like a fax document or a scanned newspaper clipping) to your Google Docs account and it will turn that image into editable text. The quality depends largely on the quality of the image. It is usually necessary to look over the text and correct errors that have been made during character recognition. Google Docs helps in the error correction by underlining unknown words in red in its interface. It still takes some time to correct the errors.

I am providing steps to get started and sample image provided by Google. Here is a sample form to upload scanned images to your Google Account and the server will automatically try to extract text from these images provided the image resolution is good and that the text inside images is written using Latin character sets.

image

 

image

image

HTTP.jpg provided by Google for testing

HTTP

 

Unfortunately, when I tried it I received the following error:-

Error processing document:
Expected response code 200, got 400 <?XML:NAMESPACE PREFIX = [default] http://schemas.google.com/g/2005 NS = "http://schemas.google.com/g/2005" />GData InvalidEntryException Could not convert document.

 

Invalid file

Please chose a JPG, GIF or PNG file not larger than 10 MB/25 mega pixel.

The OCR feature can also extract text from noisy images as well (like this WSJ clipping) though the recognized text is not very accurate and the document formatting is lost (see conversion results).

If you are a developer, you can add the ocr=true parameter to your upload request and Google Docs will automatically scan that image for text patterns. You can also upload images to Google Docs without the OCR parameter but in that case, the image will be converted into a new Word document minus OCR.

Like Google Docs, Google Search too includes OCR features but the difference is that while Google Docs can extract text from images, the OCR in Google Search works only with scanned PDF files.