Error casting DocumentBufferedFileStoreCell

Hi knime team and community.

When I try to read document cells, the getClass() method returns the type DocumentBufferedFileStoreCell. Then I tried the following to get the document to be read:

RowIterator it = inData[0].iterator();
        while (it.hasNext()) {
        	DataRow r =;
        	DataCell c = r.getCell(colIndex);"Cell class: " + c.getClass());"Cell type: " + c.getType());"String da célula: " + c.toString());

        	/* c.getClass() returns DocumentBufferedFileStoreCell */

        	DocumentBufferedFileStoreCell dc = (DocumentBufferedFileStoreCell) c;
        	Document d = dc.getDocument();



For some reason, when I execute the node, it gives an error saying I can't cast a type to the very same type!

2017-07-01 15:43:38,734 : DEBUG : KNIME-Worker-0 : BrTagger : BrTagger : 0:8 : Execute failed: cannot be cast to

java.lang.ClassCastException: cannot be cast to at org.knime.brtagger.BrTaggerNodeModel.execute(

Line 147 at the error is line 12 at code snippet above.

Can someone tell me what I'm missing? I already tried to cast the DataCell to DocumentBufferedFileStoreCell and to DocumentCell and both causes the cast error.

Thank you a lot!!!

Never ever cast to a cell implementation! A column can contain different compatible cell implementations. Always cast to the corresponding DataValue interface, which I believe is DocumentValue in your case.

Hi thor.

Before casting, I assure the cell has the DocumentBufferedFileStoreCell class by using the colIndex pointing to a Document Cell:

String colName = "Preprocessed Document";
int colIndex = inData[0].getDataTableSpec().findColumnIndex(colName);

I based my cast on method execute() of  org.knime.ext.textprocessing.nodes.
  transformation.sentenceextraction.SentenceExtractionNodeModel class, which made use of exactly the DocumentValue interface:

protected BufferedDataTable[] execute(final BufferedDataTable[] inData,
            final ExecutionContext exec) throws Exception {
        try {
            long count = 0;
            RowIterator it = inData[0].iterator();
            while (it.hasNext()) {
                DataRow row =;
                Document doc = ((DocumentValue)row.getCell(m_docColIndex)).getDocument();
                DataCell docCell = docCache.getInstance(doc);

But when I try to do the same:

        while (it.hasNext()) {
        	DataRow r =;
        	DataCell c = r.getCell(colIndex);
        	DocumentValue dv = (DocumentValue)c;
        	Document d = dv.getDocument();


I get:

2017-07-02 14:01:22,873 : DEBUG : KNIME-Worker-0 : BrTagger : BrTagger : 0:8 : Execute failed: cannot be cast to

java.lang.ClassCastException: cannot be cast to

The Cell returned from the getCell method has the type DocumentBufferedFileStoreCell, which inherits AbstractDocumentFileStoreCell, which has the public Document getDocument(). That was the only way I could find to read a Document text.

Is there any other way? I might be really missing something...

This looks like you have two different versions of the DocumentValue interface in your classpath.

Yes, you are right!!!

I've put the org.knime.ext.textprocessing as an external jar included on my bundle (including it on Bundle-ClassPath and on bin.includes) because I was getting the error

java.lang.ClassNotFoundException: cannot be found by org.knime.brtagger_1.0.0

when the right thing to do is to include it as a dependency (Require-Bundle), not as a binary. 

Thank you a lot, Thor!!!