Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Long cannot be cast to a String" when either exporting a graph or saving a gephi file #679

Closed
thallium205 opened this issue Oct 3, 2012 · 3 comments

Comments

@thallium205
Copy link

(As advised from this forum post -> https://forum.gephi.org/viewtopic.php?f=29&t=2233)

"A way to reproduce the bug, or a description of what you was doing. "

  • After importing a sub-graph into Gephi using the Neo4j plugin with a traversal import, I am unable to either export or save a .gephi file. I have had much success in doing this procedure with other graphs using a full traversal, but I believe this is a particularly different case because the graph in which I am importing is extremely large - roughly 3 million nodes and 3 million edges. It should be noted that once this graph is in Gephi, I proceed to apply several filters in order to reduce it to a much smaller and more manageable size (which works perfectly). The data I am importing is also a mere subsection of a much larger Neo4j database - roughly 80 million nodes and edges. I suspect the ID numbers that my graph database has generated are actual Longs which may result in such an edge case. I should also note that the Data Explorer is unable to pull up the data - it has a particular problem in exporting the edges into a CSV - it omits both the source ID and destination ID portions of the data which I think is what is causing the problem!

"The configuration of your machine: Windows/Mac/Linux and system version; type of graphic card: Nvidia/ATI/integrated-to-motherboard. "

  • Windows 7, 26 GB of RAM, Core I7, Nvidia Cards

"The Java stack trace if exists."
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at org.gephi.desktop.io.export.DesktopExportController$2.run(DesktopExportController.java:107)
at org.gephi.utils.longtask.api.LongTaskExecutor$RunningLongTask.run(LongTaskExecutor.java:251)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at org.gephi.graph.dhns.node.NodeDataImpl.getId(NodeDataImpl.java:238)
at org.gephi.io.exporter.plugin.ExporterGEXF.writeNodes(ExporterGEXF.java:371)
at org.gephi.io.exporter.plugin.ExporterGEXF.writeGraph(ExporterGEXF.java:266)
at org.gephi.io.exporter.plugin.ExporterGEXF.execute(ExporterGEXF.java:223)
at org.gephi.io.exporter.impl.ExportControllerImpl.exportFile(ExportControllerImpl.java:131)
at org.gephi.desktop.io.export.DesktopExportController$2.run(DesktopExportController.java:104)
... 7 more
Real iterations 150
Entering liquid stage...
Liquid stage completed in 444 seconds, total energy = 30899111418920960.000000
Entering expansion stage...
Expansion stage completed in 453 seconds, total energy = 77994909696.000000
Entering cool-down stage...
Real iterations 300
Entering liquid stage...
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at org.gephi.desktop.io.export.DesktopExportController$2.run(DesktopExportController.java:107)
at org.gephi.utils.longtask.api.LongTaskExecutor$RunningLongTask.run(LongTaskExecutor.java:251)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at org.gephi.graph.dhns.node.NodeDataImpl.getId(NodeDataImpl.java:238)
at org.gephi.io.exporter.plugin.ExporterGEXF.writeNodes(ExporterGEXF.java:371)
at org.gephi.io.exporter.plugin.ExporterGEXF.writeGraph(ExporterGEXF.java:266)
at org.gephi.io.exporter.plugin.ExporterGEXF.execute(ExporterGEXF.java:223)
at org.gephi.io.exporter.impl.ExportControllerImpl.exportFile(ExportControllerImpl.java:131)
at org.gephi.desktop.io.export.DesktopExportController$2.run(DesktopExportController.java:104)
... 7 more
SEVERE [org.netbeans.swing.outline.DefaultOutlineCellRenderer]
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at org.gephi.graph.dhns.node.NodeDataImpl.getId(NodeDataImpl.java:238)
at org.gephi.graph.dhns.node.AbstractNode.toString(AbstractNode.java:285)
at org.gephi.graph.dhns.utils.TreeNodeWrapper$TreeNodeImpl.toString(TreeNodeWrapper.java:160)
at org.openide.awt.HtmlRendererImpl.configureFrom(HtmlRendererImpl.java:197)
at org.openide.awt.HtmlRendererImpl.getTableCellRendererComponent(HtmlRendererImpl.java:131)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
[catch] at org.netbeans.swing.outline.DefaultOutlineCellRenderer$HtmlRenderer$Renderer.getTableCellRendererComponent(DefaultOutlineCellRenderer.java:565)
at org.netbeans.swing.outline.DefaultOutlineCellRenderer.getTableCellRendererComponent(DefaultOutlineCellRenderer.java:244)
at org.netbeans.swing.etable.ETableColumn.estimatedWidth(ETableColumn.java:365)
at org.netbeans.swing.etable.ETableColumn.updatePreferredWidth(ETableColumn.java:282)
at org.netbeans.swing.etable.ETable.updatePreferredWidths(ETable.java:1764)
at org.netbeans.swing.etable.ETable.setModel(ETable.java:863)
at org.netbeans.swing.outline.Outline.setModel(Outline.java:634)
at org.gephi.desktop.datalab.NodeDataTable.refreshModel(NodeDataTable.java:258)
at org.gephi.desktop.datalab.DataTableTopComponent$8.run(DataTableTopComponent.java:471)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
at java.awt.EventQueue.access$000(EventQueue.java:102)
at java.awt.EventQueue$3.run(EventQueue.java:662)
at java.awt.EventQueue$3.run(EventQueue.java:660)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:671)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:162)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
SEVERE [org.openide.util.Exceptions]
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at org.gephi.graph.dhns.node.NodeDataImpl.getId(NodeDataImpl.java:238)
at org.gephi.graph.dhns.node.AbstractNode.toString(AbstractNode.java:285)
at org.gephi.graph.dhns.utils.TreeNodeWrapper$TreeNodeImpl.toString(TreeNodeWrapper.java:160)
at org.openide.awt.HtmlRendererImpl.configureFrom(HtmlRendererImpl.java:197)
at org.openide.awt.HtmlRendererImpl.getTableCellRendererComponent(HtmlRendererImpl.java:131)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
[catch] at org.netbeans.swing.outline.DefaultOutlineCellRenderer$HtmlRenderer$Renderer.getTableCellRendererComponent(DefaultOutlineCellRenderer.java:565)
Caused: java.lang.IllegalStateException
at org.netbeans.swing.outline.DefaultOutlineCellRenderer$HtmlRenderer$Renderer.getTableCellRendererComponent(DefaultOutlineCellRenderer.java:576)
at org.netbeans.swing.outline.DefaultOutlineCellRenderer.getTableCellRendererComponent(DefaultOutlineCellRenderer.java:244)
at org.netbeans.swing.etable.ETableColumn.estimatedWidth(ETableColumn.java:365)
at org.netbeans.swing.etable.ETableColumn.updatePreferredWidth(ETableColumn.java:282)
at org.netbeans.swing.etable.ETable.updatePreferredWidths(ETable.java:1764)
at org.netbeans.swing.etable.ETable.setModel(ETable.java:863)
at org.netbeans.swing.outline.Outline.setModel(Outline.java:634)
at org.gephi.desktop.datalab.NodeDataTable.refreshModel(NodeDataTable.java:258)
[catch] at org.gephi.desktop.datalab.DataTableTopComponent$8.run(DataTableTopComponent.java:471)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
at java.awt.EventQueue.access$000(EventQueue.java:102)
at java.awt.EventQueue$3.run(EventQueue.java:662)
at java.awt.EventQueue$3.run(EventQueue.java:660)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:671)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:162)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Real iterations 300
Entering liquid stage...
Liquid stage completed in 877 seconds, total energy = 24101099459837952.000000
Entering expansion stage...
Expansion stage completed in 916 seconds, total energy = 58664239104.000000
Entering cool-down stage...
Cool-down stage completed in 945 seconds, total energy = 1575196033024.000000
Entering crunch stage...
Crunch stage completed in 384 seconds, total energy = 1144025251840.000000
Entering simmer stage...
Real iterations 600
Entering liquid stage...
WARNING [org.netbeans.core.TimableEventQueue]: too much time in AWT thread org.netbeans.core.ui.sampler.SelfSamplerAction$InternalSampler@c320a3b
Liquid stage completed in 1802 seconds, total energy = 14734741081161728.000000
Entering expansion stage...
Expansion stage completed in 1814 seconds, total energy = 57823096832.000000
Entering cool-down stage...
Cool-down stage completed in 1878 seconds, total energy = 880871211008.000000
Entering crunch stage...
Crunch stage completed in 746 seconds, total energy = 873448734720.000000
Entering simmer stage...
Simmer stage completed in 1089 seconds, total energy = 95320.148438
Layout completed in 7329 seconds with 3004 iterations
SEVERE [org.netbeans.swing.outline.DefaultOutlineCellRenderer]

  • This stack trace is created for each error - which results in a log file nearly 400,000 lines long.

