java.lang.NullPointerException: Cannot invoke method addURL() on null object

Nishant Kansal March 21, 2016

Please help me to resolve this null pointer exception.

I am executing this script from "Script Runner" console in JIRA.

--------------------------------------------------------------------------------------------------------------------------

this.class.classLoader.rootLoader.addURL(new URL("file:///C:/TEMP/sqljdbc4.jar"))

import groovy.sql.Sql
import java.sql.Driver

def sql = Sql.newInstance("jdbc:sqlserver://servername:1433/Valid_DB_Name", "Valid user", "valid password", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
--------------------------------------------------------------------------------------------------------------------------

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 21, 2016

The first line of your code here calls a method on an object that does not exist at the point at which you run it.  The "this" is empty!

 

Nishant Kansal March 25, 2016

Thanks, Nic.

Could you please help me further to resolve it? I am not much into OO programming and although I understood your point, however, couldn't able to think of the resolution as such.

 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2016

I can't tell you anything more - your code and explanation do not explain what the "this" object is for or where you expect it to come from

Suggest an answer

Log in or Sign up to answer