I know this is bit of a necro, but I had a similar problem and this is the first result I got. So finally managing to solve the type error I wanted to give my solution.
In the script task it seems (somebody can correct me if I'm wrong) that you can't use imports, but always have to use full paths to each class. In my case I was having problems with using Date and Calendar. This was fixed by writing java.util.Date and java.util.Calendar instead of just Date or Calendar. So for example
Date dateVariable = new Date(); Doesn't work, but should be
java.util.Date dateVariable = new java.util.Date();
I hope this helps some other people who might be having the same kind of troubles.