0

Below are the first few lines of my groovy file. When i try to run it from the server, i get the null Pointer Exception: Cannot invoke method addURL() on null object

I am not sure how the code needs to be changed here to fix the above error:

package groovy;

def localFile = new File("/tmp/sqljdbc4.jar");
this.class.classLoader.rootLoader.addURL(localFile.toURI().toURL());

import java.sql.Connection;
import java.sql.DriverManager;
import com.microsoft.sqlserver.jdbc.*;
import groovy.sql.Sql;

Connection ret = null;

try {
SQLServerDataSource ds = new SQLServerDataSource()
......

1 Answers1

0

Try using the class name instead of this for example if the class is named Groove use the line Groove.class.classLoader.rootLoader.addURL(localFile.toURI().toURL());