Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Side Bean Validation: HV000250: Uninitialized locale #216

Closed
zeppelinux opened this issue Dec 13, 2022 · 36 comments
Closed

Client Side Bean Validation: HV000250: Uninitialized locale #216

zeppelinux opened this issue Dec 13, 2022 · 36 comments
Assignees
Labels
bug Something isn't working

Comments

@zeppelinux
Copy link

Bean Validation doesn't seem to kick in in showcase (/ui/csv/bean.xhtml).

I have slightly different problem, it kicks in for my dto/bean, but fails with:

2022-12-13 00:41:39,451 SEVERE [org.pri.app.exc.PrimeExceptionHandler] (executor-thread-6) HV000250: Uninitialized locale: en. Please register your locale as a locale to initialize when initializing your ValidatorFactory.: javax.validation.ValidationException: HV000250: Uninitialized locale: en. Please register your locale as a locale to initialize when initializing your ValidatorFactory. at org.hibernate.validator.resourceloading.PlatformResourceBundleLocator.getResourceBundle(PlatformResourceBundleLocator.java:181) at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.resolveMessage(AbstractMessageInterpolator.java:449) at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.lambda$interpolateMessage$0(AbstractMessageInterpolator.java:399) at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.interpolateMessage(AbstractMessageInterpolator.java:399) at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.interpolate(AbstractMessageInterpolator.java:355) at org.apache.myfaces.core.api.shared.FacesMessageInterpolator.interpolate(FacesMessageInterpolator.java:47) at org.hibernate.validator.internal.engine.validationcontext.AbstractValidationContext.interpolate(AbstractValidationContext.java:322)

@melloware
Copy link
Owner

Let me check this out.

@melloware
Copy link
Owner

Verified its not working for me either. I have to step through the JS code to find out why not.

@melloware melloware self-assigned this Dec 13, 2022
@melloware melloware added the bug Something isn't working label Dec 13, 2022
@melloware
Copy link
Owner

I haven't forgotten about this just debugging trying to figure out what is going on.

@zeppelinux
Copy link
Author

I appreciate this very much! No rush though :) This forced me to put some real effort into the REST API validation/error handling.

@melloware
Copy link
Owner

OK got to the bottom of it. Primefaces scans your bean for constraints so it can put them on the client side but this class is returning no results when running in Quarkus: https://github.com/primefaces/primefaces/blob/master/primefaces/src/main/java/org/primefaces/metadata/BeanValidationMetadataExtractor.java

I am sure this has to do with Quarkus, reflection, or the Hibernate Validator implemented differently for Quarkus. I am afraid this feature probably will not work with Quarkus.

@zeppelinux
Copy link
Author

Looks like we are not alone vaadin/flow#15352

@melloware
Copy link
Owner

I will see if I can ask on the mailing list to see if anyone knows if there is a way to do what we need

@melloware
Copy link
Owner

I got to the bottom of the JS errors when running the "Basic" CSV scenario not the "Bean" scenario and fixing it in PFE: primefaces-extensions/primefaces-extensions#1010

@melloware
Copy link
Owner

Also posted on the Dev mailing list: https://groups.google.com/g/quarkus-dev/c/KUHY1q8AfuE

@melloware
Copy link
Owner

@zeppelinux I got to the bottom of it and fixed it! primefaces/primefaces#9546

@zeppelinux
Copy link
Author

You Rock!

@melloware
Copy link
Owner

Quarkus + Hibernate team admitted its a bug on their end and is fixing it for Quarkus 2.15.2 See: quarkusio/quarkus#30139

@zeppelinux
Copy link
Author

Upgraded to Quarkus 2.15.2 and still getting this:

javax.validation.ValidationException: HV000250: Uninitialized locale: en. Please register your locale as a locale to initialize when initializing your ValidatorFactory.
        at org.hibernate.validator.resourceloading.PlatformResourceBundleLocator.getResourceBundle(PlatformResourceBundleLocator.java:181)
        at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.resolveMessage(AbstractMessageInterpolator.java:449)
        at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.lambda$interpolateMessage$0(AbstractMessageInterpolator.java:399)
        at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330)

Probably something else.

@melloware
Copy link
Owner

