How to get correctly shadow Matrix

If you are using 1.10, getting the shadow matrix in GLSL is a lot easier; it can be accessed through p3d_LightSource[0].shadowMatrix (or customInput.shadowMatrix if you used setShaderInput instead of setLight), which does not require you to multiply it with a bias matrix. Check out this sample:

UPDATE: Please do not use shadowMatrix, but use shadowViewMatrix instead, which transforms from view-space vertex coordinates instead of model-space coordinates, which is more efficient.

Also, to get a tiny bit of shadow smoothing for free, you should really use a sampler2DShadow (sampling which does the depth compare for you). This is also demonstrated in the sample program above.