Or you can use the already included FastMath methods sphericalToCartesianZ and cartesianZToSpherical. :) I notice the second method is slightly different than yours (when storing, y and z is swapped) but we use these at work sucessfully.
java.lang.ArithmeticException: This matrix cannot be inverted
at com.jme.math.Matrix4f.invert(Matrix4f.java:1086)
at com.jme.renderer.AbstractCamera.getWorldCoordinates(AbstractCamera.java:939)
at com.jme.system.DisplaySystem.getWorldCoordinates(DisplaySystem.java:782)
at com.jme.system.DisplaySystem.getWorldCoordinates(DisplaySystem.java:765)
at org.resonus.aa.comps.ui.AAInputHandler$12.onMove(AAInputHandler.java:339)
at com.jme.input.lwjgl.LWJGLMouseInput.update(LWJGLMouseInput.java:200)
at com.jme.input.InputSystem.update(InputSystem.java:67)
at com.jme.app.BaseGame.start(BaseGame.java:63)
at org.resonus.aa.Main.main(Main.java:234)
Got that when zooming.
That's when I did a quick search and replace, replacing all my sphericalToCartesianZUp with FastMath.sphericalToCartesianZ and my cartesianToSphericalZUp with FastMath.cartesianZToSpherical.
Hmm, well please alter cartesianZToSpherical to use the swapped y and z as in your method and see if it then works for you. If so, check it in. Looking through the code, it seems we're not using that method anyhow, instead we swap y and z and pass that in.