Git pre-pushed object on remote server? git ls-tree
java code formatter as a pre-receive hook

Don't do it. You're trying to run the equivalent of git filter-branch behind your developer's back.  Don't do it.

Is there any other way of doing this?

If you want inbound code formatted in a particular way, validate the inbound files. If any aren't done right list them and reject the push.  

How to get that object on a remote server?

You can't fetch arbitrary objects, you can only fetch by ref (branch or tag) name.  The pre-receive hook runs before any refs have been updated, so no ref names the inbound commits.
I have a Atlassian Stash server for git.
I am looking to write a script that will run java code formatter as a pre-receive hook (before it pushes the changes to the repository).
So, what I am looking to do is NOT to do the work on the stash server itself rather perform the work on another server and send the status back (0 or 1) to the Stash server.
I have written the script in Python where it calls a cgi (python) script on the remote server with "ref oldrev newrev" as HTTP GET Method. Once I have the STDIN values (ref oldrev newrev) on a remote server, I created a dir, git init, git remote add origin URL, and git fetch (i even tried git pull) to get the latest contents/objects of a reporsitory in hoping to get the object that has not been pushed to the repository but its in a pre-pushed stage environment.
The hash or SHA key or "newrev" key of the object that is in the pre-pushed stage: 36ac63fe7b15049c132c310e1ee153e044b236b7
Now, when I run 'git ls-tree 36ac63fe7b15049c132c310e1ee153e044b236b7 Test.java' inside the directory I created above, it gives me error.
'fatal: not a tree object'
Now, My questions are:
How to get that object on a remote server?
What might be the git command that I run that will give me that object in that stage?
Is there any other way of doing this?
Does it make any sense of what I've asked above. Let me know if I am not clear and I will try to clear things up more.
Thanks very much in advanced for any/all the help?