0

Page not found: because of Cyrillic symbol

asked 2018-05-28 18:27:14 +0800

everdelightedone gravatar image everdelightedone
111 4

updated 2018-05-28 21:18:01 +0800

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?

delete flag offensive retag edit

13 Answers

Sort by » oldest newest most voted
1

answered 2018-07-02 15:41:09 +0800

everdelightedone gravatar image everdelightedone
111 4

updated 2018-07-02 18:24:55 +0800

your recent stack looks unrelated to index.zul: WARNING: Unable to load ...\central-admin-2.4.8-SNAPSHOT\zk\report\eventLog.zul Yes, my bad, I just replaced problem zul's contents with index.zul's contents.

I finally found the solution to that problem. Problem arised only on Windows machines because of system encoding cp1251. Building the same project under Linux was successful. Solution is add -Dfile.encoding=UTF-8 property to MAVEN_OPTS. Exact solution for Netbeans users is: Right Click on project -> Properties -> Actions -> Clean And Build Project (or Build Project, or both) -> Add Env.MAVEN_OPTS=-Dfile.encoding=UTF-8 to Set Properties.

Thank you, cor3000 for your unvaluable help!

link publish delete flag offensive edit

Comments

that's great news, thanks for the update... I agree file encoding issues can be a nightmare

cor3000 ( 2018-07-02 16:19:19 +0800 )edit
1

answered 2018-07-02 16:16:30 +0800

cor3000 gravatar image cor3000
4366 2 7
ZK Team

instead of double quotes you can use backticks to format source code:

"Env.MAVEN_OPTS=-Dfile.encoding=UTF-8"

vs

Env.MAVEN_OPTS=-Dfile.encoding=UTF-8

link publish delete flag offensive edit
1

answered 2018-07-02 10:07:10 +0800

cor3000 gravatar image cor3000
4366 2 7
ZK Team

your recent stack looks unrelated to index.zul: WARNING: Unable to load ...\central-admin-2.4.8-SNAPSHOT\zk\report\eventLog.zul

If you think it's a Netbeans problem I'd suggest to build/run the application from command line. Then you can identify or rule out Netbeans as the source.

A common command to build the war file is to execute ...

> mvn clean package

.. and the war file should be the target folder.

You also made a few vague statements:

So page has windows-1251 encoding for some reason ... I opened problem .zul with Notepad++ and it looked OK.

What does Notepad++ say about the character encoding? Can you try converting it to UTF-8?

The file encoding Notepad++ detected (it doesn't care about the XML prolog) is shown at the bottom right: image description

If that's not UTF-8 then you can convert your file to UTF-8 with the menu option "convert to utf-8":

image description

Then save the file again.

If you think it's a maven settings issue then please compare the source and target files. In any case you need to first be certain about your file encodings. No tool can 100% help you if you don't know which file encoding your text files have or should have.

link publish delete flag offensive edit
0

answered 2018-06-29 20:47:10 +0800

everdelightedone gravatar image everdelightedone
111 4

Another reason could be is a maven configuration

link publish delete flag offensive edit

Comments

maven is well documented: here a related setting https://maven.apache.org/plugins/maven-resources-plugin/examples/encoding.html

cor3000 ( 2018-07-02 10:08:35 +0800 )edit
0

answered 2018-06-29 19:29:40 +0800

everdelightedone gravatar image everdelightedone
111 4

Replacing problem page content to index.zul from your link got the same error instead of opening page. Stack trace:

WARNING: Unable to load C:\Yuri\games\Java\projects1\ca\admin-web\war\target\central-admin-2.4.8-SNAPSHOT\zk\report\eventLog.zul

>>com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.
>>  at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:701)
>>  at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:372)
>>  at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1895)
>>  at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanLiteral(XMLEntityScanner.java:1187)
>>  at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:858)
>>  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:447)
>>  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:250)
>>  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
>>  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
>>  at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
>>  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
>>  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
>>  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
>>  at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
>>  at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
>>  at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
>>  at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
>>  at javax.xml.parsers.SAXParser.parse(SAXParser.java:328)
>>  at org.zkoss.idom.input.SAXBuilder.build(SAXBuilder.java:298)
>>  at org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:99)
>>  at org.zkoss.zk.ui.metainfo.PageDefinitions$MyLoader.parse(PageDefinitions.java:209)
>>...
Jun 29, 2018 2:09:55 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1362
SEVERE: >>org.zkoss.zk.ui.UiException: Page not found: /zk/report/eventLog.zul
>>  at org.zkoss.zk.ui.http.ExecutionImpl.getPageDefinition(ExecutionImpl.java:375)
>>  at org.zkoss.zk.ui.impl.AbstractExecution.createComponents0(AbstractExecution.java:246)
>>  at org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:238)
>>  at org.zkoss.zul.Include.afterCompose(Include.java:450)
>>  at org.zkoss.zul.Include.applyChangesToContent(Include.java:345)
>>  at org.zkoss.zul.Include.fixMode(Include.java:327)
>>  at org.zkoss.zul.Include.setSrc(Include.java:280)
>>  at ru.mycompany.centraladmin.web.MenuComposer.doClick(MenuComposer.java:78)
>>  at ru.mycompany.centraladmin.web.MenuComposer.onClick(MenuComposer.java:57)
>>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>  at java.lang.reflect.Method.invoke(Method.java:498)
>>  at org.zkoss.zk.ui.select.Selectors$ComposerEventListener.onEvent(Selectors.java:683)
>>  at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2743)
>>  at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2714)
>>  at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2655)
>>  at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136)
>>  at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1720)
>>  at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1505)
>>  at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1215)
>>  at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:601)
>>  at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:483)
>>  at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:492)
>>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
>>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
>>  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
>>  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>  at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
>>  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
>>  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>>  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
>>  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>  at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:167)
>>  at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
>>  at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
>>  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
>>  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
>>  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
>>  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
>>  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
>>  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
>>  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
>>  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
>>  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
>>  at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
>>  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
>>  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
>>  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
>>  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
>>  at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503)
>>  at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492)
>>  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>>  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>>  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>>  at java.lang.Thread.run(Thread.java:748)

Then I got rid of "И" and opened page again. Result:

initial
windows-1251

мя

So page has windows-1251 encoding for some reason. Looks like it's Netbeans's problem.

I opened problem .zul with Notepad++ and it looked OK. Then I opened the same .zul from netbeans generated source (from war/target folder) and got broken "И".

link publish delete flag offensive edit
1

answered 2018-06-29 17:34:07 +0800

cor3000 gravatar image cor3000
4366 2 7
ZK Team

according to your stack trace setSrc on an <include> component is called

org.zkoss.zul.Include.setSrc(Include.java:280)

So created a simple case doing exactly that when clicking a button.

http://zkfiddle.org/sample/3jvph99/2-cyrillic-chars-and-default-charset

It will include a zul file containing cyrillic characters. Please also run this in your tomcat, maybe this simple case (reducing the problem space) also breaks in your application and we'll see which character encoding is set during runtime.

Looking forward to your results.

link publish delete flag offensive edit
0

answered 2018-06-29 14:50:52 +0800

everdelightedone gravatar image everdelightedone
111 4

Good to see you again! Thank you for your help!

Stack trace:

WARNING: Unable to load C:\Yuri\games\Java\projects1\ca\admin-web\war\target\central-admin-2.4.8-SNAPSHOT\zk\dictionary\bin-dictionary.zul

