Error while running shell script using Java

I have pretty simple shell script file which i am executing using java Processbuilder as shown below:

processBuilder = new ProcessBuilder("/bin/bash", "/opt/node.sh");
            processBuilder.start();

Contents of the shell file node.sh is shown below.

#!/bin/bash
cd /opt/vision/
python oc_db.py -c hanoi.json

Above script is working fine, but when i slightly modify the contents of the shell script to persist process id in to the other file, process is not working properly using java.

#!/bin/bash
cd /opt/vision/
python oc_db.py -c hanoi.json & echo $! >/opt/hanoi.file

However if i run the node.sh file after modification from the command prompt, it works with out any issue. Wondering what i am missing.