This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 65052 - I18N - [50cat] UTFDataFormatException when I edit web.xml file
Summary: I18N - [50cat] UTFDataFormatException when I edit web.xml file
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: DD Editor (show other bugs)
Version: 5.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Pavel Fiala
URL:
Keywords: I18N
: 65237 65855 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-24 00:31 UTC by vbrabant
Modified: 2005-10-17 15:02 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
web.xml used when problem has been encountered (1.09 KB, text/xml)
2005-09-26 20:57 UTC, vbrabant
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vbrabant 2005-09-24 00:31:59 UTC
[ BUILD # : 20050922 ]
[ JDK VERSION : 1.5.0_05 ]

I open a web.xml file, choose servlet tab, create a new Initialization parameter, and add a description in french, containing characters like éèà.
I save the file. And I obtain the following exception:

A java.io.UTFDataFormatException exception has occurred.
Please report this at http://www.netbeans.org/community/issues.html,
including a copy of your messages.log file as an attachment.
The messages.log file is located in your C:\Documents and Settings\Vincent\.netbeans\5.0\Daily\20050922\var\log folder.

And hereafter the detail:

java.io.UTFDataFormatException: Invalid byte 2 of 3-byte UTF-8 sequence.
	at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
	at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
	at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
	at org.apache.xerces.impl.XMLEntityScanner.scanContent(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanContent(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.netbeans.modules.j2ee.ddloaders.web.DDUtils.parse(DDUtils.java:200)
	at org.netbeans.modules.j2ee.ddloaders.web.DDDataObject.parseDocument(DDDataObject.java:220)
	at org.netbeans.modules.j2ee.ddloaders.web.DDDataObject.validateDocument(DDDataObject.java:214)
	at org.netbeans.modules.j2ee.ddloaders.multiview.DDMultiViewDataObject$ModelSynchronizer.updateData(DDMultiViewDataObject.java:215)
	at org.netbeans.modules.xml.multiview.XmlMultiViewDataSynchronizer$1.run(XmlMultiViewDataSynchronizer.java:45)
	at org.openide.util.Task.run(Task.java:207)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:469)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:870)


And sometimes, but not always, I obtains unreadable characters in the web.xml, in place of éèà
Comment 1 Petr Jiricka 2005-09-25 23:34:41 UTC
Could this be related to issue 64433 ? 

Vincent, do you consider this important enough for the beta release, or is it
sufficient to fix this after beta? Thanks.
Comment 2 Martin Balin 2005-09-26 08:05:06 UTC
Internationalization issue. This bug will be fixed for FCS.
Comment 3 Marek Fukala 2005-09-26 10:29:47 UTC
Vincent, I have tried to follow your steps but I cannot reproduce the problem.
Can you please let me know if the problem you desribes happens every time or is
random? Even it is obvious from the UTFDataFormatEx, but just for sure - does
the web.xml UTF-8 set in the xml header?

I tried to put french characters by using french keyboar and also by copypasting
some french text from web inside but didn't get the error when saving the file.
Also the characters are saved correctly. Can you please attach you web.xml with
the french chars so I am able to reproduce it somehow?
Comment 4 vbrabant 2005-09-26 19:45:04 UTC
UTF-8 is well appearing in the XML file.

For me, it should be fixed for the final release of 5.0 (Is FCS means Final
Release of 5.0)

Please find a step by step flash demo hereafter
ftp://ftp-developpez.com/brabant/flash/NetBeans/5.0/issues/65052.html
Comment 5 Marek Fukala 2005-09-26 20:39:12 UTC
Vincent, the flash movies is great. Could you zip and attach the webmodule used
for the demo besides? I still cannot reproduce using only "éàçè" chars, I
suspect there is an another one which causes the problem. Thanks!!!
Comment 6 vbrabant 2005-09-26 20:57:31 UTC
Created attachment 25198 [details]
web.xml used when problem has been encountered
Comment 7 vbrabant 2005-09-26 20:58:21 UTC
You can find in attach the web.xml file used during the demo
Comment 8 Petr Blaha 2005-09-28 09:43:41 UTC
*** Issue 65237 has been marked as a duplicate of this issue. ***
Comment 9 Marek Fukala 2005-09-29 10:46:11 UTC
The problem is caused by the DDDataObject incorrectly reading the xml file. The
code in the DDDO creates a new InputSource from an InputStream without providing
appropriate encoding:

The code should look something like this:
DDDataObject:195:  

< return new InputSource(createInputStream());

> InputStream is = createInputStream();
> Sring enc = EncodingHelper.detectEncoding(is);
> InputSource isource = new InputSource(is);
> isource.setEncoding(enc);
> return is;

You can find the encoding helper class in org.netbeans.modules.xml.core.lib
package of xml/core module. However the class is not public, and you even not
depend on the xml/core API.

The problem arises when the system's default encoding doesn't correspond to the
encoding specified in the web.xml file. In such case the InputSource is created
from the InputStream (bytes stream only) with the default encoding. The proposed
fix should help.

A workaround for reporters: Set system default encoding to the same enc. as
specified in the web.xml file or change the enc. in the web.xml. For example to
 force netbeans to use UTF-8 as default file enc. use:

./netbeans -J-Dfile.encoding=UTF-8  ...
Comment 10 vbrabant 2005-09-29 17:28:48 UTC
Just a stupid question:

I would like to know why I have not same problem when I edit HTML and JSP pages.
Those are not XML files, (so not depending of the XML/core api) but can be
correctly written, by using the correct encoding.
Maybe it would be possible to use the same way than for HTML and JSP pages. 

No ?
Comment 11 Marek Fukala 2005-10-04 14:56:25 UTC
Vincent, the problem described in this issue is caused by the DD code used in
the UI configurators (like the one of web.xml). I am not sure, but IMO, without
opening this UI editors you will be able to edit the web.xml file without problems. 

As for the HTML, JSP and XML "plain" editors - the encoding handling is
implemented there correctly so you should be able work with national character
sets without problems. 

Does this answer your question? 
Comment 12 Ken Frank 2005-10-04 17:46:09 UTC
adding I18N to synopsis for internal tracking

I've seen the same kind of exception sometimes on creation of separate xml
files also, but maybe that is related since these are xml files also.

ken.frank@sun.com
Comment 13 Pavel Fiala 2005-10-12 14:24:44 UTC
Fixed 

http://xml.netbeans.org/source/browse/xml/multiview/src/org/netbeans/modules/xml/multiview/EncodingHelper.java?rev=1.1&content-type=text/vnd.viewcvs-markup
http://xml.netbeans.org/source/browse/xml/multiview/src/org/netbeans/modules/xml/multiview/Bundle.properties?r1=1.12&r2=1.13
http://xml.netbeans.org/source/browse/xml/multiview/src/org/netbeans/modules/xml/multiview/Utils.java?r1=1.16&r2=1.17
http://xml.netbeans.org/source/browse/xml/multiview/src/org/netbeans/modules/xml/multiview/XmlMultiViewDataObject.java?r1=1.53&r2=1.54
http://xml.netbeans.org/source/browse/xml/multiview/src/org/netbeans/modules/xml/multiview/XmlMultiViewEditorSupport.java?r1=1.51&r2=1.52
http://j2ee.netbeans.org/source/browse/j2ee/ddapi/nbproject/project.xml?r1=1.5&r2=1.6
http://j2ee.netbeans.org/source/browse/j2ee/ddapi/src/org/netbeans/modules/j2ee/dd/api/ejb/DDProvider.java?r1=1.7&r2=1.8
http://j2ee.netbeans.org/source/browse/j2ee/ddapi/src/org/netbeans/modules/j2ee/dd/impl/common/DDProviderDataObject.java?r1=1.3&r2=1.4
http://j2ee.netbeans.org/source/browse/j2ee/ddapi/src/org/netbeans/modules/j2ee/dd/impl/common/DDUtils.java?r1=1.7&r2=1.8
http://j2ee.netbeans.org/source/browse/j2ee/ddloaders/src/org/netbeans/modules/j2ee/ddloaders/multiview/DDMultiViewDataObject.java?r1=1.8&r2=1.9
http://j2ee.netbeans.org/source/browse/j2ee/ddloaders/src/org/netbeans/modules/j2ee/ddloaders/multiview/EjbJarMultiViewDataObject.java?r1=1.52&r2=1.53
http://j2ee.netbeans.org/source/browse/j2ee/ddloaders/src/org/netbeans/modules/j2ee/ddloaders/web/DDDataObject.java?r1=1.11&r2=1.13

http://j2ee.netbeans.org/source/browse/j2ee/ddapi/src/org/netbeans/modules/j2ee/dd/api/ejb/DDProvider.java?r1=1.7&r2=1.8
Comment 14 vbrabant 2005-10-14 22:15:45 UTC
I just checked with the last QBuild (20051013), and I always have the same problem.

So, for me, it's not fixed. Or maybe it was fixed too late for the Qbuild.

Does I have to reopen the issue ?
Comment 15 vbrabant 2005-10-15 13:12:43 UTC
Verified in daily build 200510131922
Comment 16 Pavel Fiala 2005-10-17 15:02:25 UTC
*** Issue 65855 has been marked as a duplicate of this issue. ***