[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 05:25:05 EST 2013


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

Lukáš Fryč commented on ARQ-1598:
---------------------------------

Note: the same issue happens when we use twice the same anonymous class:

{code}
public class MyTest {

   @Test
   public void test1() {
       runWarp();
   }

   @Test
   public void test2() {
       runWarp(); // fails
   }

   private void runWarp() {
       Warp....inspect(new Inspection() {
           private static final long serialVersionUID = 1L;
       });
   }
}
{code}

The suggested solution should work here (caching classes), but it came to my mind that we could also take completely another approach:

do deployment-build-time extraction of member classes (that extends Inspection?) from declaring class (which we are avoiding to load by this whole "transformation process").

In such a way, we would not need to load classes during requests, they would be loaded just once per deployment, thus we wouldn't need caching.
                
> 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