Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Displaying NullPointerException

Options
Padma
Padma Posts: 5

Hello,
I am new to Java and trying to run below code however I am getting NullPointerException and I couldn't figure out how to instantiate varScriptToolContxt.
Appreciate if someone cana help me.

public class helloWorld {
public static void main(String[] args) throws IOException{
ScriptingContext varScriptToolContxt = null;
String s = printHW(varScriptToolContxt);
Application.showMessage(s);
}
public static String printHW(ScriptingContext varScriptToolContxt) throws IOException
{
return varScriptToolContxt.getValue("ExecuteScenario");
}
}

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,232 ✭✭✭
    Options

    I couldn't figure out how to instantiate varScriptToolContxt

    You do not instantiate ScriptingContext. Instead, SOAtest passes the ScriptingContext object as an argument to your Java method. In SOAtest you would typically add an Extension tool to your test suite. Next, configure the Extension tool with the name of your Java class and the java method which has an argument of type ScriptingContext (not String[] args). There are examples in the User's Guide under Extensibility and Scripting Basics.