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=[com.lilly.knime.nodes.analyzer.AnalyzerNodeFactory] 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.
java.lang.ExceptionInInitializerError
    at com.lilly.knime.nodes.analyzer.AnalyzerNodeFactory.createNodeModel(AnalyzerNodeFactory.java:21)
    at com.lilly.knime.nodes.analyzer.AnalyzerNodeFactory.createNodeModel(AnalyzerNodeFactory.java:1)
    at org.knime.core.node.NodeFactory.callCreateNodeModel(NodeFactory.java:458)
    at org.knime.core.node.Node.<init>(Node.java:276)
    at org.knime.core.node.workflow.WorkflowManager.internalAddNewNode(WorkflowManager.java:502)
    at org.knime.core.node.workflow.WorkflowManager.createAndAddNode(WorkflowManager.java:471)
    at org.knime.workbench.editor2.commands.CreateNodeCommand.execute(CreateNodeCommand.java:112)
    at org.eclipse.gef.commands.CommandStack.execute(CommandStack.java:199)
    at org.knime.workbench.editor2.NodeTemplateDropTargetListener2.drop(NodeTemplateDropTargetListener2.java:186)
    at org.eclipse.jface.util.DelegatingDropAdapter$3.run(DelegatingDropAdapter.java:211)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
    at org.eclipse.jface.util.DelegatingDropAdapter.drop(DelegatingDropAdapter.java:209)
    at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:90)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
    at org.eclipse.swt.dnd.DropTarget.Drop(DropTarget.java:456)
    at org.eclipse.swt.dnd.DropTarget$3.method6(DropTarget.java:258)
    at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
    at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
    at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:363)
    at org.eclipse.swt.dnd.DragSource.access$0(DragSource.java:289)
    at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:172)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.knime.product.rcp.KNIMEApplication.start(KNIMEApplication.java:128)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    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(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.NullPointerException
    at org.knime.core.node.port.PortType.getPortObjectSpecClass(PortType.java:193)
    at org.knime.core.node.port.PortType.<init>(PortType.java:88)
    at com.lilly.knime.nodes.analyzer.AnalyzerNodeModel.<clinit>(AnalyzerNodeModel.java:45)
    ... 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!