Special characters in i18n message key produces UnsupportedOperationException at runtime

Hi,

If you use special characters for an i18n message key, you will receive the following error at runtime:

UnsupportedOperationException: Unsupported resource string format: ‘msg://Genérico.campo_obligatorio’, messagesPack=null

Studio should have a validation rule for i18n keys as there is for entity class names.

Thanks.

Hi,

Could you please provide the full stack trace or log file?

After changing Genérico to Generico error disappeared.

2018-06-26 09:49:18.227 ERROR [http-nio-8084-exec-57/app/admin] com.haulmont.cuba.web.log.AppLog - Exception in com.haulmont.cuba.web.toolkit.ui.CubaButton: 
com.vaadin.server.ServerRpcManager$RpcInvocationException: Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:160) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:119) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:444) [vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:409) [vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274) [vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90) [vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41) [vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1435) [vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:361) [vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:312) [cuba-web-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:203) [cuba-web-6.9.1.jar:6.9.1]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) [servlet-api.jar:na]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.23]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.23]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.5.23]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.23]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.23]
	at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107) [spring-web-4.3.14.RELEASE.jar:4.3.14.RELEASE]
	at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73) [spring-web-4.3.14.RELEASE.jar:4.3.14.RELEASE]
	at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:107) [cuba-web-6.9.1.jar:6.9.1]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.23]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.23]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [catalina.jar:8.5.23]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.23]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [catalina.jar:8.5.23]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.23]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.23]
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) [catalina.jar:8.5.23]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.23]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:8.5.23]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) [tomcat-coyote.jar:8.5.23]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.23]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-coyote.jar:8.5.23]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) [tomcat-coyote.jar:8.5.23]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.23]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_144]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.23]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: java.lang.reflect.InvocationTargetException: null
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	... 38 common frames omitted
Caused by: com.vaadin.event.ListenerMethod$MethodException: Invocation of method buttonClick in com.haulmont.cuba.web.gui.components.WebButton$$Lambda$86/701074723 failed.
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:530) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:200) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:163) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1037) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.vaadin.ui.Button.fireClick(Button.java:377) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	at com.haulmont.cuba.web.toolkit.ui.CubaButton.fireClick(CubaButton.java:54) ~[cuba-web-6.9.1.jar:6.9.1]
	at com.vaadin.ui.Button$1.click(Button.java:54) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	... 43 common frames omitted
Caused by: java.lang.UnsupportedOperationException: Unsupported resource string format: 'msg://Genérico.campo_obligatorio', messagesPack=null
	at com.haulmont.cuba.core.global.MessageTools.loadString(MessageTools.java:141) ~[cuba-global-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.core.global.MessageTools.loadString(MessageTools.java:107) ~[cuba-global-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.core.global.MessageTools.loadString(MessageTools.java:82) ~[cuba-global-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.core.global.MessageTools.getNotNullMessage(MessageTools.java:337) ~[cuba-global-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.core.global.MessageTools.getDefaultRequiredMessage(MessageTools.java:313) ~[cuba-global-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.xml.layout.loaders.FieldGroupLoader.loadRequired(FieldGroupLoader.java:607) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.xml.layout.loaders.FieldGroupLoader.loadComponent(FieldGroupLoader.java:167) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponents(ContainerLoader.java:37) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponentsAndExpand(ContainerLoader.java:89) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.xml.layout.loaders.WindowLoader.loadComponent(WindowLoader.java:80) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.WindowManager.createWindow(WindowManager.java:575) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.WindowManager.openEditor(WindowManager.java:869) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.web.WebWindowManager.openEditor(WebWindowManager.java:178) ~[cuba-web-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.components.WindowDelegate.openEditor(WindowDelegate.java:258) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.web.gui.WebWindow.openEditor(WebWindow.java:487) ~[cuba-web-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.components.actions.CreateAction.internalOpenEditor(CreateAction.java:305) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.gui.components.actions.CreateAction.actionPerform(CreateAction.java:265) ~[cuba-gui-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.web.gui.components.WebButton.performAction(WebButton.java:45) ~[cuba-web-6.9.1.jar:6.9.1]
	at com.haulmont.cuba.web.gui.components.WebButton.lambda$new$61446b05$1(WebButton.java:37) ~[cuba-web-6.9.1.jar:6.9.1]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510) ~[vaadin-server-7.7.13.cuba.9.jar:7.7.13.cuba.9]
	... 49 common frames omitted

Unfortunately, we cannot reproduce the problem. We will be able to help you if you send us a small sample project along with reproduction scenario that demonstrates the issue.

I’ve reproduced the same FieldGroup with requiredMessage set to msg://Genérico.campo_obligatorio. It works as expected: untitled.zip (80.1 KB)

We are using UTF-8 for all the resources, thus it should work for all the Unicode characters.

Hi Yuriy and thanks for taking the time to reproduce the issue.

I have created a new project and followed these steps to get the error happening:

  1. Create new Entity at the Data Model tab
  2. Create new Attribute with default type
  3. In the Validation panel for the attribute, click on not set next to NotNull validation
  4. Enable and click on the world icon
  5. Click Add to create a new message key
  6. Enter “Genérico.not_null” and keep pressing OK until all changes are saved
  7. Select new entity and click on New -> Generic UI Screen
  8. Click on Run -> Start application server
  9. Open the browser and navigate to the app
  10. Log in, click on Application and select the previously created entity
  11. A pop up with the following should appear:
    imagen

Here is the zipped project: TestI18n.zip (79.7 KB)

The project was created using version 6.9.1 with no changes made to default configuration.

1 Like

Thank you for the reproduction scenario, now I see the problem. It is related only with messages defined in entities.

As a workaround, you can specify full message path with package:

@NotNull(message = "{msg://com.company.testi18n.entity/Genérico.not_null}")
@Column(name = "TEST_ATTRIBUTE")
protected String testAttribute;

I’ve filed the issue: https://github.com/cuba-platform/cuba-gradle-plugin/issues/46