Saturday, October 2, 2010

Trampoline day - September 2010



I attended my first trampoline day in Melbourne last week. Trampoline is an interesting concept - a self organising "un-conference" where the attendees build the agenda as they go, and then facilitate a session for 20 minutes. Sessions can be presentations, workshops, or simply open discussions on anything that the facilitator finds amazing.

Situated at Circus Oz in Port Melbourne this year, there were about 150 attendees and there were some interesting sessions ranging from the political, spiritual, scientific and pure entertainment...

I attended the following sessions:
  • Born to run - taught me why I should be running in bare feet.
  • A solution focussed approach to change - if only we could take this approach in the corporate IT world more often.
  • How to 2-step to punk music - a bit like this
  • My TV Remote sucks - usability 101
  • Ecosystems and the God Particle - inspired by the book Massive
  • Coffee with @jonathannen and @dougenglish - not really a session but a good coffee break
  • Anatomy of a web startup - how to raise your first million from someone that had
  • The Future of Money - is money evil?
Pretty much all sessions were interesting, especially those that pitted the hippies against the scientists which made for entertaining "un-collaboration".

Looking forward to the next one...

    Sunday, August 29, 2010

    Unit testing EJB 3.1 with Derby DB and embedded Glassfish

    Unit testing EJBs has always been a bit of a pain as you'd need to deploy them to a container first. This is something that JEE6 addresses by specifying an embeddable implementation of the container. Using the embeddable container is simple enough, but I wanted to unit test an EJB that acted as a façade to a JPA entity backed by a derby database. I've had all sorts of problems getting this going.

    I originally tried this based on sample code from chapter 6 of Antonio Goncalve’s book JEE6 with Glassfish 3 which despite being an excellent book, I couldn't get the example working. I've been trying to get the sample going for a little while and followed heaps of different blogs and ideas but was still unsuccessful. Recently I was pointed to this great post which gave me enough info to get it working so I figured I'd re-post the example from Antonio's book with some info so that anyone bashing their head against the same wall as I was could get it running.

    Taking the original code from Chapter6 of Antonio’s book it looks something like this:

    • Book.java: a JPA entity that handles storage and retrieval of book data.
    • BookEJB: A Stateless Session bean that invokes the JPA entity to uses it
    • BookEJBTest: A class to test the EJB using JUnit test.
    • persistence.xml: configuration file specifying and persistence units.

    The issue with the sample code is that when an instance of the embedded container is created,
    it doesn’t successfully find BookEJB to deploy and it doesn’t have any knowledge of the jdbc-resource-pools required for a JTA data source.

    The original code for instantiating the embedded container is:
    public static void initContainer() throws Exception {
    ec = EJBContainer.createEJBContainer();
    ctx = ec.getContext();
    }
    To resolve these issues we need to do a few things:
    • Create a simple glassfish domain with a domain.xml configuration file that contains the relevant jdbc-connection-pools, and jdbc-resources.
    • Additionally, we need to tell the embedded container where to look for this stuff so we replace the original code with some pointers to where to find the classes
    To do this, replace the provided initContainer method with the following code.

    @BeforeClass
    public static void initContainer() throws Exception {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(EJBContainer.MODULES, new File("target/classes"));
    properties.put("org.glassfish.ejb.embedded.glassfish.installation.root", "myGlassfish");
    properties.put(EJBContainer.APP_NAME, "chapter06");
    ec = EJBContainer.createEJBContainer(properties);
    ctx = ec.getContext();
    }


    Specifying the "EJBContainer.MODULES" property tells the embedded container explicitely where to look for EJBs to deploy.

    Specifying the "org.glassfish.ejb.embedded.glassfish.installation.root" property, allows the container to find the resource adapters and domain.xml.

    When looking up the BookEJB, you need to use the fully qualified name (note the app name 'chapter06' that we specified as a property in the modified code:
    BookEJB bookEJB = (BookEJB) ctx.lookup("java:global/chapter06/BookEJB!org.beginningee6.book.chapter06.BookEJB");


    Now it’s just a matter of putting the files in the right locations, ensuring your persistence.xml and domain.xml are consistent and the unit test will work...

    Assuming you already have the original code (including all chapters etc), unpack the updated code in the same location, run 'mvn clean test' and it should all hang together...

    Here's a screen shot of the workspace...




    Monday, July 12, 2010

    Stop, collaborate and listen - Jodoro


    I caught up with some ex-colleagues for a few fat yaks the other day and it turns out they have founded their own company jodoro. Based on their experience as Software Architects working in anger with large enterprises trying to sort out their data models, they've put together a collaborative data modelling tool and service "graft" which provides a new way of attacking the data model collaboration problem.

    Graft is hosted in the cloud and provides organisations with a collaborative data modelling environment within which models can be developed, extended, communicated, and published completely on-line. It's in early release stage at the moment, but it has a great user experience and I can see how such a tool could be used to assist in many problem areas including:
    • efficient development, communication, collaboration, and implementation of data models on development projects.
    • organisations looking to adopt and collaborate on industry standard models

    Delivery projects
    Graft makes sense on several recent projects I've worked on. On these projects a large delivery team (50+) has had to design, develop, share, communicate and collaborate, on a data model in a tool with a circa 1990's collaboration vibe (thick desktop client interacting with a model repository file. Whilst it was designed for multi user operation, it still has one foot firmly entrenched in single user world). The project essentially used the tool as diagraming software - taking screenshots of the model, pasting into a word document and then emailing to the client for review. The graft tool would move this process to a completely online world where all users interacted with the actual data model, and I can see a future where organisations could configure their own governance workflow process in the tool to keep the Enterprise Architects happy. It's only early days, but the collaboration experience will only get better as new features are added.

    Adopting industry standards
    Graft could also help organisations in adopting industry standard models and collaborating with other organisations in the same domain (assuming they would play nice). For example, graft allows organisations to take a standard model, select the parts of the model that are relevant to them, and leave all other model elements as 'passive' (they still exist but are not implemented). Over time the organisation can choose to include these model elements and along the way can publish their model publicly so that other players can extend the model and in turn republish their own customisations. This feature makes it very attractive to organisations that want to move to an industry standard model, but roll it out in bite size chunks rather than scoffing the entire thing. This suits the project funded world that we live in where the first passenger never wants to pay for the entire bus.

    Check out the graft tool here http://www.jodoro.com and if you want to have a crack at developing your own model, I recommend watching the 3 minute video first.