You are getting this error because of the division:
- The BigDecimal by default always tries to return the exact result of an operation.
- Due to this, certain division operations like 1 divided by 3, the exact quotient will have an infinitely long decimal expansion. This will cause the division operation to fail and throw the error as described above.
Provide a scale and a rounding mode (as you've done when creating the BigDecimals) within the division method to prevent this.
Taken from here. Example code for working division is also provided.
See also: Java docs on BigDecimal.