Posts

Showing posts from 2013

Using Selenium WebDriver to select JSF/PrimeFaces selectOneMenu options

I'm using JBehave with Selenium WebDriver to test my PrimeFaces (JSF2) application. Selecting an option from a SelectOne option list isn't standard though because of the HTML markup generated by the JSF component. The facelets code to place the selectOneMenu uses the ID 'state': This generates HTML div blocks with id's prefixed with this components id: To select an option, I use a method which manipulates the appropriate divs - this can be used as illustrated below: To reuse this type of utility method, I put it in a base Page Object class:

Some user feedback

I was exporting my banking transactions the other day. It's a much more tedious process than it has to be and after using this for years and not seeing any updates to the site I thought I'd send some feedback - written as stories: As an Online Banking Customer, I want the system to remember my export preferences so that I can efficiently export my transactions ­  currently I have to set everything every time (even if you navigate from a selected account, you still have to pick an account) ­  file format (i.e CSV) ­  date format (dd/mm/yycc)  As an Online Banking Customer, I want to export transactions for all my accounts in one go so that I can efficiently export my transactions ­ so I don't have to do them one at a time ideally multiple accounts in one file  As an Online Banking Customer, I want to be able to access more than 12 months worth of transactions so that I don't have to export so often. ­  not much history is available online ­and transac

Exposing the version of your Maven built web application

Sometimes its useful to expose the version of your web application - I find it useful so vsConsole can display the version of the deployed application for each environment on the dashboard. If you build your app with Maven, you can use this code to get the version, and simply wire up a controller/rest endpoint to return it as text/plain. To expose the version of your maven built spring web application, you can use a REST controller like that shown below. Note, you won't see a valid version while running in the IDE - it'll only work when running the Maven built WAR. If you want to add the Jersey dependencies to your spring application try using the following dependency declaration.

Avoid embedding database connection information in your code

I've seen projects where the application code base contains database connection information - passwords and all, or, WAR files are rebuilt for each environment with properties substituted appropriately for the target environment. Rather than putting database information in the application code, it makes more sense to use a JDNI data source provided by the container. This way the exact same application code is deployed to all environments, and we don't encounter any exposed passwords - since the owner of the container (in production environments the infrastructure/support team) define the data source themselves. Database access via JNDI data source in Tomcat In your application server you want to define a data source which points to the database server and schema of your choice. Here, I'm using the H2 database , and assuming this is the DEV Tomcat server, I point it to the DEV schema - define this resource in the Tomcat context.xml :  <Resource name=" jdbc/

Deploying to Tomcat 7 with Maven

It's sometimes nice to be able to update a development Tomcat 7 server from Maven - this makes it simple to hook automatic deployment into a CI server or just update the dev server as a developer. First, the Tomcat manager application needs to be installed (check Tomcat's webapps directory for the manager application) and configured with the appropriate user credentials: Now, I needed to define the server admin credentials in my maven settings (~/.m2/settings.xml): Then, I updated the POM to configure the maven tomcat plugin : Now, using 'mvn tomcat7:redeploy' lets me update the dev server. Note however, on Windows you may have some problems with undeploying the application - after an undeploy command, some jars may be left over in the webapps/appname directory. When you try to redeploy your app you'll see an error containing " cannot invoke tomcat manager fail - unable to delete... ". To work around this, you can change the TOMCAT_HOME/

Exception: AbstractMethodError requires c3p0 upgrade

Image
photo credit: markchadwickart via photopin cc I just encountered this exception: Exception in thread "main" java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V at org.hibernate.type.descriptor.sql.ClobTypeDescriptor$4$1.doBind(ClobTypeDescriptor.java:114) at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:92) It turns out that upgrading c3p0 does the trick (from 0.9.1.2 to 0.9.2.1):         <dependency>             <groupId>com.mchange</groupId>             <artifactId>c3p0</artifactId>             <version>0.9.2.1</version>         </dependency>

Week in Review - 2013-16

