Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) loadFromString error (Read 14459 times)
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
loadFromString error
Jul 1st, 2011 at 2:33pm
Print Post  
Hello,

We bought the JDiagram yesterday after long tests.

We have sometimes an error when we use the loadFromString function.

This is the error :
com.mindfusion.diagramming.XmlException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.

at com.mindfusion.diagramming.Diagram.a(Unknown Source)

at com.mindfusion.diagramming.Diagram.a(Unknown Source)

at com.mindfusion.diagramming.Diagram.loadFromString(Unknown Source)

at VegaGrapheVisu.creerGraphe(VegaGrapheVisu.java:137)

at VegaGrapheVisuDemo.main(VegaGrapheVisuDemo.java:63)
Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.

at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(Unknown
Source)

at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(Unknown Source)

at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(U
nknown Source)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)

at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)

... 5 more

Our diagram contains 492 nodes and 249 links.
We created it with a developped calculated layout.

We used after a saveToString() function of the Diagram and pass the returned String to another class which call the loadFromString function.

What do you need to reproduce the problem ?

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFromString error
Reply #1 - Jul 1st, 2011 at 3:19pm
Print Post  
Do you save the diagram in CompressedXml or Xml format?
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: loadFromString error
Reply #2 - Jul 1st, 2011 at 3:39pm
Print Post  
I think it is in a text format.

this is my code :

Code
Select All
_flowChart.saveToString(); 



I don't use XML format

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFromString error
Reply #3 - Jul 1st, 2011 at 4:50pm
Print Post  
This saves the diagram as a base64-encoded Java object stream. A base64 encoded binary diagram string always starts with "rO0A" characters, can you see them in the string you are getting the exception with?

If you are getting XML exceptions from loadFromString, that means either the string starts with a < symbol (which should not appear in a base64 sequence) and the diagram decides it's an XML document, or binary deserialization failed for some reason.

Binary serialization might fail if the string is somehow corrupted, or if the file contains objects from a class that is no longer available in your application.
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: loadFromString error
Reply #4 - Jul 4th, 2011 at 7:41am
Print Post  
Hello,

The string starts with the "rO0A" characters.

How can I send you the contents of the string ?

Regards
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFromString error
Reply #5 - Jul 4th, 2011 at 8:28am
Print Post  
Paste it into a text file and email the file to support@mindfusion.eu.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFromString error
Reply #6 - Jul 4th, 2011 at 10:33am
Print Post  
Are you sure that was the diagram you can't load? loadFromString worked for me and loaded this:
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: loadFromString error
Reply #7 - Jul 4th, 2011 at 10:51am
Print Post  
Yes,

The error is in the loadFromString function.

Remember the stack of the error :
com.mindfusion.diagramming.XmlException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceExceptio n: Invalid byte 1 of 1-byte UTF-8 sequence.

at com.mindfusion.diagramming.Diagram.a(Unknown Source)

at com.mindfusion.diagramming.Diagram.a(Unknown Source)

at com.mindfusion.diagramming.Diagram.loadFromString(Unknown Source)

at VegaGrapheVisu.creerGraphe(VegaGrapheVisu.java:137)

at VegaGrapheVisuDemo.main(VegaGrapheVisuDemo.java:63)


The diagram is based on a database request.
I can give you my classes which loaded the datas from flat files (nodes and links separated files) to reproduce the incident.
This sample allways generates the error.

Here is a sample code of the generation of the diagram
Code
Select All
public String creerGraphe () {


String retour = "";



erreur = "";
// Code which creates the diagram
.....





retour = _flowChart.saveToString();


wf_trace ("Début graphe\r\n" + retour + "\r\nFin graphe", false);


close(false);


return retour;

}
 



And this is the code which calls the creerGraphe function in the visual class
Code
Select All
public void creerGraphe () {


this.validate();


String valeur = graphe.creerGraphe();


if (valeur != null) _flowChart.loadFromString(valeur);


chargerComboTaches();


overview.update();

}
 



Regards
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFromString error
Reply #8 - Jul 4th, 2011 at 11:25am
Print Post  
Are you getting the error every time? I don't see how it can load in my project but not in yours, or throwing exceptions only occasionally, except maybe if you are loading the diagram from another thread?

The control is not thread-safe, and you must load the diagram only from the Swing UI thread. If your database gives you the result asynchronously via callback called from a worker thread, you will have to use SwingUtilities.InvokeAndWait to call loadFromString from the UI thread.
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: loadFromString error
Reply #9 - Jul 4th, 2011 at 11:39am
Print Post  
I have this error at every time. Not for all graphs. It can maybe come from my datas.

The graph is loaded in the same thread.
The loadFromString is done in the UI thread.

Do you want the code : only 5 classes, 2 flat files and a shl file ?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFromString error
Reply #10 - Jul 4th, 2011 at 11:56am
Print Post  
It seems you have the main() method in the call stack. main() runs in a different thread than the Swing dispatch thread, and you will get all kind of strange exceptions if Swing starts to repaint the diagram while it is still loading in main().

If I remember correctly, it should be safe to modify Swing component from main() only if you haven't yet called the pack() or show() methods of the main window. If you are calling loadFromString() after these methods, move it before them.

If it still does not work, try calling loadFromString from some window event handler such as windowOpened.
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: loadFromString error
Reply #11 - Jul 4th, 2011 at 12:16pm
Print Post  
I have a strange phenomen. I have changed my code like this to avoid the repainting of the graphe :
Code
Select All
public void creerGraphe () {


this.validate();


[color=Red]_flowChartView.suspendRepaint();[/color]

String valeur = graphe.creerGraphe();


if (valeur != null) _flowChart.loadFromString(valeur);
[color=Red]_flowChartView.resumeRepaint();[/color]

chargerComboTaches();


overview.update();

}
 



and now I have the error in the savetoString function :

Exception in thread "main" java.lang.StackOverflowError

at java.util.concurrent.ConcurrentHashMap$Segment.get(Unknown Source)

at java.util.concurrent.ConcurrentHashMap.get(Unknown Source)

at java.io.ObjectStreamClass.lookup(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at com.mindfusion.diagramming.Serialization.writeTag(Unknown Source)

at com.mindfusion.diagramming.DiagramItem.writeExternal(Unknown Source)

at com.mindfusion.diagramming.DiagramNode.writeExternal(Unknown Source)

at com.mindfusion.diagramming.ShapeNode.writeExternal(Unknown Source)

at java.io.ObjectOutputStream.writeExternalData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at com.mindfusion.diagramming.ConnectionPoint.writeExternal(Unknown Source)

at java.io.ObjectOutputStream.writeExternalData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at com.mindfusion.diagramming.DiagramLink.writeExternal(Unknown Source)

at java.io.ObjectOutputStream.writeExternalData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at com.mindfusion.diagramming.BaseList.writeExternal(Unknown Source)

at java.io.ObjectOutputStream.writeExternalData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at com.mindfusion.diagramming.DiagramNode.writeExternal(Unknown Source)

at com.mindfusion.diagramming.ShapeNode.writeExternal(Unknown Source)

at java.io.ObjectOutputStream.writeExternalData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at com.mindfusion.diagramming.ConnectionPoint.writeExternal(Unknown Source)

at java.io.ObjectOutputStream.writeExternalData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at com.mindfusion.diagramming.DiagramLink.writeExternal(Unknown Source)

at java.io.ObjectOutputStream.writeExternalData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)

at com.mindfusion.diagramming.BaseList.writeExternal(Unknown Source)

at java.io.ObjectOutputStream.writeExternalData(Unknown Source)

at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

at java.io.ObjectOutputStream.writeObject0(Unknown Source)

at java.io.ObjectOutputStream.writeObject(Unknown Source)
.........

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFromString error
Reply #12 - Jul 4th, 2011 at 12:34pm
Print Post  
As I said, you should move the code before the window.show() call or to a window event handler. Even if you call suspendRepaint(), Swing might start sending mouse, layout, keyboard, etc. events to the diagram while it is still loading in main. And you must do that for all diagram APIs you call for initialization (such as overview.update), not only loadFromString.
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: loadFromString error
Reply #13 - Jul 4th, 2011 at 12:51pm
Print Post  
Ok, so I modify my window to not call the Jdiagram function in the main event.

Now , the creerGraphe function which wall call in the main code of VegaGrapheVisuDemo class is not yet called.

I put this in a JButton of my window.
I still have the problem.

Regards
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: loadFromString error
Reply #14 - Jul 4th, 2011 at 2:39pm
Print Post  
Please email us the test project.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint