Mar 26 2008

Gwt-Ext screencasts on showmedo.com

Tag: Ext, Gwt, Java, Programming, Ubuntu, WebAbhijeet Maharana @ 11:23 pm

In addition to hosting the Gwt-Ext screencasts at http://gwt-ext.com/screencasts/, Sanjiv has also made them available at showmedo.com. So you can watch them online without having to download first.

Here are the direct links:

  1. Setup GWT and Cypal studio in Eclipse on Ubuntu
    http://showmedo.com/videos/video?name=2040000;fromSeriesID=204

  2. Add Ext and Gwt-Ext to the project
    http://showmedo.com/videos/video?name=2040010&fromSeriesID=204

  3. Add basic client side regex validation, remote service and save form data in Oracle database
    http://showmedo.com/videos/video?name=2040020&fromSeriesID=204

Download Eclipse projects shown in the screencasts from Gwt-Ext.com or Rapidshare.

Thanks Sanjiv for the appreciation. And more importantly, for putting in lots of hard work to produce Gwt-Ext.


Mar 17 2008

Gwt-Ext screencasts for beginners

Tag: Ext, Gwt, Java, Javascript, Links, Linux, Maps, Programming, Ubuntu, WebAbhijeet Maharana @ 8:51 pm

I have started out with Gwt-Ext and thought I will record some screencasts. These are for beginners who may need a hand when they are starting out and are anxious to jump right into code. The screencasts have been recorded on Ubuntu Feisty with Eclipse Europa.

There are 3 screencasts in avi and ogg format.

  1. First screencast shows the installation of Gwt 1.4 and Cypal Studio for Gwt. Cypal Studio is an Eclipse plugin that automates most of the tasks associated with GWT like adding a module and adding a remote service. In the screencast, I create a Gwt project using this plugin.
  2. Second screencast shows how to add the ExtJS Javascript library (2.0) and Gwt-Ext Java library (2.0.1) to the project. In the screencast, I create a simple Ext form with some text fields and a button.
  3. Third screencast (added on March 22) shows how to send form data back to the server. In the screencast, I validate form fields using regular expressions / Ext Vtype, add a remote service and then save form data in an Oracle database using the remote service.

    You can read this post for installing Oracle 10g XE on Ubuntu Feisty.

All screencasts are hosted at Rapidshare. Sanjiv Jivan, the author of Gwt-Ext has offered to host them at gwt-ext.com. I think the files are quite big and I am not well-versed with audio/video formats and parameters. If you know any way to reduce file size while maintaining the quality of screencasts, do let me know.

Download screencasts from Rapidshare.
Download Eclipse projects shown in the screencasts from Gwt-Ext.com or Rapidshare.

Update:
Sanjiv has been kind to host them at http://www.gwt-ext.com/screencasts/.
I have also edited the gwt-ext wiki accordingly. (See comments)

Related links:
Google Web Toolkit
ExtJS Javascript library
Gwt-Ext
Cypal Studio for Gwt


Jan 21 2008

OpenOffice woes

Tag: Linux, UbuntuAbhijeet Maharana @ 9:10 pm

I am running Ubuntu 7.04 - Feisty Fawn. Applications from OpenOffice.org 2.2 crashed on my face with the error message:

The application cannot be started.
An internal error occurred.
OpenOffice.org 2.2 error

On running it from a terminal, it became evident that the problem was with user settings

$ oowriter
[Java framework] Error in function createUserSettingsDocument (elements.cxx).javaldx failed!
GTK Accessibility Module initialized
[Java framework] Error in function createUserSettingsDocument (elements.cxx).GTK Accessibility Module shutdown
 
** (process:9274): WARNING **: Unknown error forking main binary / abnormal early exit ...

A search for “Error in function createUserSettingsDocument (elements.cxx).javaldx failed!” led me to this thread where the answer was in the 6th post:

Become root, delete “/home/<username>/.openoffice.org2″ and then start OpenOffice. The folder is recreated and all works well.


Jan 07 2008

Ubuntu Feisty + Squid proxy

Tag: Linux, Ubuntu, WebAbhijeet Maharana @ 12:43 am

I have a LAN at home and one of my machines is connected to the Internet. I wanted to share this connection with the other machines.

When I had Ubuntu Edgy earlier, I had set up Internet Connection Sharing, referring this thread at Ubuntuforums.org. Now I am using Feisty and thought I will set up a proxy server this time. So I went with Squid. My installation log (for plain http access) is given below.

  1. Install Squid. Open a terminal and type
  2. sudo apt-get install squid
  3. Set visible_hostname
    If you got the below error message after installation, you will need to set visible_hostname.
  4. FATAL: Could not determine fully qualified hostname.  Please set 'visible_hostname'

    Edit /etc/squid/squid.conf as root and add a hostname (line 2899 on my system - line numbers are wrt the config file that is created when Squid 2.6.5-4 is installed from the Feisty repository)

    visible_hostname newpc
  5. Grant access to machines on your LAN
    Add the following lines to squid.conf to create an acl and grant http_access to it (you can find a commented example around line 2590 in this file). Replace the IP address range as required.

    acl my_network src 192.168.1.0/24
    http_access allow my_network
  6. (Re)start squid
    sudo /etc/init.d/squid restart

Now you can point the browsers on your LAN machines to port 3128 on the machine where squid is running.


Dec 29 2007

Command not found … do the following!

Tag: Linux, UbuntuAbhijeet Maharana @ 11:04 pm

I was working with a script and had to do a quick float calculation. I knew Accessories >> Calculator but wanted a command line utility. Struggling to remember the syntax for using bc, I tried

$ bc 2.38987 + 5.43534
File 2.38987 is unavailable.

Not quite amused with the response, I was wondering if it always has to be as geeky as

echo 2.38987 + 5.43534 | bc

or

bc -i
2.38987 + 5.43534

and not something like

calc 2.38987 + 5.43534

I happened to type ‘calc’ and hit return without really thinking about it, and Ubuntu promptly reported

The program 'calc' is currently not installed.  You can install it by typing:
sudo apt-get install apcalc
Make sure you have the 'universe' component enabled
bash: calc: command not found

I was impressed! It doesn’t just tell me “command not found” but also tells me how to enable it to find it! Given Ubuntu’s packaging and software repository system this may be simple to achieve but these “simple” little things are what make exploring Ubuntu a joy. I took my OS’s advice and in no time I was using “calc 2.38987 + 5.43534″ (I am using Ubuntu 7.04).


Dec 22 2007

Oracle 10g XE + Java on Ubuntu Feisty

Tag: Database, Java, Linux, Programming, UbuntuAbhijeet Maharana @ 3:30 pm

I needed a basic database on my Ubuntu Feisty system and decided to try out Oracle 10g Express Edition. The installation is pretty straightforward. Below is a log of what I did to get it running along with Java code to access the database.

My Setup:

  • AMD 3600+ 64 bit running Ubuntu 7.04 32 bit
    (2.6.20-15-generic kernel)
  • 2GB RAM

Download the .deb file for Oracle Database 10g Express Edition for Linux x86. I have oracle-xe_10.2.0.1_i386.deb which is a bit old now. The official installation guide is located here.

The installation steps are as follows:

  • Step1: Requirements and installation
    In short: 1.5 GB of disk space, 512 MB of RAM with 1GB swap. The Express Edition can use a maximum of 1GB of RAM even if more is available. The minimum and recommended requirements for installation can be found here . The installation went fine on my machine with 2GB of RAM and no swap space.

    Run the .deb. You may need to be connected to the Internet for the dependencies. The installation creates shortcuts under the Applications menu. However, we don’t need to use any at the moment.

    screenshot

  • Step2: Configuring the database
    Run

    sudo /etc/init.d/oracle-xe configure

    Use the default settings for Oracle Application Express (8080) and the database listener (1521) or change the ports if you have other servers using these ports.

    Enter the SYS/SYSTEM password. I used ‘manager’.

    Select ‘n’ for the option for starting the database at boot time since we can conveniently do the same using the created menu items. [See the troubleshooting section below]

    screenshot

    The user starting or stopping the database must be a member of the ‘dba’ group. This can be done from [Gnome Menu] >> System >> Administration >> Users and groups >> Manage groups. Select ‘dba’ and click on properties. Select user(s) to add them to this group.

  • Step3: Administration using the web interface
    Log into Application Express by hitting the URL http://127.0.0.1:8080/apex
    Enter SYSTEM / [password you had entered earlier]. There is a built-in user account HR which needs to be unlocked before it can be used. But, we will create a new account for our use.
    Goto Administration >> Database users >> Create user
    Enter ’scott’ / ‘tiger’ for the username / password and click Create.

    screenshot 1 | screenshot 2

    Log out and log in again as scott.

  • Step4: Create test tables
    Create a table

    • using the object browser
      Object browser >> create >> table

      screenshot 1 | screenshot 2

    • using a SQL Query
      SQl >> SQL Commands >> Enter Command
      You can enter multiple statements in the editor and execute one statement at a time by selecting a statement and hitting CTRL + ENTER.
      CTRL + ENTER works out of the box on Firefox 2.0.0.3. On Opera 9.24, you may need to change some settings. At this point I can’t say what.

      screenshot 1 | screenshot 2 | screenshot 3

  • Step5: Access database from Java

    Save the following code as OracleJdbcDemo.java. It prints values from the first column.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    import java.sql.*;
     
    public class OracleJdbcDemo
    {
    	public OracleJdbcDemo() throws Exception
    	{
    		Class.forName("oracle.jdbc.OracleDriver");
    		String connString = "jdbc:oracle:thin:@localhost:1521:XE";
    		Connection conn = DriverManager.getConnection(connString, "scott", "tiger");
    		Statement stmt = conn.createStatement();
    		ResultSet rs = stmt.executeQuery("select * from student");
    		while(rs.next())
    		{
    			System.out.println(rs.getString(1));
    		}
    	}
     
    	public static void main(String args[]) throws Exception
    	{
    		new OracleJdbcDemo();
    	}
    }

    Compile and run the code by supplying the ojdbc14.jar file in the classpath:

    $ javac OracleJdbcDemo.java
    $ java -cp "/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/jdbc/lib/ojdbc14.jar":. OracleJdbcDemo

    If you have downloaded and installed a JDK yourself, make sure the compiler and interpreter are both from the same installation.
    I have JDK1.6.0 installed on my system and this is the entry in my /home/abhijeet/.bashrc

    export JAVA_HOME="/apps/java/jdk1.6.0"
    export PATH=${JAVA_HOME}|>/bin:${PATH}|>



Troubleshooting


I came across a situation where just after the installation everything worked fine but after a reboot, neither http://localhost:8080/apex nor the Java program worked. However, the database was starting and stopping from the menu options as I was able to connect using the “Run SQL Command Line” utility found in the menu. First few lines of the exception thrown by the program are shown below:

Exception in thread "main" java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
...

I had answered “no” to start the database at boot time since I didn’t want it running when I am not using it. This may or may not be related to the problem above and I did not reinstall selecting “yes” to check.

After searching a little, this is what worked.
Register environment variables and start TNSLISTENER:

$ . /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh
$ sudo /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/tnslsnr

If you get the following error after the first command

/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh: 114: [[: not found
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh: 114: [[: not found

then edit /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh and change the first line from

#!/bin/sh

to

#!/bin/bash

Wait for sometime after starting the listener and both the web interface and Java program should start working.

[Reference: Oracle forums]