I'm trying to get a basic JUNG graph example running - I was able to get the following code to run in a standalone java program but when I put the same code in a server-side jar built using Maven, it fails with a ArrayStoreException on the VisualizationImageServer initialization:
public Response getGraph() throws IOException {
//log.info("Starting graph rendering");
try {
DirectedSparseGraph<String, Number> g = new DirectedSparseGraph();
String[] v = createVertices(10);
createEdges(v);
vv = new VisualizationImageServer<String,Number>(new KKLayout<String,Number>(graph), new Dimension(600,600));
renderGraph(vv);
...}
This line fails:
vv = new VisualizationImageServer<String,Number>(new KKLayout<String,Number>(graph), new Dimension(600,600));
Error message snippet:
java.lang.ArrayStoreException: edu.uci.ics.jung.algorithms.layout.KKLayout
at edu.uci.ics.jung.visualization.layout.ObservableCachingLayout.<init>(ObservableCachingLayout.java:50)
at edu.uci.ics.jung.visualization.DefaultVisualizationModel.setGraphLayout(DefaultVisualizationModel.java:91)
at edu.uci.ics.jung.visualization.DefaultVisualizationModel.<init>(DefaultVisualizationModel.java:74)
at edu.uci.ics.jung.visualization.BasicVisualizationServer.<init>(BasicVisualizationServer.java:150)
at edu.uci.ics.jung.visualization.VisualizationImageServer.<init>(VisualizationImageServer.java:40)
My best guess is that on your server side code, you have more than one version of jung that conflict with each other.
On line 50 of ObservableCachingLayout
in jung-visualization version 2.0, the delegate (KKLayout
) is added to a org.apache.commons.collections15.Transformer[]
array, because the KKLayout
delegate is (supposed to be) an instance of a Transformer
.
Your array store exception that calls out the KKLayout
as the problem makes me think that the earlier version 2.0 of ObservableCachingLayout
is getting a version 2.1 or later KKLayout
delegate (from jung-algorithms) that is not a Transformer
, but is instead a com.google.common.base.Function
.
I can't verify that this is the actual problem, but I believe that this theory addresses a possible cause of the specific errors you are seeing.