[arquillian-issues] [JBoss JIRA] (ARQ-1598) Warp on WildFly: CDI fails to inject into inspection that is inner static class

Lukáš Fryč (JIRA) jira-events at lists.jboss.org
Thu Dec 5 04:24:06 EST 2013


    [ https://issues.jboss.org/browse/ARQ-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928815#comment-12928815 ] 

Lukáš Fryč edited comment on ARQ-1598 at 12/5/13 4:23 AM:
----------------------------------------------------------

It works fine for inner classes, probably because their names doesn't clash.

----

I have tried and the fact is that we need to "transform" static inner classes as well,
because they bears a link to declaring class, which prevents classloading.

----

Another suggestion might be loading inner static classes just once on server-side - keeping a deployment-scoped class store for classes that was already loaded.
                
      was (Author: lfryc):
    It works fine for inner classes, probably because their names doesn't clash.

----

I have tried and the fact is that we need to "transform" static inner classes as well,
because they bears a link to declaring class, which prevents classloading.

----

Another suggestion might be loading inner static classes just once on server-side.
                  
> Warp on WildFly: CDI fails to inject into inspection that is inner static class
> -------------------------------------------------------------------------------
>
>                 Key: ARQ-1598
>                 URL: https://issues.jboss.org/browse/ARQ-1598
>             Project: Arquillian
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Extension - Warp
>    Affects Versions: warp_1.0.0.Alpha5
>         Environment: WildFly 8.0.0.Beta2-SNAPSHOT
>            Reporter: Lukáš Fryč
>             Fix For: warp_1.0.0.Alpha6
>
>
> When class is inner static class:
> {code}
> public class MyTest {
>    @Test
>    public void test1() {
>       Warp....inspect(new MyInspection());
>       Warp....inspect(new MyInspection()); // fails
>    }
>    @Test
>    public void test2() {
>        Warp....inspect(new MyInspection()); // fails
>    }
>    public static class MyInspection() {
>    }
> }
> {code}
> the first inspection pass, but all subsequent inspections fails in the scope of one deployment.
> ----
> I think that is because the class is already loaded in classloader and its scanning might be cached by Weld.
> ----
> A issue was originally reproduced and reported here:
> https://issues.jboss.org/browse/RF-13417
> ----
> Exception and cause:
> {code}
> java.lang.RuntimeException: Could not inject members
> 	at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:135)
> 	at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.enrich(CDIInjectionEnricher.java:78)
> 	at org.jboss.arquillian.test.impl.TestInstanceEnricher.enrich(TestInstanceEnricher.java:52)
> 	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:606)
> 	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
> 	at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
> 	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
> 	at org.jboss.arquillian.warp.impl.server.test.LifecycleTestEnrichmentWatcher.rememberFieldValue
> {code}
> {code}
> Caused by: java.lang.IllegalArgumentException: Can not set org.richfaces.ui.region.RegionBean field org.richfaces.ui.region.AbstractRegionTest$SetupExecute.region to org.richfaces.ui.region.AbstractRegionTest$SetupExecute
> 	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
> 	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)
> 	at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:55)
> 	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:75)
> 	at java.lang.reflect.Field.set(Field.java:741)
> 	at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:94)
> 	at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:358)
> 	at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:369)
> 	at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:72)
> 	at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:60)
> 	at org.jboss.weld.injection.producer.DefaultInjector$1.proceed(DefaultInjector.java:66)
> 	at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
> 	at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)
> 	at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:90)
> 	at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectNonContextualInstance(CDIInjectionEnricher.java:145)
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the arquillian-issues mailing list