Problems with AbstractPortObject from 2.x used in 3.1

Hi, I'm developing with knime-2 api and derived my port object from AbstractPortObject:

public class SeesarPortObject extends AbstractPortObject {

    public static final PortType TYPE = new PortType(SeesarPortObject.class);
    public static final PortType TYPE_OPTIONAL = new PortType(SeesarPortObject.class, true);
    :

Everything works fine in knime-2.x, but in knime-3.1, when trying to save an executed workflow with a node that has such a port type as output, I get the following error in knime.log:

2016-06-22 09:32:18,384 : DEBUG : ModalContext : SaveWorkflowRunnable :  :  : Could not save workflow
java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Optional.java:135)
	at org.knime.core.node.FileNodePersistor.savePortObject(FileNodePersistor.java:1425)
	at org.knime.core.node.FileNodePersistor.savePort(FileNodePersistor.java:1389)
        :

I have seen that built-in port objects like ImagePortObject were updated for knime-3 api to use the PortTypeRegistry:

public static final PortType TYPE = PortTypeRegistry.getInstance().getPortType(ImagePortObject.class);

And, when looking into the PortTypeRegistry's method getObjectSerializer(), there is a special legacy handling to deal with knime-2 PortTypes, and there another special treatment of AbstractSimplePortObject, but no special handling of AbstractPortObject.

My question: Has anybody else got similar problems with nodes using AbstractPortObject developed in knime-2 and using in knime-3?

Best regards, Frank

I already found a workaround:

Implementing PortObject instead of extending AbstractPortObject works also with 3.1.2.

public class SeesarPortObject implements PortObject {

    public static final PortType TYPE = new PortType(SeesarPortObject.class);
    public static final PortType TYPE_OPTIONAL = new PortType(SeesarPortObject.class, true);

    //
    // private members
    //
    private static SeesarPortObjectSerializer m_serializer;

    :


    public static final PortObjectSerializer<SeesarPortObject> getPortObjectSerializer() {
        if (m_serializer == null) {
            m_serializer = new SeesarPortObjectSerializer();
        }
        return m_serializer;
    }

    :

 

Hi Frank,

looks good, does this solve your problems or shall I find one of our developers to help you?

Cheers, Iris

Hi Iris,

thanks for asking.  No, I'm fine with direct implementing PortObject, in fact, it's not really much more code, it's just having an additional serializer, but with the methods I would have otherwise to implement in my PortObject class.

Cheers, Frank