"The log file."
https://dl.dropbox.com/u/2190/messages.log

@panisson
Copy link
Member

I'm having a similar problem, but using the Scripting Console.

Trying to execute the following lines:

>>> n1 = g.addNode()
>>> n2 = g.addNode()
>>> e = g.addEdge(n1,n2)
>>> print e
e1
>>> e.id = 0
>>> print e
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ClassCastException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
>>> e.id = '0'
>>> print e
e0
>>> 

I get the same exception when saving it in .gephi format or gexf format, but not when saving as a csv file.

This seems to be a similar issue as the one described by John, if not exactly the same, so I am adding it to the discussion.

@panisson
Copy link
Member

This issue happens because it is possible to set the node id through the method setValue(String column, Object value) from the AttributeRow class. Any plugin that use this method to set the node id are vulnerable to this bug.

I see three different solutions for it:

  1. Change the method NodeDataImpl.getId() and avoid a cast to String - this is easy and can be done simply by invoking the toString() from the returning object;
  2. Change the method AttributeRowImpl.setValue(AttributeColumn column, Object value), enforcing the value to be a String when the attribute is node id;
  3. Let the plugin developers correct their implementations, by checking that they are passing a String object if the attribute to be set is node id.

@eduramiba
Copy link
Member

This should now be fixed.

mbastian pushed a commit to mbastian/gephi that referenced this issue Nov 18, 2012
@ghost ghost assigned eduramiba Dec 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants