java.lang.NullPointerException in Java Service

Hi All,

I am getting java.lang.NullPointerException while invoking my java service from flow service.
I am having records in database and using jdbc adaptor I am reading those records and passing fields values as input for my java service.
This database may have null values in some columns. My service is checking whether its null or blank and accordingly its setting default values to those variables.

But when null values will get mapped, it throws java.lang.NullPointerException. Allow Null property of all variable is set to True. I have checked the inputs an all possible causes that i can think.
In my case it is necessary to pass null value to my java service. Can you please help me, how to pass null values to java service.

Sample of my code :
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String DocTitle = IDataUtil.getString( pipelineCursor, “DocTitle” );
Object InTime = null; //IDataUtil.get( pipelineCursor, “InTime” );
String Author = null; //IDataUtil.getString( pipelineCursor, “Author” );
String Account =null; // IDataUtil.getString( pipelineCursor, “Account” );
String primaryFile = IDataUtil.getString( pipelineCursor, “primaryFile” );
pipelineCursor.destroy();

//FileMetaData is HashMap static object of HashMap declared in source part of Shared tab
if (FileMetaData==null)
FileMetaData = new HashMap(); // Stores the Key Value pair for the File
else
FileMetaData.clear();

FileMetaData.put(“DocTitle”, DocTitle.trim());

DateFormat dateFormat = new SimpleDateFormat(“MM/dd/yyyy hh:mm a”);
if (InTime!= null )
{
Date date=(Date)InTime;
FileMetaData.put(“InTime”, dateFormat.format(date));
}
else
{
Date date = new Date();
FileMetaData.put(“InTime”, dateFormat.format(date));
}

if (Author==null)
FileMetaData.put(“Author”, “sysadmin”);
else if (Author.trim().equals(""))
FileMetaData.put(“Author”, “sysadmin”);
else
FileMetaData.put(“Author”, Author.trim());

if (Account==null)
FileMetaData.put(“Account”,"");
else
FileMetaData.put(“Account”, Account.trim());

// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “DocTitle”, FileMetaData.get(“DocTitle” ).toString());
IDataUtil.put( pipelineCursor_1, “InTime”, FileMetaData.get(“InTime” ).toString());
IDataUtil.put( pipelineCursor_1, “Author”, FileMetaData.get(“Author” ).toString());
IDataUtil.put( pipelineCursor_1, “Account”, FileMetaData.get(“Account” ).toString());
pipelineCursor_1.destroy();

DocTitle could be null. I don’t see a null check before the call to DocTitle.trim()

If this does not solve your problem ,you may want to try debugging the issue by adding some sysout statements to your java service.

Thank you agrawal, thanks for your quick reply.
I found the root cause of problem. Actually mapping was wrong. I was having variable with name Intime as well as InTime. And I have mapped Intime variable instead of InTime.

My problem is solved after changing mapping.

Thanks and Regards,
mayur