Exception while inserting doc

Hi All
I’m getting a NullPointer Exception when inserting a document into Tamimo.

       
//Insert new document into Tamino
TXMLObject submission = TXMLObject.newInstance(element);
TResponse response = accessor.insert(submission);
System.out.println("Response to insert: " + response.getReturnValue()); 


I’m getting an exception on the TResponse response = accessor.insert(submission) line.
Please advice.
Best Regards

Hello there.

I think that the most likely possibility for a NullPointerException on the line you mentioned is that the “accessor” object is null.

Could you please post the code where you create and assign a value to the “accessor” object?

Best Regards,
Trevor.

Thank for the reply Trevor,
Here’s the code where I assign a value to the accessor

 
// Obtain the concrete TXMLObjectAccessor using the JDOM object model
accessor = connection.newXMLObjectAccessor(TAccessLocation.newInstance(collection), TJDOMObjectModel.getInstance());


I’ve also attached the whole java program.
Thanks
CreateNew.java (4.94 KB)

Hello goligoli.

In your code you assign values to the “connection” and “accessor” fields in the “CreateNew” constructor - but unfortunately this constructor is never called!

I would recommend making the “connection” and “accessor” fields local to the main method, and initializing them just before usage.

I hope that helps,
Trevor.