Hive UDFs are executed on the task nodes. Unless you're running hive server on every task node (hopefully not), giving the connection URL as "localhost:10000" will not work. You must give it the actual address of the hive server node, whether that is an actual name (e.g. my-hive-server-node.company.com:10000) or just an ip (e.g. 10.20.30.40:10000).
Also, I would really take a step back and make sure this is really what you want to do. This seems like it's really against the intentions of Hive.