It doesn't matter whether the prefix is the same or different. What does matter is the namespace URI applied to the prefixes in the two places; that should be the same.
In the XML document I can see the namespace URI which is applied to the "ns" prefix. But I don't see the code where you apply a namespace URI to the "tns" prefix in your XPath expression. Perhaps you didn't apply any? If you are asking about a javax.xml.xpath.XPath object (you didn't mention that) then the setNamespaceContext method is how you do that.