Are you getting it in your own project or in this showcase?

@zeppelinux
Copy link
Author

My own project, which was created using showcase (i.e. should behave the same, but something is different).

@melloware
Copy link
Owner

Yep something is not the same. But this error is very strange. It's saying you are missing a locale.

@zeppelinux
Copy link
Author

zeppelinux commented Jan 5, 2023

Had to introduce this to fix it in my project:

@ApplicationScoped
public class MyValidatorFactoryCustomizer implements ValidatorFactoryCustomizer {

    @Override
    public void customize(BaseHibernateValidatorConfiguration<?> configuration) {
        configuration.defaultLocale(Locale.ENGLISH);
    }
}

@melloware
Copy link
Owner

That is very bizarre. I wonder why I don't have to do that here on this showcase?

@zeppelinux
Copy link
Author

zeppelinux commented Jan 5, 2023

try changing the pom.xml

<!--        <maven.compiler.target>11</maven.compiler.target>-->
<!--        <maven.compiler.source>11</maven.compiler.source>-->
        <maven.compiler.release>17</maven.compiler.release>

@melloware
Copy link
Owner

Oh good idea. I will report back!

@melloware
Copy link
Owner

melloware commented Jan 6, 2023

Hmmm bumped to JDK17 and its still working fine.

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: C:\Tools\apache-maven-3.8.6
Java version: 17, vendor: Oracle Corporation, runtime: C:\Tools\jdk-17
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

And are you sure you are just using this dependency?

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-validator</artifactId>
        </dependency>

@zeppelinux
Copy link
Author

Confirmed, I can consistently make quarkus-faces to fail (at least in my environment) on the same exception by setting/downgrading <primefaces-extensions.version>12.0.2</primefaces-extensions.version>

It doesn't fixes it for my project (without ValidatorFactoryCustomizer), unfortunately. I have bunch of other dependencies, something is still on the way.

@melloware
Copy link
Owner

i feel like something else is colliding. Can you post your pom.xml here ?

@zeppelinux
Copy link
Author

Sure, but let's see if we can both reproduce it in quarkus-faces first.

When you change the pom.xml line 23 to
<primefaces-extensions.version>12.0.2</primefaces-extensions.version>

and

  1. mvn clean compile quarkus:dev
  2. navigate to http://localhost:8080/ui/csv/bean.xhtml
  3. Click 'Save'

Does it fail for you?

@melloware
Copy link
Owner

Nope with 12.0.2 works fine and i get this.

image

@zeppelinux
Copy link
Author

Well, this is 'interesting'... because i'm not doing any other change to the quarkus-faces, here is my Mac OS Java runtime:

dimas@Jam quarkus-faces % java -version
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

@melloware
Copy link
Owner

melloware commented Jan 6, 2023

I just updated to Adoptium 17.0.5 from Oracle 17.0 and still no issue. I can't imagine its JDK related?

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: C:\Tools\apache-maven-3.8.6
Java version: 17.0.5, vendor: Eclipse Adoptium, runtime: C:\Tools\jdk-17
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

@melloware
Copy link
Owner

Found this really old Quarkus ticket from 2019 but says its fixed: quarkusio/quarkus#5882

@melloware
Copy link
Owner

can you do mvn --version for me?

@zeppelinux
Copy link
Author

dimas@Jam quarkus-faces % mvn --version
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /usr/local/Cellar/maven/3.8.1/libexec
Java version: 17.0.2, vendor: Oracle Corporation, runtime: /Users/dimas/Library/Java/JavaVirtualMachines/openjdk-17.0.2/Contents/Home
Default locale: en_CA, platform encoding: UTF-8
OS name: "mac os x", version: "12.5.1", arch: "x86_64", family: "mac"
dimas@Jam quarkus-faces %

Here is screen capture video:
https://s3.amazonaws.com/diligesoft.imps/public/Screen+Recording+2023-01-06+at+1.26.21+PM.mov

@melloware
Copy link
Owner

OK can you do me a favor and grab that Entire stack trace. I am wondering if its somehow a MyFaces issue I want to look through the stack and walk back through it to see if I can see anything strange.

@zeppelinux
Copy link
Author

zeppelinux commented Jan 6, 2023

Here it is:

2023-01-06 13:27:21,006 SEVERE [org.pri.app.exc.PrimeExceptionHandler] (executor-thread-1) HV000250: Uninitialized locale: en_US. Please register your locale as a locale to initialize when initializing your ValidatorFactory.: javax.validation.ValidationException: HV000250: Uninitialized locale: en_US. Please register your locale as a locale to initialize when initializing your ValidatorFactory.
        at org.hibernate.validator.resourceloading.PlatformResourceBundleLocator.getResourceBundle(PlatformResourceBundleLocator.java:181)
        at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.resolveMessage(AbstractMessageInterpolator.java:449)
        at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.lambda$interpolateMessage$0(AbstractMessageInterpolator.java:399)
        at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330)
        at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.interpolateMessage(AbstractMessageInterpolator.java:399)
        at org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator.interpolate(AbstractMessageInterpolator.java:355)
        at org.apache.myfaces.core.api.shared.FacesMessageInterpolator.interpolate(FacesMessageInterpolator.java:47)
        at org.hibernate.validator.internal.engine.validationcontext.AbstractValidationContext.interpolate(AbstractValidationContext.java:322)
        at org.hibernate.validator.internal.engine.validationcontext.AbstractValidationContext.addConstraintFailure(AbstractValidationContext.java:231)
        at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:79)
        at org.hibernate.validator.internal.metadata.core.MetaConstraint.doValidateConstraint(MetaConstraint.java:130)
        at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:123)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:555)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:518)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:488)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:450)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateValueInContext(ValidatorImpl.java:799)
        at org.hibernate.validator.internal.engine.ValidatorImpl.validateValue(ValidatorImpl.java:221)
        at javax.faces.validator.BeanValidator.validate(BeanValidator.java:214)
        at org.apache.myfaces.core.api.shared.ComponentUtils.callValidators(ComponentUtils.java:245)
        at javax.faces.component.UIInput.validateValue(UIInput.java:472)
        at javax.faces.component.UIInput.validate(UIInput.java:729)
        at javax.faces.component.UIInput.processValidators(UIInput.java:302)
        at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1410)
        at javax.faces.component.UIForm.processValidators(UIForm.java:204)
        at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1410)
        at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1410)
        at javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1759)
        at javax.faces.component.UIViewRoot.access$500(UIViewRoot.java:83)
        at javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1867)
        at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1715)
        at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:965)
        at org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:39)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:172)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:125)
        at javax.faces.lifecycle.LifecycleWrapper.execute(LifecycleWrapper.java:61)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:207)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
        at org.omnifaces.filter.CacheControlFilter.doFilter(CacheControlFilter.java:239)
        at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:183)
        at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.omnifaces.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:123)
        at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
        at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:56)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:595)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:120)

        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:284)
        at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18)
        at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$1.run(UndertowDeploymentRecorder.java:417)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)

@melloware
Copy link
Owner

OK I am stumped unless its some kind of timing or threading issue because the code from MyFaces and Hibernate both look fine. But it checks a ConcurrentHashmap to see if its loaded so I guess its possibly some weird timing issue. My machine is pretty fast so I wonder if that is why I dont see it?

@zeppelinux
Copy link
Author

Most likely. And there is an easy workaround... Hopefully this, whatever it is, doesn't show it's ugly face anywhere else. Thanks a lot for looking into it 🍻

@melloware
Copy link
Owner

melloware commented Feb 25, 2023

@zeppelinux I as able to reproduce your issue and got to the bottom of it. Can you add these two properties to your application.properties and let me know if this error goes away. It did for me.

# default bean validation locale
quarkus.default-locale=en
# The list of all the supported MyFaces locales
quarkus.locales=ar,ca,cs,de,en,en_US,es,fr,it,ja,mt,nl,pl,pt,pt_BR,ru,sk,uk,zh_CN,zh_HK,zh_TW

@melloware melloware changed the title Client Side Bean Validation Client Side Bean Validation: HV000250: Uninitialized locale Feb 25, 2023
@zeppelinux
Copy link
Author

Confirmed it works in my proj @melloware, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants