*UPDATED
I am new to grails and stack. I am trying to instantiate a java class in a controller. My .java file is in the /src folder. I have tested the class outside of grails and it works fine. However, when I try to instantiate it from a controller I get a null pointer exception. My relevant code:
package matrices
import org.springframework.dao.DataIntegrityViolationException
class MFController {
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
def index() {
MatrixFactorization m = new MatrixFactorization()
def answer = m.getAnswer().toString()
return answer
}
My trace:
Message: null
Line | Method
->> 45 | run in matrices.MatrixFactorization
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 36 | <init> in ''
| 10 | index . . in matrices.MFController$$ENtqy0Aa
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
MatrixFactorization class 35-45
public MatrixFactorization() {
double[] l1 = { 5, 3, 0, 1 };
double[] l2 = { 4, 0, 0, 1 };
double[] l3 = { 1, 1, 0, 5 };
double[] l4 = { 1, 0, 0, 4 };
double[] l5 = { 0, 1, 5, 4 }; //45
Thanks in advance