Print to Google Drive I just noticed 'Save to Google Drive' in my 'Print' options in Chrome! This is awesome - when you want to save something for reference, and you don't want to go through thousands of bookmarks, this is exactly what I wanted! Media Problems Here is a great blog post about trying to find a decent movie streaming service. Now I have FetchTV (this lets me buy movies to stream, much like the Google Play option) I'm considering turning my MythTV media center off, but I still need an option for playing music/displaying photos/etc. There are lots of options, from AppleTV to Western Digital et al media players. Props to Google for actually selling us here in Australia movies and music - unlike Amazon (we still can't buy movies and music from Amazon in 2013). Andrew Chen quits RSS - WTF! Andrew Chen just announced that he's quitting RSS in favour of email notifications. Look at the comments though, and there isn't a single p

AspectJWeaver with JDK 7 - error - only supported at Java 5 compliance level or above

I came across this problem with an older project - when I switched from jdk6 to jdk7, when the application started I encountered: nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException:   error annotation type patterns are only supported at Java 5 compliance level or above I didn't want a purely maven solution because during development I run the app in Tomcat via the IDE (Intellij IDEA). In the end I just upgraded my aspectjweaver dependency to 1.7.2 (it was 1.5.4) <dependency>    <groupId>org.aspectj</groupId>    <artifactId>aspectjweaver</artifactId>    <version>1.7.2</version> </dependency> Everything seems okay now.

Week in Review - 2013-13

Image
photo credit: @Doug88888 via photopin cc Installing Windows Vista For the first time since I bought it, my old Dell Inspiron 1525 has Windows Vista back on it. It's been running Ubuntu Linux since I got it, so why does it now have Windows again? My children are using computers at school now and they are using Windows - mainly Office. So rather than confuse them with different operating systems it seems more constructive to just give them some consistency and let them have their own computer set up like it is at school. I'm going to have to buy Microsoft Office for them - which after seeing how Libre Office handles clip art, I'm quite happy to do! (MS Office has a nice search and browse for clipart which the kids love and can use well. Libre Office didn't seem to have any search and you were left to click into each folder one at a time to see the clipart - not particularly useful). Downloading statements I've just noticed PayPal have an interesting fea

Week in Review - 2013-12

Google Reader and Listen I've been using Google Listen for listening to podcasts since I got my Android phone. It worked well, I would just subscribe to podcasts via Google Reader and drop it in the 'Listen Subscriptions' folder. But now with Google announcing the end of Reader , and Listen has long been abandoned , I'm looking for a suitable alternative. I really liked how I simply had to subscribe to a feed online - if I have to subscribe to things via an app, I'm stuck if I ever want to switch apps. Maybe I'll try Pocket Casts . LinkedIn Groups I've noticed that when contributing to LinkedIn groups, its not immediately obvious to others from your profile. Recent comments might show up in your activity stream but they'll soon disappear. If you view your profile, you'll see a Groups section that shows the groups you have joined. Click on one of those and you'll be taken to the Group page and at the top there will an area where you can st

Living without Google Reader and Listen

Since I got my Android phone, I've been using Google Listen to listen to podcasts. I really liked this solution since adding another podcast to my collection was as simple as adding it to my 'Listen subscriptions' folder in Google Reader. All from within my browser, all at the click of a button. Awesome. Listen may not have been the best podcast player - it didn't let you speed the playback up and didn't have a sleep timer. But it was simple and worked. Pity it was discontinued last year. Now Reader is on its way out I've had to find a new solution to consume my podcasts. And I've found it in Pocket Casts . This does allow you to speed up playback and set a sleep timer - something particularly useful since I've found podcasts distract me so much I can fall asleep very quickly. I've imported my Reader OMPL file by doing the following: Read how to export Google Reader feeds here http://lifehacker.com/5990456/google-reader-is-getting-

Fixing my server 500 errors

