[ https://issues.apache.org/jira/browse/MYFACES-4311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16987283#comment-16987283 ]
Volodymyr Siedlecki commented on MYFACES-4311: ---------------------------------------------- I tested with a sample application, but ran into a different null pointer exception. The commit has my comment. I also created a patch for 2.3.x, but I kept getting this error: javax.faces.FacesException: java.lang.ClassCastException: org.apache.myfaces.cdi.bean.TestBean$$OwbNormalScopeProxy0 incompatible with org.apache.myfaces.cdi.bean.EntityBean at org.apache.myfaces.cdi.bean.CustomConverter.getAsString(CustomConverter.java:8) at org.apache.myfaces.cdi.converter.FacesConverterCDIWrapper.getAsString(FacesConverterCDIWrapper.java:69) at org.apache.myfaces.shared.renderkit.RendererUtils.getStringValue(RendererUtils.java:378) Maybe you could take a look? I don't see what I'm doing wrong since it works when I test in other servers? Thank you! > Custom Converters Do Not Support Generics > ----------------------------------------- > > Key: MYFACES-4311 > URL: https://issues.apache.org/jira/browse/MYFACES-4311 > Project: MyFaces Core > Issue Type: Bug > Components: JSR-372 > Affects Versions: 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5 > Reporter: Volodymyr Siedlecki > Priority: Minor > Fix For: 3.0.0-SNAPSHOT, 2.3.7 > > Attachments: ConverterTestApp.war, MYFACES-4311.patch, > myfaces-4311-test-case.patch, updated_MYFACES-4311.patch > > Time Spent: 20m > Remaining Estimate: 0h > > Hello, > > A user posted an issue with the Converter's here: > [https://stackoverflow.com/questions/58825333/facesconverter-is-null-jsf-2-3-cdi-2-0] > > I investigated the issue, and it is caused by the beanManger#getBeans inside > the /org/apache/myfaces/cdi/util/CDIUtils.java file. The getBeans returns an > empty set instead of the converter bean. It searches by class, but it should > also check by type. Since it's an problem with MyFaces code, I thought I'd > open an issue here. > > I've provided a patch (overloading the CDIUtil.java methods to accept a type) > and sample app (borrowed from StackOverflow). > > I only modified the code to search by type (1) when using getBeans. Type is > obtained from creating a TypeLiteral (2). > > Since Validators don't check by type as Converters, I can make another fix if > you don't have any issues with this patch. > Please let me know if you have questions or suggestions for the code. > > 1) > https://javaee.github.io/javaee-spec/javadocs/javax/enterprise/inject/spi/BeanManager.html#getBeans-java.lang.reflect.Type-java.lang.annotation.Annotation...- > 2) > https://javaee.github.io/javaee-spec/javadocs/javax/enterprise/util/TypeLiteral.html -- This message was sent by Atlassian Jira (v8.3.4#803005)