-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello everybody!
I got a legacy project (2016 year) with zul-pages. The problem is some pages issue "Page not found" with
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence
(...stack trace follows).
I found out that problem arises only on pages with "И" symbol (Cyrillic Capital Letter I, unicode code is U+0418). So, if I replace "И" with & # x0418;
(without spaces) on .zul page - it works. It looks strange because all other Cyrillic symbols are working without any problems.
Zk version is 7.0.3,
Tomcat version 8.0.27, OS Windows 10 1803 build 17134.48 with russian locale.
Every zul-page has <?xml version="1.0" encoding="UTF-8"?>
as a first line.
Is it a ZK framework bug?
I found this post in another forum which also has a problem around the "И" character:
https://www.java-forums.org/new-java/51981-problem-encoding-russian-text-between-utf-8-unicode.html
Could it be that your default OS encoding is other than UTF-8? You might have to run the Java process specifically with UTF-8?
According to this you can run your application server with the JVM parameter ...
-Dfile.encoding=UTF-8
... to set it explicitely.
Thank you for the answer! I am new to ZK and possibly don't understand something simple. The project I got have been uploaded from git repository and I run it with Netbeans IDE 8.2 under Apache Tomcat 8.0.27. I have tried to run project under different browsers (Chrome 66.0.3359.181 and Firefox 59.0.2). Maven snippet from pom.xml:
<properties>
<zk.spring.version>3.0</zk.spring.version>
<zk.version>7.0.3</zk.version>
</properties>
<dependency>
<groupId>org.zkoss.theme</groupId>
<artifactId>sapphire</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkplus</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkbind</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zhtml</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkspring-core</artifactId>
<version>${zk.spring.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkspring-security</artifactId>
<version>${zk.spring.version}</version>
</dependency>
The first line in .zul file is
<?xml version="1.0" encoding="UTF-8"?>
I can open .zul in Notepad++ without any encoding problem with UTF-8 encoding. I also can see ploblem symbol in Netbeans editor. I don't understand how is it possible for every cyrillic symbol to work without any problem, but just one of them and only with uppercase case to fail. My .zul snippet:
<south height="250px" splittable="true" minsize="250" collapsible="true" style="border-bottom: 0; border-left: 0; border-right: 0;"
autoscroll="true"
open="@load(vm.addingNewItemMode or vm.editorOpen) @bind(vm.editorOpen)">
<groupbox id="addItemWindow" form="@id('newItem') @load(vm.selectedItem) @save(vm.selectedItem, before='save')"
style="border: 0" visible="@load(not empty vm.selectedItem)" width="100%" height="100%" contentStyle="border: 0; padding: 0;">
<grid width="100%" height="100%" style="border: 0">
<columns>
<column hflex="min"/> <column/>
</columns>
<rows>
<row>
<label value="Код"/>
<vlayout>
<textbox width="" value="@bind(newItem.code) @validator(vm.codeValidator,length='30')" disabled="@load(!vm.canEdit)" hflex="1"/>
<label sclass="error" value="@bind(vmsgs['code'])"/>
</vlayout>
</row>
<row>
<label value="Имя"/>
<vlayout>
<textbox value="@bind(newItem.name) @validator(vm.uniqueValidator,length='255')" disabled="@load(!vm.canEdit)" hflex="1"/>
<label sclass="error" value="@bind(vmsgs['name'])"/>
</vlayout>
</row>
<row>
<label value="Описание"/>
<vlayout>
<textbox value="@bind(newItem.description) @validator(vm.lengthValidator,length='255')" disabled="@load(!vm.canEdit)" hflex="1"/>
<label sclass="error" value="@bind(vmsgs['description'])"/>
</vlayout>
</row>
<row>
<label value="Цвет"/>
<vlayout>
<combobox id="comboColors" model="@load(c:split(configuration.getString('ui.priority.work.mode.colors'),','))" readonly="true"
value="@bind(newItem.color) @converter(vm.comboBoxSelectedItemConverter) @validator(vm.uniqueValidator,length='255')"
selectedItem="@load(newItem.color)"
disabled="@load(!vm.canEdit)" itemRenderer="@load(vm.colorRenderer)"
style="@bind((newItem.color eq null or c:trim(newItem.color) eq '') ? '' : c:cat('color: #',c:replace(c:substring(newItem.color, 1, 7), 'FFFFFF', '000000')))"/>
<label sclass="error" value="@bind(vmsgs['color'])"/>
</vlayout>
</row>
</rows>
</grid>
</groupbox>
</south>
(I can't insert a full .zul's text in my post, because it contains links I'm getting error "Your karma is insufficient to publish links, please remove the link and post again".)
Problem symbol is in the row <label value="Имя"/>
I run it under Windows 10. I tried it to run of two different computers (both with the same hardware and OS).
Opening page results "Page not found: /zk/priority/workMode.zul" error message.
To me it simply sounds like your file might not be encoded/saved correctly as UTF-8.
I tried it on zkfiddle and it works. Could be I tested not the exact case. So can you please add what's missing in case I forgot a detail, update the fiddle and provide the link here?
Asked: 2018-05-28 18:27:14 +0800
Seen: 29 times
Last updated: Jul 02 '18