Archive for the ‘quick tips’ Category

Access a Spring Bean from within a Servlet

Tuesday, September 21st, 2010

ApplicationContext context =
    WebApplicationContextUtils.getWebApplicationContext(getServletContext());
MyService service = (MyService) context.getBean("serviceBeanName");

Tags: ,
Posted in Development, quick tips | No Comments »

Selenium Tests Randomly Failing

Saturday, July 31st, 2010

The Problem

The project I’m currently working on uses a lot of selenium tests to verify the behaviour of the web front end and, I must say, I’ve been quite impressed with it.

Yesterday however after updating my local machine with the latest copy of the project from Clearcase I noticed a lot of failing tests; the worrying (interesting?) thing though was that the failures appeared to be “random”. Tests were passing one run and failing the next, with no changes having being made in the source code and no changes in the initial starting conditions. I was starting to pull my hair out. Curiously the tests ran fine on my colleagues’ and the build machine. My workmate had a look (remember the tests ran fine for him) but he too was getting the random failures on my machine – we were both stumped.
(more…)

Tags: , ,
Posted in quick tips | No Comments »

Dos to Unix (Dos2Unix) with Eclipse

Wednesday, July 21st, 2010

1. Open the file in Eclipse that you wish to “Dos2Unix”
2. File -> Convert Line Delimiters To -> Unix

Profit!

Tags: ,
Posted in quick tips | No Comments »

JAXB @XmlAnyElement example

Monday, June 7th, 2010

The problem

I was recently working on a JAXB centric app which was required to capture “arbitary” xml. e.g.

<a> 
   <b></b> 
   <c></c> 
   <d> 
       <!-- "Unknown" XML here --> 
       <maybee></maybee> 
       <maybef></maybef> 
       <!-- etc etc --> 
   <d></d> 
</d></a> 

How could I ever capture the contents of if they could be “anything”?
(more…)

Tags: , , ,
Posted in Development, quick tips | No Comments »

How to convert a CLOB to an XMLType in Oracle

Thursday, June 3rd, 2010

Not much comment to add here; code says it all

PROCEDURE clobToXMLType(myClob IN CLOB)

IS
    l_xmlType XMLTYPE;
    -- do something
BEGIN
    l_xmltype := XMLTYPE.createXML(myClob);
  
EXCEPTION

    WHEN OTHERS THEN
    	RAISE;

END clobToXMLType;

Tags: , ,
Posted in Development, quick tips | 1 Comment »