-
1. Re: Proxy is not created considering all class interfaces
alberto_souza Oct 6, 2013 10:02 PM (in response to alberto_souza)A more simple example:
[java]
Validator validator = cdiBasedContainer.instanceFor(Validator.class);
ExecutableValidator evalidator = validator.forExecutables();
System.out.println(evalidator.toString());
[/java]
This code throws ClassCastException:
java.lang.ClassCastException: org.jboss.weld.proxies.Validator$742456564$Proxy$_$$_WeldClientProxy cannot be cast to javax.validation.executable.ExecutableValidator
at org.jboss.weld.proxies.Validator$742456564$Proxy$_$$_WeldClientProxy.forExecutables(Unknown Source)
at br.com.caelum.vraptor.test.VRaptorNavigationSimpleScenariosTest.shouldValidateObject(VRaptorNavigationSimpleScenariosTest.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
I think this a weldse bug... The correct behavior should be implement all class implementations... But when i run the webapp, and Tomcat7Container is used, the same code runs fine
-
2. Re: Proxy is not created considering all class interfaces
luksa Oct 7, 2013 4:33 AM (in response to alberto_souza)The proxy is created based on the injection point's type, not the bean's actual type.
Apparently, I shouldn't be answering questions until I'm fully awake
The proxy is based on the bean type, of course. Your Validator is probably created by a producer method, so the bean type is based on the method's return type. But, IIRC, DeltaSpike does in fact scan all the injection points and create beans with bean types based on the injection points themselves.
More info at: [WELD-1498] ClassCastException when proxied class return this - JBoss Issue Tracker
-
3. Re: Proxy is not created considering all class interfaces
alberto_souza Oct 7, 2013 8:38 AM (in response to luksa)I see... But, even so, i think the proxy should be created respecting implementation interfaces... Another doubt is the different behavior between Tomcat7Container and WeldContainer(se mode)... Do you know anything about? I tried to take a look inside the classes but I did not find any reason...
Thanks!!
-
4. Re: Proxy is not created considering all class interfaces
alberto_souza Oct 7, 2013 10:10 AM (in response to alberto_souza)I updated the weld version to rc1 and everything is working. Thanks for the tip .