FieldHelper cannot be cast to java.lang.String pentaho

I had the following error in a “User Defined Java Class” step on Pentaho Data Integration.

FieldHelper cannot be cast to java.lang.String

Indeed, you have to use the getRow() method to convert the field you’re getting into a String or any other variable type.

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException, Exception
{
  Object[] r = getRow();
        if (r == null) { return false; }
        String myString = get(Fields.In, "FeedSubmissionId").getString(r);
}

 


Get XML Data won’t parse XML object – Pentaho

I had an issue with Pentaho today. It wasn’t able to simply parse this XML that I was fetching from Amazon Marketplace Webservice.

Here’s the data I got :

<SubmitFeedResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<SubmitFeedResult>
<FeedSubmissionInfo>
<FeedSubmissionId>MY_FEED_ID</FeedSubmissionId>
<FeedType>_POST_INVENTORY_AVAILABILITY_DATA_</FeedType>
<SubmittedDate>2016-08-01T19:28:30+00:00</SubmittedDate>
<FeedProcessingStatus>_SUBMITTED_</FeedProcessingStatus>
</FeedSubmissionInfo>
</SubmitFeedResult>
<ResponseMetadata>
<RequestId>MY_REQUEST_ID</RequestId>
</ResponseMetadata>
</SubmitFeedResponse>

The step “Get XML Data” couldn’t parse it because of the xmlns attribute tag. So I had to add a step “Replace in string” that would delete this attribute.

Screenshot from 2016-08-01 17:18:56