Dependencies, dependencies - Selenium RC & NakedObjects
I wanted to throw together a simple demo of Fit and 'Selenium RC' working together… the way I'd do it.
I wanted the demo to be self-contained, not needing access to the internet to do the demo...
I'd heard about NakedObjects - a framework that requires that you only write domain objects and it generates the UI dynamically. Early versions just used Eclipse as a platform for the UI. Now (and for a while in fact) it also generates a web UI. Perfect! I could run the webserver locally and it could generate a simple UI - adequate for my needs and saving me a lot of hassle writing HTML and JSPs.
I started with a project that contained both NakedObjects and Selenium. Completed the NakedObjects Tutorial with a simple domain object (mine was a 'StaffMember' rather than a customer)… Took a look at the web front end and all was working well… it really was as easy as the tutorial video indicates...
As soon as I tried to run my SeleniumRC tests I started to get errors!!!
java.lang.VerifyError: (class: org/openqa/selenium/server/SeleniumServer, method: assembleHandlers signature: (Z)V) Incompatible argument to function
Eh!?!?! I'd run Selenium RC in this way plenty! Never seen this before... I opened another project I had some tests in… ran them - no problem… So, it had to be something about this project...
I googled and googled… couldn't find the answer. I saw one forum post (in Chinese - Google Translator helped me read it) that kept talking about Jetty… I realised that the jars for both selenium and NakedObjects contained Jetty - probably different versions… so, I played around with the class path order...
This is how it was initially, causing the VerifyError...
So, I moved NakedObjects to the bottom…
Now, my Selenium RC Tests passed:
But, now I was getting Log4J warnings...
log4j:WARN No appenders could be found for logger (org.openqa.selenium.server.SeleniumServer). log4j:WARN Please initialize the log4j system properly.
Grrr...
And then I realised that I hadn't restarted the NakedObjects server since changing the class path order project… Thought I ought to...
Boom!
Exception in thread "Client" java.lang.NoSuchMethodError: org.mortbay.jetty.Server.(I)V at org.nakedobjects.nos.client.web.server. NakedObjectsWebServer.init(NakedObjectsWebServer.java:32) at org.nakedobjects.nos.client.web.server. NakedObjectsWebServer.init(NakedObjectsWebServer.java:28) at org.nakedobjects.nos.client.web.server. WebBrowserClient.run(WebBrowserClient.java:43) at org.nakedobjects.nof.boot.system.NakedObjectsSystem. runClient(NakedObjectsSystem.java:570) at org.nakedobjects.nof.boot.NakedObjects$1. run(NakedObjects.java:252) at java.lang.Thread.run(Thread.java:595)
Clearly, the NakedObjects and Selenium both depended on different, incompatible versions of Jetty...
OK... That whole idea of quickly throwing a demo together was starting to be not so quick... I realised that I should have done what I would have normally done in practice...
Solution
At the moment, I don't need my Fit/Selenium Tests to be dependent upon anything in the application project (containing NakedObjects). The fact that they were all in one Eclipse project was just because I was being lazy - no, that's not fair - I was trying to just get a simple job done as quickly as possible... Well, more haste - less speed. So, what's the solution? Two separate projects - one with the Fit/Selenium tests and the other for the NakedObjects application, no interdependencies - job done!!!!
