Closed cj19 closed 4 months ago
Interesting question. Where would the alt-locale messages come from? CXF delivers only messages in English. Does perhaps your service have bundles for other locales?
For the mechanism to pick some non-default locale, CXF seems to always take Locale.getDefault()
, so you would have to pass -Duser.language=hu
when starting your app in JVM mode and set quarkus.default-locale=hu
at build time for native mode. That would only hold for CXF's own messages and you would have to provide the bundles for your locale yourself.
If you ask about the language of the messages thrown by your own service, then I think you are on your own. Neither JAX-WS nor CXF prescribe you anything. You can pick whatever message loading mechanism you want and you can make it sensitive to whatever system property or SOAP/HTTP message header you like.
Disclaimer: I never solved this in practice, so I can be wrong.
Thank you @ppalaga for the quick answer, I will look into this, then I get back to you when I have new updates. :)
@ppalaga This problem popped up when my coworker ran the test on his computer and the assertion of the error messages appeared in different language, because his OS configured with different languages. Sidenote: We have already configured the quarkus locale settings, tried with jvm arguments etc.
I am not sure what else we can be done to change the locale for the CXF. :)
the assertion of the error messages appeared in different language
Can you plz show an example of such a message? Which jar / piece of code is it coming from?
I was able to configure the user.language via build.gradle file, but it is strange that if I change the quarkus.default-locale=en_US, that does not change anything.
I could perhaps help more if I knew which messages you speak about. Could you cite one? Which jar or Java class produces it?
Caused by: jakarta.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 0; columnNumber: 0; cvc-complex-type.2.4.a: Invalid content was found starting with element 'invalidElement'. One of '{expectedElement}' is expected.]
Is this sufficient?
That's one half of the requested info. The other half would be where that particular SAXParseException object gets instantiated. It can be seen from the stack trace.
Closing because of missing information. Please feel free to reopen providing it.
@zhfeng has just described a situation in #1327 that looks pretty similar to yours. The stack trace in #1327 is
Interceptor for {http://www.jboss.org/eap/quickstarts/wscalculator/Calculator}CalculatorService#{http://www.jboss.org/eap/quickstarts/wscalculator/Calculator}addCheckParameters has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: Unmarshalling Error: cvc-maxInclusive-valid: 对于类型为 'smallIntType' 的 maxInclusive '1024', 值 '1028' 不具有面有效性。
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:931)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:737)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:168)
at org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:265)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:233)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:207)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:159)
at io.quarkiverse.cxf.transport.CxfHandler.process(CxfHandler.java:243)
at io.quarkiverse.cxf.transport.CxfHandler.handle(CxfHandler.java:180)
at io.quarkiverse.cxf.transport.CxfHandler.handle(CxfHandler.java:48)
at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:191)
at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279)
at io.vertx.core.impl.ContextImpl.lambda$internalExecuteBlocking$2(ContextImpl.java:210)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:599)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: jakarta.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 181; cvc-maxInclusive-valid: 对于类型为 'smallIntType' 的 maxInclusive '1024', 值 '1028' 不具有面有效性。]
at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:444)
at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:378)
at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:355)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.doUnmarshal(JAXBEncoderDecoder.java:880)
at org.apache.cxf.jaxb.JAXBEncoderDecoder$3.run(JAXBEncoderDecoder.java:919)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:917)
... 24 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 181; cvc-maxInclusive-valid: 对于类型为 'smallIntType' 的 maxInclusive '1024', 值 '1028' 不具有面有效性。
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:135)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:512)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3600)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3437)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3347)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2373)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:944)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.endElement(ValidatorHandlerImpl.java:585)
at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.ValidatingUnmarshaller.endElement(ValidatingUnmarshaller.java:80)
at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.StAXStreamConnector.handleEndElement(StAXStreamConnector.java:192)
at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:154)
at org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:376)
... 29 more
The exception is instantiated by JRE code. One can set the language via LANG
environment variable or by passing -Duser.language=...
on the command line. That would hold for running the application using java -jar
(JVM mode). For native mode, the language support is compiled in based on quarkus.default-locale
set in application properties.
It seems that the language setting of the messages depends on the settings of the OS. I already configured the :
quarkus.default-locale=en_US
but that does not change the language of the soap fault messages. Is there any way to change this to be not dependent on the locale settings of the OS?