Thats very dubious for me.
The subject look like you try to access an EJB deployed in a JBoss5.1 from an AS7 server (sounds like inside EJB).
Your code is a main method, which is a standalone application.
So if you have a standalone application you should use the standard procedure to access EJBs in a JBoss 5.1 (your example is a mix of AS5 and AS7 client).
The client libraries of AS5 and AS7 are different and you can not access in that way.