com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence. at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:701) at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:372) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1895) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanLiteral(XMLEntityScanner.java:1191) at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:858) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:447) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:250) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327) at javax.xml.parsers.SAXParser.parse(SAXParser.java:328) at org.zkoss.idom.input.SAXBuilder.build(SAXBuilder.java:298) at org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:99) at org.zkoss.zk.ui.metainfo.PageDefinitions$MyLoader.parse(PageDefinitions.java:209) ... Jun 29, 2018 9:13:38 AM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1362 SEVERE: >>org.zkoss.zk.ui.UiException: Page not found: /zk/dictionary/bin-dictionary.zul at org.zkoss.zk.ui.http.ExecutionImpl.getPageDefinition(ExecutionImpl.java:375) at org.zkoss.zk.ui.impl.AbstractExecution.createComponents0(AbstractExecution.java:246) at org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:238) at org.zkoss.zul.Include.afterCompose(Include.java:450) at org.zkoss.zul.Include.applyChangesToContent(Include.java:345) at org.zkoss.zul.Include.fixMode(Include.java:327) at org.zkoss.zul.Include.setSrc(Include.java:280) at ru.mycompany.centraladmin.web.MenuComposer.doClick(MenuComposer.java:78) at ru.mycompany.centraladmin.web.MenuComposer.onClick(MenuComposer.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.zkoss.zk.ui.select.Selectors$ComposerEventListener.onEvent(Selectors.java:683) at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2743) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2714) at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2655) at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136) at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1720) at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1505) at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1215) at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:601) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:483) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:167) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)

Running an application from your post I get:

windows-1251 ���������������������������������������������������������������� АБВГДЕЖЗ�?ЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя ��������??������������������������������������������������������� ���������������������������������������������������������������� АБВГДЕЖЗ�?ЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя ��������??�������������������������������������������������������

I'm using java 1.8.0_171

link publish delete flag offensive edit
1

answered 2018-06-29 11:44:06 +0800

cor3000 gravatar image cor3000
4366 2 7
ZK Team

updated 2018-06-29 11:45:36 +0800

The specific problem with the "И" character happens when deliberately using cp1251 when converting the bytes or setting the default it via -Dfile.encoding=cp1251:

String s = "";
for (char ch = 0x0410; ch <= 0x044F; ch++)
    s += ch;

String s2 = s;

System.out.println(Charset.defaultCharset());

System.out.println(s);
s = new String(s.getBytes("utf-8"));
System.out.println(s);
s = new String(s.getBytes(), "utf-8");
System.out.println(s);

System.out.println(s2);
s2 = new String(s2.getBytes("utf-8"), "cp1251");
System.out.println(s2);
s2 = new String(s2.getBytes("cp1251"), "utf-8");
System.out.println(s2);


windows-1251
АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя
АБВГДЕЖЗР?ЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя
АБВГДЕЖЗ??ЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя
АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя
АБВГДЕЖЗР?ЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя
АБВГДЕЖЗ??ЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя

This kind of invalid byte/string conversion between cp1251 and utf-8 might explain this ... So at least this happens in this little test case.

How/where this can occur inside your or potentially any other ZK application I hope to find out with your stack trace.

I quite like those kind of mysteries so hang in.

link publish delete flag offensive edit
1

answered 2018-06-29 10:53:03 +0800

cor3000 gravatar image cor3000
4366 2 7
ZK Team

updated 2018-06-29 10:53:24 +0800

took me a while to revisit this one... in your first post you mentioned:

... "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) ...

Can you provide the full stack trace? (somehow I forgot to ask right away ... I thought it will "follow" later) I'd like to see which method(s) inside ZK lead to this behavior. There are multiple starting points for ZK to load/read a zul file (initial page, include, macro, Executions.createCompontentsDirectly, template ) ... to do some deeper analysis this stacktrace might help. So in case you can still reproduce the error please provide the stack trace information.

Also the JAVA version might be related (just to be sure).

link publish delete flag offensive edit
0

answered 2018-06-08 00:31:57 +0800

everdelightedone gravatar image everdelightedone
111 4

Thank your very much for your help! I have tried to set VM Option for Tomcat as -Dfile.encoding=UTF-8 and Dfile.encoding=UTF8. I've also tried to set environmental variable JAVA_OPTS as -Dfile.encoding=UTF8. But unfortunately, it's not working in my case. The code from your first link

class Basic 
{ 
public static void main(String[] args) throws Exception 
{ 
String s = "";
for(char ch=0x0410; ch<=0x044F; ch++)
s += ch;
System.out.println(s); 
s = new String(s.getBytes("UTF-8"));
System.out.println(s); 
s = new String(s.getBytes(), "UTF-8");
System.out.println(s);
} 
}

is working good in my case and yields

АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя
АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя
АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2018-05-28 18:27:14 +0800

Seen: 24 times

Last updated: Jul 02 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More