Life Codecs @ NamingCrisis.net

Ruminations. Reflections. Refractions. Code.

Apr 24, 2009 - software dev

JBoss 5.0.x (and 5.1 Beta?) and JPA Persistence Units

After much messing around, I finally have my sample EJB 3 app working, but on Glassfish!! I started off with JBoss, and may still go back to it once they decide on better handling of persistence units, and not reload/load it regardless! Too complicated for me to explain, check out these links which summarise it in depth (they speak about Seam, but refer to the same issue I’m babbling about):

http://relation.to/Bloggers/JBossAS5AndGlassFishSupportAddedToSeamgen

http://code.google.com/p/seaminaction/wiki/DeployingToJBossAS5

Basically I have a common domain-model jar which I wish to treat as a persistence unit used by both my EJB and WAR in the same EAR.

And after hours of tweaking and messing, this is my successful test output:

1
2
3
4
5
6
7
8
9
10
Creating...
Data Value=JustCreated!!

Retrieving...
Data Value=JustCreated!!

Updating...
Updated Data Value=JustUpdated!!

Deleting...

Ah, the joys of development. Actually that’s a pretty decent test case, it’s a servlet that’s got an EJB3 instance injected, which in turn has an EntityManager instance obtained via the JNDI name of a configured JTA XA MySQL datasource injected. What a mouthful!

Apr 23, 2009 - general software dev

A Failed Interview!

I had an interview yesterday – which I thought went quite well, except for 2 questions below (interview was around 30 minutes I think), which it seems were significant to the interviewer.

Disclaimer: I didn’t get the job – so there’s obviously some bias in what I have to say. If anything, just add these questions to your list of things to look out for when looking for a Java WebApp job. I did not have a full job description when I went in (it was not provided), all I knew was it involved Hibernate, and that they were a team following an Agile methodology.

The Questions of Doom were:

  1. What’s a Hibernate Session?
  2. In a WSDL, what’s the difference between port and binding?

Question 1, something I probably should’ve been able to give a quick answer for. I started with the Session being a non-threadsafe object, which allows you to do CRUD operations with entities. The interviewer brought up the relationship between a Session and a database connection, and this is where I fumbled – eventually saying that a session uses one connection. It’s tricky because a Hibernate Session performs many functions (the docs say so too – “The Session is also many other things”!! I wonder if that violates the SRP 😛 – though it’s probably more a logical Facade). When you learn it mostly on project where most things are set up when you get there, you tend to skip exact details, so reading about it formally: it’s a unit of work, it also maintains the persistence cache – a map of objects in the persistence context to ensure identity, it is a handle to load and store objects, it’s a list of SQL statements to be executed, and finally it obtains a connection from a connection pool. Many things eh. I knew all of this from experience, I just could not put it elegantly into words. I also obviously knew having too many sessions open at the same time could exhaust your connections!

I also now know that you can reconnect a session – but the API deprecates the no-param reconnect() method, and you have to supply a connection reconnect(Connection)… any ideas on what the use case for this generally is? Extended sessions? Hmm…

Question 2, now I have done a fair bit of Web Services work, debugged quite a few issues too – but I’ve generally been a downstream client, so we get WSDLs from the upstream services, run a tool like Axis over it, voila a nicer Java view of the whole thing, so I didn’t have to tweak or look at the WSDL much – hence my knowledge of WSDLs themselves is fairly informal – I do know it’s basically a contract/webservice interface document and defines types, messages, and operations. When I did have to mess with WSDLs – it had to do with the operations and I/O parameters – the actual messages being passed around. So this question took me under 10 minutes to find resources for and get a fairly clear idea about the difference – a portType is like a module of available functions, and their parameters. A binding links these operations (and defines message formats) to a transport (which is usually just SOAP over HTTP anyway!). While I appreciate that it shows a crucial concept that WSDL separates messages from the transport – it’s hardly something that takes days to understand, certainly not rocket science (actually talking about SOAP itself, it very well could be).

In this interview, if I were to apply meaning to the whole incident, I would be left feeling a bit discontented – but I won’t do that because I know my abilities better than that – I so uberly-rock *cough* :P. In the end I just did not meet their expectations, but it is their expectations, and that is all. As for me, I’ll prepare better for notions or concepts that I take for granted because I use them everyday – must be like a fish-in-the-water-not-knowing-about-the-water-syndrome (that’s a long syndrome name…).

Apr 5, 2009 - martial arts

BKC Demonstration

I initially posted this video on Facebook (doesn’t look like I can point to my status and it’s comments from here?), and received some comments to which I needed to reply in some detail. However, Facebook restricts the amount I can type in a comment box, so reproducing it here.

See post comments. FYI it’s a demonstration by my grandmaster, founder of BKC.

Mar 14, 2009 - arts personal

“Nessun Dorma”, Vanessa Mae’s Violin Rendition

Here’s the video – it’s just some background images for the piece really, not a “real” video. Definitely makes it to my all-time favourite list. Here’s more info on the piece itself. You might also like the more opera-friendly version sung by the 3 tenors. For completeness, I like Andrea Bocelli’s version too.

Beautiful stuff. Hope you enjoy it as much as I do.

— Kamal, bumming and unemployed at 1.55am :-).