I'm slowly working through my broken pages - which were broken during the conversion from WordPress to Blogger. I can see in Google Web Master tools I've still got 22 server 500 errors left. There must have been more like 50 to start with. Its a slow painful process of copying the content from the broken post to a new post. I suspect it may be caused by the original WordPress post having comments - something the Wordpress2Blogger script must not be able to handle and therefore creates an corrupted post. Interestingly, the contents of the post are still viewable via the monthly archive page, but viewing the individual post errors - presumably as it tries to render the comments. If I had time, I'd go look at my WordPress database to confirm this theory but all of my time is being taken with fixing the errors. I cannot recommend using the Wordpress2Blogger script, I'm feeling a lot of pain and I had no help from Blogger support or groups.

Week in Review - 2013-11

Job interview testing While job hunting, I've come across one company that seems to have a very good filtering process. First off, you get a series of technical questions which are obviously aimed at finding out how you think or how much you know about technologies applicable to the organisation. I'm sure these questions have been custom written for their environment - which does to some extent convey some information about the potential role. If you pass that, you get an online 2 question Codility test which you have exactly an hour to complete. This is where you actually write code and can verify it compiles and produces the right answers. If you haven't seen Codility before, have a look - as a programmer you can even complete tests to get a 'certificate' you can put on your resume. Job hunting sites Some interesting sites when job hunting: http://www.glassdoor.com/ Information about company salaries http://www.snipey.com.au/ Find jobs advertised by co

Week in Review - 2013-10

An Optus representative came knocking the other week, and explained that by having an Optus home phone, broadband and mobile phone (which I have), I'd qualify for a 25% discount and free Fetch TV . Now, this is all GOOD. I had to upgrade my mobile plan from $29 to $30 (for which they wanted a $100 plan change fee), but hopefully my next bill will be 25% smaller (down from $80ish to $60ish). And, I'm currently enjoying the Fetch TV experience. This set-top box has a 1T hard disk, and a pretty good interface for navigating the recordings and (free albeit old) IPTV movies. I'm not saying its the best, but it does have me considering turning off the MythTV media center since it takes care of recording terrestrial TV (but I would need a DNLA alternative or similar for watching audio/video/dvds - maybe a NAS? or XBMC?). See https://www.optus.com.au/shop/broadband/bundles/85 An interesting point to note, now that I have FetchTV I can rent and stream movies for approx $6.50 -

Java on a $5 per month server from Digital Ocean

I just recently came across Digital Ocean - "Simple Cloud Hosting". I was impressed by the pricing, much cheaper than my current VPS solution so I've set up an Ubuntu 12.10 server with 512MB, 20GB SSD, for $5 USD per month. Since I've moved almost everything to Google (from self hosted WordPress to Blogger and Google Docs) the only thing I really need a VPS for is to run my Java applications (there still is the option to use AppEngine with Play 1.2.x if it makes sense to use DataStore). But for $5 a month, this means I can use Grails or Play with a relational database - if it performs well enough. Setting up a server with Digital Ocean really is simple. Once you've signed up (check their Twitter posts for a coupon) and added a credit card, your server can be running in minutes. I chose Ubuntu 12.10, and then they have nice and clear instructions on what to do next to secure it: Initial Server Setup with Ubuntu 12.04 How to Set Up a Firewall Using IP T

Integration testing Griffon services

I wanted to create an integration test for some Griffon services - where I wanted to set up some data first, then check that the service produced the appropriate results. Therefore, I wanted the database working normally, but I needed access to a configured Griffon application and the required services. My issue was how to get hold of the services? They don't automatically get injected as I first expected. But luckily, StackOverflow and Andres to the rescue:

Griffon - restricting a textfield to numbers

With my latest Griffon+JavaFX application, I wasn't having any luck binding a textfield to a 'float' property in my model. So to work around it temporarily, I've added a change listener which will veto any input that isn't a number. This example is basically using a very Java centric approach: Now, we can simplify this by using the Groovy way: See Groovy way to implement interfaces to understand how this is implementing the interface. If we want to have several text fields using the same logic, we can define the closure in the Controller and reference that in many places: Still, this is not optimal since I have to use Strings instead of Floats in my model - but it does let me continue with whats important right now. Hopefully the binding bug can be fixed soon.

Week in Review - 2013-09

I came across BackBox Linux - although it's not my area of expertise, I always find different distributions of Linux interesting. On the website it is described as follows:   "BackBox is a Linux distribution based on Ubuntu. It has been developed to perform penetration tests and security assessments. Designed to be fast, easy to use and provide a minimal yet complete desktop environment, thanks to its own software repositories, always being updated to the latest stable version of the most used and best known ethical hacking tools." I love listening to podcasts, and PocketCasts is an Android podcatcher that looks great! It supports variable speed playback, which if you haven't realised, you can easily play some podcasts at up to 1.5x without missing anything. Not sure if it does pitch correction to compensate, but I'll have to try it out. I have to admit to being a big Google+ fan. Whenever I scroll down my stream, I just find HEAPS of very cool interes

Moving from Wordpress to Blogger

I recently moved from Wordpress to Blogger. It just seemed to make sense to me, less maintenance (I was running Wordpress on a Linux VPS) and no infrastructure to worry about. It hasn't been seamless though - I used the Wordpress2Blogger script to transfer my content to Blogger but it appears there have been some issues: Firstly, managing comments is totally broken - If I try to access the comments from the management screen, all I get is: We're sorry, but we were unable to complete your request. When reporting this error to Blogger Support or on the Blogger Help Group, please: Describe what you were doing when you got this error. Provide the following error code. bX-naxxg8 This information will help us to track down your specific problem and fix it! We apologise for the inconvenience. Try googling for that error code and you get nothing. I've sent the Blogger team an email using the online help but I've heard nothing back. Secondly, some of my posts don

Upgrading Griffon plugins

I've written one Griffon application, and now I'm on to another. Its a great learning experience because I've never really worked much on desktop applications or with swing. While working on vsPhotoSorter I encountered a problem with the Installer plugin , one that was resolved in a recent update - but how do I upgrade the plugin? There are no upgrade-plugins scripts, but it is as simple as installing the plugin again, and specifying the version. You can use griffon list-plugin-updates to find out which plugins can be upgraded: Plugins with available updates are listed below: -------------------------------------------------------------------------------- <Plugin>            <Current>           <Available>         <From> datasource          0.4                 1.1.0               griffon-central gsql                1.0                 1.1.1               griffon-central installer           0.7                 0.8                 griff

vsConsole 2.0.6 available

vsConsole 2.0.6 has been released. This has a couple of bug fixes and feature enhancements added, see  http://www.vamonossoftware.com/2013/02/vsconsole-206-available.html for more information. vsConsole is a tool for developers and testers which lets you easily tail log files on remote servers, monitor the status and version of applications deployed to your environments, and stay informed with broadcast messaging.   Read more .

Looking for work

I'm looking for work! Last year I joined the SpringSource R&D team here in Sydney, but our project has come to an end so I'm looking for exciting opportunities - local (Sydney CBD) or telecommuting. If you need a passionate agile java developer, then please get in contact. For more information, see my profile at http://au.linkedin.com/in/paulrule/ or  http://careers.stackoverflow.com/paulrule .

Sort out your digital photo collection

Image
If you're like me, you've got several years (and gigs) of digital photos that you've been copying off your cameras, your phone, your wifes phone etc. Tonnes of photos, all unsorted, and some times copied more than once. How do you go about sorting out the good photos - the ones you want to share with your family - from the ones that just aren't worth sharing? This is why I started working on vsPhotoSorter - at the moment it is minimalistic, just enough features to provide me with value - but its working for me as I steadily sort out my collection. If you have a similar problem with your photo collection, have a look and see if it helps you too. Read more here http://www.vamonossoftware.com/2013/01/sort-out-your-digital-photo-collection.html . This software is a desktop application built using  Griffon and  Groovy on the  Java platform.