It would be a bit more helpful if provided the stack trace of the error you are getting. But part of the problem is that you're assuming you'll be getting back you bean class, which you will not. With your HelloWorldBean, you should have a corresponding HelloWorld interface marked with an @Remotae annotation. Then your code should read:
InitialContext ic = new InitialContext(); HelloWorld hw = (HelloWorld) ic.lookup("HelloWorldBean/remote");
That would be the proper way to write your code. Otherwise, you'll get a ClassCastException.