Have you tried running the command one piece at a time and seeing what the outcome is? In other words, run this:
ps efax | grep java
Make sure you get some output (at least one java process should be available). Then run:
ps efax | grep java | grep $USERNAME
(I suspect that this will yield no output because it assumes that JBoss AS is running under the same user name as the script, which is a bad assumption. Perhaps take that grep out of the command string.)
And then add the next part and so on. Eventually you will have a script that works for you.