Archive for the 'coding' Category

My facelets are no longer parsed – an adventure in Google and Java

The new feelitlive.com website is powered by Seam running over Hibernate and JSF. The stuff you see – the HTML source code – is generated by Facelets.

Facelets is a layer over JSF and the two work well together. I have mixed feelings on JSF – I don’t think I’d use it without the corrections made by Seam – but the combination of Facelets+JSF+Seam is quite compelling – once you get it set up. If you are an ex-ASP.NET guy like me then Facelets is equivalent to the union of “master pages” and “user controls”. JSF is equivalent to the whole supporting notion of “controls” in ASP.NET, but has has a cleaner separation of front and back end logic.

In Facelets the “master pages” part is known as “templating” and gives you a template for the whole page. Your content is added into the middle.

The “user controls” feature is known as “composition components” and gives re-useable blocks that you can drop into the page or template ad-hoc by simply adding a namespace qualified element. These are used all over feelitlive.com for everything from individual links and images to whole blocks of content.

my composition components were not being parsed

So, I was a little shocked to find that all of a sudden my composition components were not being parsed! Though live for months, half the site was now simply missing;  little bits of each page eaten away like swiss cheese!

I had moved to using Netbeans and was focusing on a backend web service so hadn’t actually run my homepage from my development machine for a week or so. When I went to do so, the templates and every built-in tag library was working, but the tag library containing my composition components was not parsed or executed. In facelets the tag libraries are assigned a URL and that URL becomes the the XML namespace in the XHTML source file – today all the XML in my own namespace was simply transferred into the output verbatim.

So, I scoured my change-log for evidence of any relevant changes I might have forgotten. I found nothing that even the most desperate coder would choose to consider related. I tried building from the command line – still no joy.

Netbeans was using the very latest Apache 6.0.20, so I tried the locally built WAR in three different versions of Apache including the version used in live – nothing. So “great”, I thought, “I can’t even release untested code if I wanted to”.

Thinking of the live server gave me an idea, so I downloaded the WAR file running from live and ran that in two of the Tomcat versions I had locally. Nothing. “Huh? Surely that should work”!

What about the JVM? Nope, my JVMs didn’t seem to have changed. This was mysterious – I’m sure I remembered an update arriving, but then I have three computers I use regularly.

So, no clues. Stuck. I’m a team of one on this project so nobody to ask. I could possibly change JVM anyway, though I’m not sure what I’d change it to, or where to get an older version. Possibly I could try downloading old versions of the code and trying to do a binary search for the change that caused it, but that’s assuming a code change had caused it and nothing logged looked likely. I could waste a lot of time on this one!

understanding this issue was secondary to fixing it

I left those two ideas untried, because something else occurred to me. Some stuff was working – the built in tag libraries. These are packaged in the facelets JAR and I could see them being picked up by facelets in the tomcat log. My tag lib was not being picked up.  I decided that understanding this issue was secondary to fixing it, and went about building a version of my tag library in a separate JAR, breaking it out of its home inside the main WAR file, and hoping that making it look more like that stuff tat worked would cause it to work.

I followed the layout of the seam-mail JAR, but this doesn’t use composition components – only custom components. So I added my existing folder full of XHTML fragments into  “META-INF/facelets” with the “fil.tablib.xml” in “META-INF”. My fragments were already identified as “facelets/fragment.xhtml”. I created a separate Maven project for all that, added it to the parent POM as a module, to the WAR as a dependency.

I built the new JAR, then built the WAR.

I then checked the layout was showing up okay in the “Libraries” folder in Netbeans – the JAR layout matched the ones that were picked up. Good.

Build again – can’t hurt.

Right click — run.

Wait.

Drum roll.

Bang! It worked – phew.

So what. The hell. Was that all about…..

Googling was useless

I don’t know. I still need to check it all over to make sure its all there back working, but frantic Googling was useless on this one so I wanted to share the adventure and the solution out of pity for the next developer down the road. I’d also like to make an observation about the process of searching for a solution on line.

This problem occurred near the top of a stack of technology starting at Windows XP, then Sun’s JVM, Apache’s Tomcat, JBoss’ Seam, then my code and finally Sun’s Facelet’s implementation. The stack could have been interfered with by the IDE – Netbeans – and the build tool – Apache’s Maven, or by any Maven plugin I’m using.  Searching the web for the phrase “facelets composition components are no longer parsed” gives you a blog post saying “please use my new site at [blah], I will no longer be keeping this one up to date” even the migrated article was not relevant, but did mention facelets. Fail. Big stinking fail.

What I needed was to find all documents – blog and forum posts, bug reports, and knowledge base articles – related to any of the technology components I listed and to the feature of “Facelets” called “composition components”. Properly understood, that is a small set of documents. Bonus points would have gone to the search engine that allowed me to select my symptoms from a list (they are not uncommon) but using supplied keywords to rank with would be good enough. A find-engine like this could have also offered an alert service and gone to work trying to find more results over a course of days, even monitored new bug reports and forum posts for results.

I got my answer after about 5 or more  hours of work spread over two days. I’d have been jubilantly happy to have had my answer after 2 hours. Others might be happy with 6 rather than 24, or 24 rather than 72, but I don’t think it would have taken anything like that long. I think you could do this kind of thing in interactive time, but the point is it doesn’t need to be that fast to be useful. I can always find other stuff to do as long as I can expect an answer. With Google I can’t get that answer without reading thousands of pages, and without hope of the answer being there.

Of course, linked data is the only current technology likely to ever offer answers to this sort of query. It involves too much precise classification and description for a statistical-web approach. How do statistics tell you the release history of  the Maven plugins which are used to build WAR files? They don’t. How do statistics provide an unambiguous list of the features in Facelets? They don’t. The runtime dependencies of JSF? Likewise. Can statistics help to rank pages according to the nature of their relationship with other concepts? Can stats weight pages directly related to given  concepts over those with links to concepts two degrees apart? Maybe. Placing problem reports over brochures, or holding that product components are more relevant than competitive products? Unlikely.

People say we don’t need semantic search because we can always add keywords, or they put up ridiculous road blocks because they think its “too hard”. Don’t they ever encounter issues like this one? Really? This is long tail stuff, but its definitely worth addressing. Those five hours were worth over £200. Once it exists I will use the web site that does this, I’d even pay a fee for the privilege.

Debugging JNLP applications

I recently had some trouble with a Java Web Start application and needed to debug. A little experimentation led to the following following Linux shell script which works a charm:

#!/bin/sh
uri=$1
export JAVAWS_TRACE_NATIVE=1
export JAVAWS_VM_ARGS=”-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=n”
env | grep JAVA
javaws $uri

Save it somewhere convenient, perhaps in your PATH. I saved it to ~/bin/djavaws.sh and set chmod u+x.

run with:

~/bin/djavaws.sh http://localhost:8080/logserver/webstart/launch.jnlp

How to build your own Chainsaw

I needed to access chainsaw’s library from a project, and determined that this is best done from source rather than downloading the JARs. What if something happens to the chainsaw project?

So I got HEAD from the SVN location below:

http://svn.apache.org/repos/asf/logging/chainsaw/trunk

This returned revision 789818, fwiw.

HOWTOBUILD in that project contained these other source dependencies:

log4j-component – http://svn.apache.org/repos/asf/logging/log4j/companions/component/trunk/
log4j-pattern-layout – http://svn.apache.org/repos/asf/logging/log4j/companions/pattern-layout/trunk/
log4j-receivers – http://svn.apache.org/repos/asf/logging/log4j/companions/receivers/trunk/
log4j-filters – http://svn.apache.org/repos/asf/logging/log4j/companions/filters/trunk/
log4j-zeroconf – http://svn.apache.org/repos/asf/logging/log4j/companions/zeroconf/trunk/

-component, -receivers and -zeroconf were found, there was no evidence of -pattern-layout
or -filters in the public SVN. Therefore the following were downloaded using the commands
Import->Check out Maven projects from SCM feature in Eclipse

Item Revision
http://svn.apache.org/repos/asf/logging/log4j/companions/component/trunk/ 789820
http://svn.apache.org/repos/asf/logging/log4j/companions/receivers/trunk/ 789821
http://svn.apache.org/repos/asf/logging/log4j/companions/zeroconf/trunk/ 789821

JMX was downloaded from here:

http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/download.jsp

and unpacked to here:
/home/simon/Desktop/jmx-1_2_1-bin/

and installed with:

mvn install:install-file -DgroupId=com.sun.jdmk -DartifactId=jmxtools -Dversion=1.2.1 -Dpackaging=jar -Dfile=/home/simon/Desktop/jmx-1_2_1-bin/lib/jmxtools.jar
mvn install:install-file -DgroupId=com.sun.jmx -DartifactId=jmxri -Dversion=1.2.1 -Dpackaging=jar -Dfile=/home/simon/Desktop/jmx-1_2_1-bin/lib/jmxri.jar

log4j-component built immediately with mvn install. Both of the others had direct
dependencies on artifact “log4j:log4j:jar:1.2.16-SNAPSHOT”

Downloading logj was done the same way. (I had some errors with folders that could not
be renamed , I cleared some guff from the target folder to fix) I downloaded from

https://svn.apache.org/repos/asf/logging/log4j/trunk

and got revision 790113

Building started in the Eclipse IDE and caused issues for mvn install. mvn clean install worked fine for log4j.

Building chainsaw requires a clean build of receivers and chainsaw. Build chainsaw with:

mvn -Dmaven.test.skip=true clean package
mvn -Dmaven.test.skip=true install

or similar, otherwise the tests will fail on you (mildly alarming).

Notes about my set up:

I have Eclipse 3.4.2 with

- Sonatypes Maven Integration for Eclipse 0.9.7.
- Subclipse (from update site  http://subclipse.tigris.org/update_1.4.x)

Once I got going I realised the project need not be included in my Eclipse workspace.

History, politics and culture of hacker spaces

I just read a thread started by Michael Zeltner on the London Hack Space group and assimilated the linked monochrom article.

Interesting points raised and I can’t dispute the history, but it seems to me that Monochrom (and I think also Zeltner)  sees hackspaces as a blank canvas onto which the (mostly left-wing) politics of the age are creatively drawn, and from which information is read by those nasty exploitative capitalists. Such an enterprise does need to agree on its purpose and destination in the way advocated by Monochrom, because otherwise the content of the canvas will be a complete mess, leading (in the real rather than the analogous world) to an unpleasant and fractious cultural space.

I thought I was helping to create a paint brush or a set of tools, capable of being used in a neutral and open way by any one friendly enough to turn up and get on with it without being an ass hole. I believed people would work on different canvases chosen by those individuals and any project groups they form as they socialise together in the space.  Some might work on their own web sites, perhaps even commercially while at the hack space as certainly happened at meetings #4 and #5. I contributed for selfish commercial reasons to an open project run by a major media company, but was friendy and sociable to the point of distraction while in “the space”. Others are working on kit to use in their own homes.  I’m sure others will get together and work on grander visions involving more people, even all of society, though I think that will take time to start happening. This latter model does not need a political direction or even a shared belief system, in relies on people with shared interests getting together and being sociable while using the facilities of the space.

Zeltner and Monocrom both approach the culture of hackspaces from what I would call (noting that my post 9/11 political awakening is still relatively recent) a collectivist meta-context and end-up ascribing collectivist features to it. Zelter reveals this when he calls setting up a space a political act and Monochrom likewise in his references to capitalists and capitalism as if they are something “other” than whatever it is he labels himself*. I wonder whether, if the factual history and consequent semantic baggage of the phrase “hacker space” is somehow unavoidably collectivist and whether I will find myself accidentally supporting a de facto left-wing political group of which I cannot approve. The rumours of funding from a certain assuredly left-wing media organisation does nothing to counter this impression.

I realise of course, that I have also ascribed features of the libertarian meta-context I was born with to the culture I expected to see formed at the London Hack Space. The description I gave above of a group of individuals united socially by accident of the facilities they enjoy and voluntarily uniting ad-hoc is basically the way I’d like my nation to be run, writ small. I would argue though, that this model of running a space – be it a country or a communal workshop – is superior exactly because it doesn’t matter if groups within the whole want to work on commercial, personal or communal projects as long as they respect the needs of every other individual sufficiently. The country, or the hackspace is a political entity in this model to exactly the same extent that a shop or a pub is political – not very political at all, but rather cultural or just social.

That all sounds very grand, but what it amounts to is turning up, getting on with whatever it is you want to get on with for whatever reason it is you want to do that, and getting on nicely with the others – exactly what has happened at every gathering so far.

Long may it continue.

* I realise I am anthropomorphising the group, but whatever…

TopQuadrant Webinar on querying and processing RDF

This webinar is interesting, not because it explains RDF exactly(though it touches on that), but because it shows the main differences between querying RDF and querying relational data in a way that won’t scare anyone away.

It should be stressed that his is one vendor’s vision and one vendor’s tool, but the speaker does lay down the boundaries between standard and vendor behaviours quite well, though its worth picking up “LET” as a non-standard keyword. Anyway, its quite a nice tool!

What novices should look for:

  • A neat explanation of RDF triples in visual terms.
  • On-the-fly invention of new properties for a type without planning ahead or doing any prep work.
  • WHERE clauses without a FROM clause – i.e. querying completely unstructured data.

If you are already sold on this RDF thing, then there is also a nice demonstration of using SPARQL for ETL functionality about half way through, which is more than cool. In addition, the RDF visualisation style where the graph is incrementally revealed on-demand is a nice paradigm for viewing graph data.

Bluetooth Links

A blog post in the traditional mould, links for my own reference:

(I have some ideas for a bluetooth app to get going with at the hackspace)

Update – more links:

On the web, no one knows you’re a man

girl from a show with beautiful eyesSNOSoft and DanBri write about social engineering hacks involving Facebook. Someone who isn’t a hot chick working in your company joins your firms Facebook group, and of course, on the internet nobody knows you’re a dog. If you saw a photo like this one, would you check or just let her in your group?

Of course, if your company sets up an Open ID provider coupled to the corporate directory and some other nice person (maybe facebook themselves) designs a widget to force group members to authenticate against particular OpenID providers then the fake employee would stick out by not being in the group.

Seeing Links

Dendrons, Pisces and the CosmosI’m currently engaged by a small systems integrations and – oddly enough, you might think -  web development company. That is to say, I’m working with a company that does web development, creative work and systems integration. I’m working on the systems integration side of things doing architecture and proofs of concept for an event driven integration platform focused around XML processing. This has involved a bit of rules based logic, arguing about defining schema upfront or letting the customer do it using RDF (it’s easy but its complicated) vs using relational databases (its complicated but its easy), a bit of coding with the DOM API, reviewing some  graph orientated process definition languages (if only to prove we didn’t want one) and some thought around long running business processes involving customers in an e-commerce context (which proved we actually did), and straying into architectural issues like whether to incorporate an ESB and what the hell an ESB is anyway.

This collection of abstract issues allows me and my colleagues to spend some time thinking in the abstract, and researching topics and increasingly seeing previously obscure links between things. For example, the fact that a web design company has ended up doing systems integration using a web language like XML  looks like a link, though actually its a complete coincidence which I only just saw. Other weird stuff comes up too, like the fact that the web page of a tool we’re reviewing was two clicks away from a definition of something very like what we’re  building, though we only came across the definition of it (and even  a related book) three months after we started to write proofs of concept. My guess is that it’ll be a useful tool.

Then came a less conceptually loaded link, in fact it was just a plain HTML link of the “if you liked that then you’ll like this” variety that lead me to an excellent InfoQ presentation on what REST is. If you’ve troubled yourself to read any of the links embedded in this article, or even if you’re familiar with some of the terms already then you’ll realise that this presentation actually sits right in the middle of the jumble touching on SOA, good web site design, and the importance of URIs as business identifiers. Of course good business identifiers are important in any system especially relational databases, almost certainly SOAs, and definately in Linked Data and in RDF and were a big topic at Linked Data Planet where I went last year so I’m seeing links stretching that way too.

Do you ever get a feeling somewhere in the back of your head of neurons rewiring themselves? You might just dismiss it as a headache but there is a particularly satisfying ache I get sometimes which is a bit like the aches the day after some strenuous excecise (another weird link) and its a feeling I get when concepts are shifting about and getting connected together in my mind. Well I have that feeling now, and the shapes being formed back there in the etched lines of synapses are pretty interesting, but are too big for one post…

Peer to Peer Web Search technology

A mailing list message on the topic of Microsoft Live’s search privacy prompted me to take another look at peer to peer web search applications, and I discovered two – YaCy and Faroo – both promise to protect your anonymity while searching, but paradoxically both will index the web using your click stream.

There are some interesting concepts at work there, in particular YaCy’s reverse word index coupled with downloadable Linked Open Data such as DBPedia, WordNet could form a powerful combination as long as the privacy protection was sound.