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


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
LoadFromString Problem
Mar 10th, 2009 at 1:19pm
Print Post  
Hello,

I am trying your last version of JDiagram (V2.1) and I have a problem (even in V2.0.1).

On some graphs, I have an exception when I use the Diagram.loadFromString() function.

I have a graph with more than 2000 nodes and links. I don't use any layout.

At the end of the creation of the graph I save the content of the graph in a String with _flowChart.saveToString();

In an other frame, I try to load my graph with _flowChart.loadFromString([i]'string with my saved graph'[/i])

_flowChart is a Diagram.

I have the following exception :

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:139)
at VegaGrapheVisuDemo.main(VegaGrapheVisuDemo.java:47)
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

I can send you a file with the saved graph to try to reproduce the incident.
(I use the loadfromstring function because I have to give the string to the JDiagramApplet).

Best regards.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LoadFromString Problem
Reply #1 - Mar 10th, 2009 at 3:35pm
Print Post  
Hi,

Please email the file to support@mindfusion.eu. Last time we tried (a couple of years ago), the control could load at most about 7000 items in total when running as an applet. Otherwise deserialization failed because JVM restricts applets to some amount of memory they are allowed to use.

Stoyan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: LoadFromString Problem
Reply #2 - Mar 17th, 2009 at 11:06am
Print Post  
Hi,

Have you good news ?

To answer to your last message, I found in the new java plugin the possibility to specify the memory of the applet with a html tag in the applet declaration like this :

<APPLET archive="my_applet.jar" code="MyApplet" width="300" height="300">
<PARAM name="java_arguments" value="-Xmx128m">
</APPLET>

You can also do it in the applet runtime settings of the java control panel.

Maybe we can have less memory problems.

https://jdk6.dev.java.net/plugin2/#JAVA_ARGUMENTS


Regards,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LoadFromString Problem
Reply #3 - Mar 17th, 2009 at 12:04pm
Print Post  
Hi JR,

The string from the file you've emailed us is not a valid base64 string. How exactly your VegaGrapheVisu class gets this string from the server?

Stoyan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: LoadFromString Problem
Reply #4 - Mar 17th, 2009 at 1:01pm
Print Post  
Hi Stoyo,

In the sample I sent to you, I am not working with a server and an applet.

It is a sample standalone application.
I get nodes and links from a database, and i create a graph.

The class which draws the graph is a non swing class connected to the database. If I don't use swing, it's because I can generate my graph in unix servers with a tomcat server started in a non graphic environment (in this case swing does not work ...).

This class (we call it CreerGraphe) works with your Diagram class.
-----------------------------------------------------------------
I create the nodes with :

ShapeNode tache = new ShapeNode ();
tache.setBounds(boxPosX(colonne+1),boxPosY(tac.getPalier()+1),LNG_TACHE_X, LNG_TACHE_Y);
_flowChart.getNodes().add(tache);

tache.setText(tac.getNom() + "\r\n<" + tac.getLocalisation() + ">");
tache.setShape(gestionShape.getShape(tac.getForme()));
tache.setFont(font);
TextFormat txtf = new TextFormat(Align.Near,Align.Center);
txtf.setNoWrap(true);
tache.setTextFormat(txtf);
StringBuffer texte = new StringBuffer ();
if (tac.getTooltip() != null && !tac.getTooltip().trim().equals("")) {

texte.append (tac.getTooltip());

texte.append (" --> ");
}
texte.append (tac.getEtat());
tache.setToolTip(texte.toString());
tache.setTag("T" + FORMAT11.format(tac.getNumero()));
tache.setEnabledHandles(0);
tache.setPen(new Pen (0, invertColor(tac.getContour())));
tache.setBrush(new SolidBrush(invertColor(tac.getFond())));
tache.setAnchorPattern(gestionShape.getAnchorPattern(tac.getForme()));

-----------------------------------------------------------------
The links are created using Anchor and PointList.
This is one example -> I use several methods according to the positions and the shapes of the nodes :

lien = new DiagramLink (_flowChart, org, dest);
_flowChart.getLinks().add(lien);
lien.setHeadShape(ArrowHead.Triangle);
lien.setPen(formeLien(lie));
lien.setOriginAnchor(anchor_org);
lien.setDestinationAnchor(anchor_dest);
PointList pl = lien.getControlPoints();
Point2D.Float point = (Point2D.Float) pl.get(1).clone();
point.x = posx2;
point.y = posy2;
pl.set(1, point);
point = (Point2D.Float) pl.get(2).clone();
point.x = posx3;
point.y = posy3;
pl.set(2, point);
point = (Point2D.Float) pl.get(3).clone();
point.x = posx3;
point.y = posy4;
pl.set(3, point);
point = (Point2D.Float) pl.get(4).clone();
point.x = posx5;
point.y = posy4;
pl.set(4, point);
lien.updateFromPoints();
lien.setLocked(false);

