1 of 1 people found this helpful
Your code looks to be doing the right thing, although I've not checked it too carefully. However, you can't just run it from a main method, you need to create your client as some JEE artifact, a war or a jar would be fine. You could call if from an EJB or a JSF page for example. The important thing is that your client needs to run inside the container. It is possible to run the client outside of the container, but it requires more work.
I notice that this is a piece of coursework. I assume the coursework mandates what technology should be used for the client (JSF, EJB, etc), so use that technology.