Create a node with no input ports

I have developed a node that originally had 1 input port and 1 output port. After getting user input, I need to remove the input port. Apparently, the way the node is going to be used is that it will be configured thru flow variables and then retrieves information from the file given in the "import File" variable.

When I tried to set up the node with zero input ports by calling super(0, 1) in the NodeModel constructor, I get an error when I try use the node in a workflow saying: "The selected node could not be created due to the following reason: null." Does anyone have experience creating a node with no input ports? Or is this even possible?

Yes, source nodes are possible to create. By any chance did you miss changing the node's xml description? Could you post the full stactrace of the problem?

I've just looked at a node a colleague has built.  The constructor uses super(0, 1) and it still extends NodeModel.

When do you get that error?

I got the error when I tried to drop the Node in the workflow.

I'm kind of thinking that it has something to do with the fact that I went from 1 input port to 0. there may be something else I need to change other than the constructor.  Something may still be looking for data or a value from an input port.

Here is a snippet from the knime.log file after I tried to drop the node into the workflow:

2014-02-13 09:10:07,075 DEBUG main WorkflowManager : Loaded workflow from "C:\Program Files\Knime\eclipse_knime_2.9.0\plugins\org.knime.base_2.9.0.0040707\metanode_templates\Looper"  with no errors
2014-02-13 09:10:07,075 DEBUG main NodeContainer : Setting dirty flag on Loop x-times 1:5
2014-02-13 09:10:07,075 DEBUG main RepositoryManager : Found meta node definition 'looper': Loop x-times
2014-02-13 09:10:37,638 DEBUG main NodeTemplateDropTargetListener2 : drop: DropTargetEvent{DropTarget {} time=1474886984 data=[] x=670 y=343 item=null operations=1 operation=1 feedback=1 dataTypes={ 50795 } currentDataType=50795}
2014-02-13 09:10:37,638 DEBUG main CreateNodeCommand : Node cannot be created.
    at org.knime.core.node.NodeFactory.callCreateNodeModel(
    at org.knime.core.node.Node.<init>(
    at org.knime.core.node.workflow.WorkflowManager.internalAddNewNode(
    at org.knime.core.node.workflow.WorkflowManager.createAndAddNode(
    at org.knime.workbench.editor2.commands.CreateNodeCommand.execute(
    at org.eclipse.gef.commands.CommandStack.execute(
    at org.knime.workbench.editor2.NodeTemplateDropTargetListener2.drop(
    at org.eclipse.jface.util.DelegatingDropAdapter$
    at org.eclipse.ui.internal.JFaceUtil$
    at org.eclipse.jface.util.DelegatingDropAdapter.drop(
    at org.eclipse.swt.dnd.DNDListener.handleEvent(
    at org.eclipse.swt.widgets.EventTable.sendEvent(
    at org.eclipse.swt.widgets.Widget.sendEvent(
    at org.eclipse.swt.widgets.Widget.sendEvent(
    at org.eclipse.swt.widgets.Widget.sendEvent(
    at org.eclipse.swt.widgets.Widget.notifyListeners(
    at org.eclipse.swt.dnd.DropTarget.Drop(
    at org.eclipse.swt.dnd.DropTarget$3.method6(
    at org.eclipse.swt.internal.ole.win32.COMObject.callback6(
    at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
    at org.eclipse.swt.dnd.DragSource.drag(
    at org.eclipse.swt.dnd.DragSource.access$0(
    at org.eclipse.swt.dnd.DragSource$1.handleEvent(
    at org.eclipse.swt.widgets.EventTable.sendEvent(
    at org.eclipse.swt.widgets.Widget.sendEvent(
    at org.eclipse.swt.widgets.Display.runDeferredEvents(
    at org.eclipse.swt.widgets.Display.readAndDispatch(
    at org.eclipse.ui.internal.Workbench.runEventLoop(
    at org.eclipse.ui.internal.Workbench.runUI(
    at org.eclipse.ui.internal.Workbench.access$4(
    at org.eclipse.ui.internal.Workbench$
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(
    at org.knime.product.rcp.KNIMEApplication.start(
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(
    at org.eclipse.equinox.launcher.Main.basicRun(
    at org.eclipse.equinox.launcher.Main.main(
Caused by: java.lang.NullPointerException
    at org.knime.core.node.port.PortType.getPortObjectSpecClass(
    at org.knime.core.node.port.PortType.<init>(
    ... 52 more
2014-02-13 09:14:10,488 DEBUG main NodeContainer : Setting dirty flag on KNIME_project 0
2014-02-13 09:14:10,488 DEBUG KNIME-Workflow-Notifier WorkflowEditor : Workflow event triggered: WorkflowEvent [type=WORKFLOW_DIRTY;node=0;old=null;new=null;timestamp=Feb 13, 2014 9:14:10 AM]
2014-02-13 09:14:10,488 DEBUG KNIME-Workflow-Notifier KnimeResourceNavigator : ROOT's workflow has changed WORKFLOW_DIRTY
2014-02-13 09:14:10,488 DEBUG KNIME-Workflow-Notifier WorkflowRootEditPart : WorkflowRoot: workflow changed, refreshing children/connections..


It seems the static initializer of your class is causing this problem.

I found the problem! One of the leftover "Trials" from my Trial and Error approach was the issue. I thought that trying to create an empty PortType with a null PortObject would work:

public static final PortType EMPTY_PORT_TYPE = new PortType(null, true);

I tried this before I found the super(0,1) solution and it got left in there.

Thanks for everyone's help!