-----------------------------------------------------------------
When I complete the graph I return to the calling function a string getted with
_flowChart.saveToString();
-----------------------------------------------------------------

The calling function is in an inherited class from JFrame (VegaGrapheVisu).
This class has your Diagram, DiagramView and overview classes.

_flowChartView.setDiagram(_flowChart);

// graphe.creerGraphe returns _flowChart.saveToString();

String valeur = graphe.creerGraphe();
_flowChart.loadFromString(valeur);

If you have more questions, don't hesitate.
It will be difficult to send you some code to reproduce the problem. I only have one abort case ... and you need the database ...

Regards

JR

(Sorry for my english...)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LoadFromString Problem
Reply #5 - Mar 17th, 2009 at 1:24pm
Print Post  
Hi JR,

There are some '\n' substrings in the string - not the new-line symbol, but backslash followed by 'n' as plain text. Any idea where they came from? Once we removed them, loadFromString worked correctly.

Stoyan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: LoadFromString Problem
Reply #6 - Mar 17th, 2009 at 1:54pm
Print Post  
Hi,

I have reproduce the problem in eclipse in debug mode.
The string gived by the saveToString method contains the 2 characters "\n" you said.

In the text of the node, I put
tache.setText(tac.getNom() + "\r\n<" + tac.getLocalisation() + ">");

But it's a carriage return/ line feed character...

Maybe the \n (2 chars) cames from the database. But I have seen the resultset and there is no '\n' characters.

When I remove these characters with valeur=valeur.replaceAll("\\n","")
I still have the same problem.

When I take a good graph, I have also '\n' characters. When I remove them, there is no abort.

Regards.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LoadFromString Problem
Reply #7 - Mar 17th, 2009 at 2:11pm
Print Post  
Do you have any Unicode text symbols in that diagram that are not in the ones that load successfully?
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: LoadFromString Problem
Reply #8 - Mar 17th, 2009 at 3:12pm
Print Post  
I don't think so.
My database has a collation 1252LATIN1 (charset cp1252).
The resultset don't have a unicode character.

Regards
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: LoadFromString Problem
Reply #9 - Mar 18th, 2009 at 10:15am
Print Post  
Hi Stoyo,

Do you receive the sources I send you tomorrow ?

Regards

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LoadFromString Problem
Reply #10 - Mar 18th, 2009 at 11:22am
Print Post  
If you send them tomorrow, we might have not received them yet 8)

Are you using the Sun's JRE and the SAX parser that comes with it? We have code that first tries to load the XML as UTF8, and if that fails it catches the exception and tries to load it as UTF16. However the exception that JDiagram expects to get is different than the one from your stack trace - MalformedByteSequenceException? We traced this in debug mode and the file loaded successfully as UTF16, so something in your environment is not exactly the same as in our test.

Stoyan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: LoadFromString Problem
Reply #11 - Mar 18th, 2009 at 11:45am
Print Post  
Hi,

Ok I understand the tomorrow Grin Grin (yesterday Roll Eyes)

I sent this now again in case of you will not received it Wink

I don't understand very well your question. I am using the jre 1.6.0_12 from Sun.
You have all the sources of my application, and it seems that I don't use SAX.

I don't know how to help you for the UTFx problem.
What kind of information do you need ?

Regards

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LoadFromString Problem
Reply #12 - Mar 18th, 2009 at 12:37pm
Print Post  
Hi,

Yes, we received them both times 8) However this worked in our test. Are you by chance using some commercial Java environment based on Eclipse, e.g. from IBM or Oracle? Both Oracle and IBM provide their own XML parsers as far as we know, and there might be some difference in how they handle different encodings. The XML parsers to use can be changed through some system settings, and Java-based application servers (such as Tomcat or WebSphere) could specify their own parsers. As a quick work-around you could use saveToString(SaveToStringFormat.Base64) instead of Xml or CompressedXml. Otherwise we'll have to try this with the same parser that you are using. Since you mentioned 1.6.0_12, the latest JRE we have tried is JRE 6 update 11; we'll test this with 12 as well.

Stoyan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: LoadFromString Problem
Reply #13 - Mar 18th, 2009 at 1:46pm
Print Post  
Hi,

I am using Eclipse Version: 3.4.1
Build id: M20080911-1700 (not commercial).

I tryed you saveToString(SaveToStringFormat.Base64) workaround and it does not work (same error).

I try to modify the xml parameters of eclipse (Menu Window -> Preferences -> XML -> XML Files) to change the encoding to utf-16 instead of utf-8) and now no graph works.
After, I put the default value to this parameter, and now no graph works.

I don't know if there is a link, but it becomes difficult to understand what is happening.

Angry Angry Angry

What can I do ?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: LoadFromString Problem
Reply #14 - Mar 18th, 2009 at 2:57pm
Print Post  
You could wait for us to try it with jre 1.6.0_12, or allow a terminal connection for our developer to try that on your system. The Base64 parameter will help only for newly saved diagrams. The strings already saved in your database still require an XML parser to load.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint