[jboss-jira] [JBoss JIRA] (WFLY-13612) Bean Validation Problem In EJB inheritance
Ivo Studensky (Jira)
issues at jboss.org
Thu Jul 2 15:02:02 EDT 2020
[ https://issues.redhat.com/browse/WFLY-13612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14189571#comment-14189571 ]
Ivo Studensky edited comment on WFLY-13612 at 7/2/20 2:59 PM:
--------------------------------------------------------------
If a stateless EJB implements an interface of a JAX-RS resource it gets a proxy created with a superclass being {{java.lang.Object}} due to the following code in {{DefaultComponentViewConfigurator}}:
{code:java}
//we define it in the modules class loader to prevent permgen leaks
L92: if (viewClass.isInterface()) {
proxyConfiguration.setSuperClass(Object.class);
proxyConfiguration.addAdditionalInterface(viewClass);
viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration));
} else {
proxyConfiguration.setSuperClass(viewClass);
viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration));
}
{code}
This leads to a {{java.lang.Object}} returned from {{EjbProxyBeanMetaDataClassNormalizer.normalize()}}:
{code:java}
public <T> Class<? super T> normalize(Class<T> clazz) {
L56: if (EjbProxy.class.isAssignableFrom(clazz)) {
return clazz.getSuperclass();
}
return clazz;
}
{code}
Which then denies the validation.
I can't see any reasonable fix instead of setting the superclass of the proxy to the {{viewClass}}. I've tried to kick up a dirty fix and tests, but that effectively disables the WFLY-11566 fix for cases with a interface, see
https://github.com/istudens/wildfly/commit/da2308e37a690b07892b67e66ecfb4a3d289a88b
was (Author: istudens):
If a stateless EJB implements an interface of a JAX-RS resource it gets a proxy created with a superclass being {{java.lang.Object}} due to the following code in {{DefaultComponentViewConfigurator}}:
{code:java}
//we define it in the modules class loader to prevent permgen leaks
L92: if (viewClass.isInterface()) {
proxyConfiguration.setSuperClass(Object.class);
proxyConfiguration.addAdditionalInterface(viewClass);
viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration));
} else {
proxyConfiguration.setSuperClass(viewClass);
viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration));
}
{code}
This leads to a {{java.lang.Object}} returned from {{EjbProxyBeanMetaDataClassNormalizer.normalize()}}:
{code:java}
public <T> Class<? super T> normalize(Class<T> clazz) {
L56: if (EjbProxy.class.isAssignableFrom(clazz)) {
return clazz.getSuperclass();
}
return clazz;
}
{code}
Which then denies the validation.
I can't see any reasonable fix instead of setting the superclass of the proxy to the {{viewClass}}. I've tried to kick up a dirty fix and tests, but that effectively disables the WFLY-11566 fix for cases with a interface, see
> Bean Validation Problem In EJB inheritance
> ------------------------------------------
>
> Key: WFLY-13612
> URL: https://issues.redhat.com/browse/WFLY-13612
> Project: WildFly
> Issue Type: Bug
> Components: Bean Validation
> Affects Versions: 20.0.0.Final
> Reporter: huaxu wu
> Assignee: Ivo Studensky
> Priority: Major
>
>
> {code:java}
> @Path("/test_action")
> public interface TestResource {
> @Path("test")
> @POST
> @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
> @Produces(MediaType.APPLICATION_JSON)
> GeneralOperationResult test2(@FormParam("asdf") @NotBlank String asdf);
> }
> {code}
> {code:java}
> @Stateless
> public class TestResourceImpl implements TestResource {
> @Override
> public GeneralOperationResult test2(String asdf) {
> return GeneralOperationResult.createSuccess("test");
> }
> }
> {code}
> The above code, the @NotBlank annotation works on wildfly19, but not on wildfly20.
> To make it work on wildfly20, I must add @NotBlank annotation to the override method.
> I wonder it's bug or it's your design?
> The above code, If I remove the @Stateless annotation, the @NotBlank annotation works as expectd.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list