Monthly Archives: May 2008

Favourite Parts of England

With an increasing push for Ephox to have a European presence based out of England, I’ve been reflecting on some of my favourite things of my time there. These are the bits that are slightly more uniquely me, than the standard tourist things. Out of the varied experiences and things to do in London and the UK, these are some of my favourites.

All Souls

Christianity and church is an essential part of life for me. Finding All Souls was a great discovery, and the times and people there form some of the fondest memories of our time in London. Before going there I had no idea how good pipe organs could sound. I was also thankful for the opportunity to be a part of Christianity Explored, and some of the other ministries of the church. It was great hearing John Stott preach, and we were also blessed and challenged by the other preachers there. I still listen to sermons from their sermon library (which dates back to 1966), which is available online (All Souls Sermon Library).

British Library

Of all the great museums, historical and cultural places and sites, my favourite was the British Library. It was great to go and see some of the extant manuscripts, especially some of the early new testament artefacts. Seeing some of the early versions of Beetles songs, some of Leonardo DaVincis writings, and Handels work was cool too.

Bletchley park

I took a trip to Bletchley Park one week-end with my Dad. Given Dad’s background in Cryptology, and my interest in IT, and security, visiting the home of where the British government was attacking German ciphers in World War 2 was a must. It was great to be able to go around on a tour and see the rooms which were filled with people attacking Enigma codes, and to see where the first computer was created by Turing. The computer history museum they had there was cool too.

Cheap Flights

Ryanair and similar flights for a penny + taxes are too hard to refuse. Even though you end up miles from anywhere, and have to pay for transport to obscure airports at both ends, as well as taxes the trips are good for a week-end, and are a real part of the England experience. It really is worth doing this at least once, and taking advantage of these cheap flights for a great week-end away.

Travel

On the subject of cheap flights, travel generally is an Aussies initial reason to go to London. It is definately worth doing a fair bit while there. If nothing else, going on organised trips makes for a decent way to see different places. Suzanne and I ended up doing a bunch of travel with Oak Hall, visiting Turkey, and doing their Europe tour. Their holidays have a bit of a reputation for being a place for singles to meet, but Suzanne and I had fun as the old married couple :).

Cosmopolitan Living

We lived in inner London, on the tube, and definitely enjoyed being in the centre of it all. Staying on top of a French Patisserie was definitely nice, as was the Organic Butcher next door.

Overall I have many fond memories of life in London, and would definitely recommend the experience.

Fixing Intermittent Table Not Found Errors with JUnit when Using Hibernate SchemaExport and H2

As a part of my test suite, I run a series of tests using Hibernate and the h2 database (h2 seems to be the most lightweight java in memory database around at the moment). These tests run in memory and perform realively quickly, so are a part of my pre-commit build.

In order to move to a spot where the application upgrades work well, I’ve just removed the hbm2ddl.auto create-drop statements from my hibernate.xml file, and wanted to move to a programmatic use of the SchemaExport tool. This was more pain than expected, so I’m documenting what I had to do here.

From the javadoc, and Java Persistence with Hibernate, it looks like you can get away with the following code:

1: Configuration configuration = new Configuration().configure();
2: SchemaExport schemaExport = new SchemaExport(configuration);
3: schemaExport.create(false, true);

Unfortunately I found that this didn’t quite work. It seems that the connection/transactionality/connection pool combination of concerns would cause this kind of code to fail at various degrees. After much gnashing of teeth I ended up with the following code:

1: Configuration configuration = new Configuration().configure();
2: SessionFactory sessionFactory =

         configuration.buildSessionFactory();
3: Session session = sessionFactory.openSession();
4: Connection connection = session.connection();
5: SchemaExport schemaExport =

          new SchemaExport(configuration, connection);
6: schemaExport.execute(false, true, false, true);
7: session.close();

the critical differences are:

In lines 2-4 we are obtaining a connection to the database which is then used by the schema export tool. In line 6 we do the export using the execute command, passing in a bunch of booleans. This tell it execute command:

  • don’t output the sql to the console,
  • do execute on the database,
  • don’t execute drop statements, and
  • do execute create statements.

Finally in line 7, we close the session, ensuring jdbc connection is released and cleaned up. Now any intermittent problems caused by using schema export with h2 database should be avoided.

Automating Deployment to IBM WebSphere Portal

Having an automated deployment procedure is an important goal for any project. This post talks about the the steps taken in making E2 autodeploy to WebSphere Portal in Development.  The below process assumes that the application has been deployed once through other means.

After a friendly pointer from AJ to an article about automating websphere deployment, I decided that the time had come to revisit trying to automate the deployment of our EAR file for E2. I had done bits and pieces of thi in the past using a combination of the WebSphere scripting client, and the WebSphere ant tool (like ant but built with WebSphere bits and pieces). The killer constraint for me is that my client machine didn’t have access to any of the WebSphere binaries (perhaps unsuprisingly Apple and IBM have don’t perfectly interoperate).

In order to work around thi sproblem I ended up leveraging one of the classic protocols (telnet), the websphere scripting client, samba (to mount the application server drives), and a bit of ant to glue it all together. The process outlined below is focused around the deployment of the application E2Application to WebSphere portal.

Step 1: Enable telnet

In Windows Server 2003 this is relatively straightforward. Simply go to your control panel -> services -> Telnet go to the properties, make it automatic and start it.

Step 2: Write scripts to start and stop the app server

I did this using tcl and ended up with the following scripts (the pythonistas may like to use jython to do the same):

stopApplication.jacl  

set cell [$AdminControl getCell]
set node [$AdminControl getNode]
set appManager

   [$AdminControl queryNames
   cell=$cell,node=$node,type=ApplicationManager,process=WebSphere_Portal,*]
$AdminControl invoke $appManager stopApplication E2Application

startApplication.jacl  

set cell [$AdminControl getCell]
set node [$AdminControl getNode]
set appManager

    [$AdminControl queryNames
   cell=$cell,node=$node,type=ApplicationManager,process=WebSphere_Portal,*]
$AdminControl invoke $appManager startApplication E2Application

Step 3: Write the ant code to compile and copy the application

After the series of standard building tasks, we used a simple copy task to copy the files to the exploded WAR directory on the server. (something like: ${portal.home}/WebSphere/profiles/wp_profile/installedApps/{cell}/{application}.ear/{app_war}.war). Since I develop on a laptop I added in a combination of available and fail task to stop me from accidently creating directories if I hadn’t mounted m

Step 4: use ant to telnet to the server

Make use of the telnet ant task1 to telnet into the server, and run the stop and start server jacl scripts. My Ant targets (passwords scrubbed) are below (excuse the duplication):

<target name="startApplication">
   <telnet userid="Administrator" password="${portal_admin_password}" server="${portal_server}">
   <read>Administrator</read>
        <!– change to the IBM AppServer directory –>
        <write>cd \ibm\AppServer\bin</write>
        <read>AppServer\bin</read>
        <!– Execute the jacl –>
        <write>wsadmin -conntype SOAP -port 10033
                -username wasadmin -password **** -f startApplication.jacl
        </write>
        <!– wait for the connected to process message, which will occur on the successful completion of the script –>
        <read>Connected to process</read>
        <read>AppServer\bin</read>
    </telnet>
</target>


<target name="stopApplication">

    <telnet userid="Administrator" password="${portal_admin_password}" server="${portal_server}">
        <read>Administrator</read>
        <!– change to the IBM AppServer directory –>
        <write>cd \ibm\AppServer\bin</write>
        <read>AppServer\bin</read>
        <!– Execute the jacl –>
        <write>wsadmin -conntype SOAP -port 10033
                -username wasadmin -password **** -f stopApplication.jacl
        </write>
        <!– wait for the connected to process message, which will occur on the successful completion of the script –>
        <read>Connected to process</read>
        <read>AppServer\bin</read>
    </telnet>
</target>

Step 5

mix ingredients and enjoying being able to have a one click deploy to WebSphere Portal.

Appendix

For security paranoid people with time on their hands, it is possible to do this using ssh and scp. The key parts will be step 3 and step 4. In step 3 we are using folder share and the ant copy task currently. It could be done with scp. In step 4 the use of telnet could be replaced with ssh.

1 – The telnet task depends on the availability of the commons-net jar on the classpath. (click here to download commons-net).?

Setting up Oracle XE to work with IBM WebSphere Portal IWWCM

In order to make the Oracle XE database work with IBM WebSphere Portal IWWCM there are a number of steps to perform.

  1. Ensure that the database is accessible using the Oracle SID (see the early post Oracle SID!=Service name)
  2. Next you will need to increase the number of proceses that can be connected to the instance, as there are a large number of connection pools set up by the system, which the database will need to support. The following command worked in my environment:
        ALTER SYSTEM SET PROCESSES=150 SCOPE=SPFILE;
  3. After having performed these base setup commands and options, you can run the IWWCM migration scripts to migrate existing data.
  4. To ensure that the connection pooling works correctly, you will need to grant the following privileges to public:

    grant select on pending_trans$ to public;
    grant select on dba_2pc_pending to public;
    grant select on dba_pending_transactions to public;

  5. Finally, grant the following privilege to each user to which connections are made from the application server.
        grant execute on dbms_system to <user>;

After having performed these steps you will have an Oracle XE database that will work happily with IWWCM.

HTTP Authentication in a URL

When reading through the Selenium FAQ, I noticed a piece of coolness that I didn't know existed in HTTP Authentication (Selenium FAQ – authentication).  RFC 1738 specifies the following scheme for specifying authentication information in a url //<user>:<password>@<host>:<port>/<url-path>.  I have been familiar with this for commanline based protocols (ftp/telnet and their secure equivalents) but didn't realise that it would work in a browser. In a browser you can specify http://user:password@server:80/path to do basic http authentication. While this ia a bad idea for usernames and passwords in real applications, it is a great tool for development purposes.  My firefox speeddial plugin now has development pages specified in this way.

Of course this approach is not a silver bullet, and other tools are needed. I have used this technique to access websphere portal and webapps hosted on a WebSphere Portal server, as well as applications using HTTP Authentication on Tomcat Servers. Unforutnately it doesn't work with the WebSphere administration console, but thankfully you can simulate the form based login using the following type of url: https://serverName:10039/ibm/console/secure/securelogon.do? action=secure&j_username=username&j_password=password 

The combination of //<user>:<password>@<host>:<port>/<url-path> tye urls, and faking login forms, makes it possible to access most web urls very quickly in a browser environment. 1

1 -Internet explorer doesn't support this for recent browsers (see: http://support.microsoft.com/kb/834489) ?

Real Programmers

There is always a bit of a culture in IT (is that an oxymoron?) around macho programmers.  Real programmers use VI/EMACs etc.   It is always fun to read some of the interesting stories, and urban legends around real programmers, basically all taking variations of the Monty Python "We were poor" sketch

The Story of Mel is one of my favourites, only upstaged by the tooltip on this XKCD Comic on Real programmers.

What's your favourite story (real or made up) of real programmers?

Memory Settings for Eclipse on OSX

For the regular readers of my blog, you may be wondering why I am stepping over to the dark side, and using Eclipse. Not to fear – it is just for an Eclipse plug-in. Using the right tool for the right job is important to always do.

When recently using the SAP Memory Analyzer tool to look at a large (1GByte) hpprof output file, I was running out of Heap space, so was lookin for where to set the -Xmx and -Xms settings on Eclipes. It was somewhat harder to find than desired, and the internet didn’t tell my as quickly as I wanted, so here’s the answer (while the video at http://www.brooksandrus.com/bog_assets/screencasts/eclipsejvmheap/ was cool, a simple text blog entry would have made me happy).

The eclipse.ini file in Eclipse.app/Contents/MacOS is the file that needs to be edited. (not the one that for me was close in location /Applications/eclipse/configuration/ eclipse.ini was bad, /Applications/eclipse/Eclipse.app/Contents/MacOS/ eclipse.ini was good).

After finding the right eclipse.ini, setting the memory is straightfoward. Simpley update the -Xmx and -Xms settings (see: The Sun Tuning java guide for what these do if you don’t know).

Using BeanShell for Enterprise Development

BeanShell promises lightweight scripting for Java. Support for BeanShell is included with the Apache ant build tool, and it is targetted to be included as a part of the standard edition of Java with JSR-274. I’ve recently included BeanShell in a project, and will share what I have achieved with this, and some of the motivations and considerations when doing this.

My primary reason for adding BeanShell was that we use some heavy enterprise APIs. We are able to mock these out for development, but have experienced consistent issues when working with the APIs, primarily caused by missing or misleading documentation. This means that there is often a need to write code to understand the APIs. To deploy to the application server takes about 3 minutes, and the wrestling required to make the code work is often much more painful that expected. It is pain which motivates the creation of some nice tools, and this pain motivated the creation of a simple tool using BeanShell.

In it’s simplest form, the tool allows the execution of code on the server that has been input into a text area. This is a powerful tool for developers and admins, but is somewhat (ok very) risky from a security standpoint, and needs to be treated as such.  Getting BeanShell up and running is really straightforward.  I've only got a couple of recommendations and comments to make about doing so.

  1. Integrating BeanShell itself is really straightforward. Simply have a servlet (action/jsp/whatever) which reads in a request parameter, uses an instance of the beanshell interpreter class to eval the string. The quickstart guide makes it clear and easy to get started (makes it quick to start :) ).
  2. In order to make the interpreter useful, you will want to have add imports of the important packages for your application (such as to your Data Access Layer), and also the set some variables on the context. Prepend the imports to the scripts before they are eval'ed, and set the variables using the interpreter set(String, Object) method.
  3. In addition to the result of the script, and the application variables that I put on the interpreter, I also add in a PrintStream, making it easy to output debug information.
  4. Finally, it is really useful to keep track of what statements have been executed, and the results of the statements.  Save these to the session, and list these on the page. A simple javascript function makes it possible to replace the contents of the text area with previous scripts, and also the output, and result messages.  This rounds out a simple little tool nicely.1

By doing this, it is possible to explore APIs, and work at a very quick pace. Whenever something behaves unexpectedly on the server, one can quickly explore what has happened, and produce the updates to production code, which are required to make this work. BeanShell is a powerful tool for serverside development, and well worth considering adding to your toolkit.

1 – for extra credit, it is really easy to keep a list of previous statements on the page, and use the javascript above to keep track of the history.?