openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: @Intercepted Bean<?> failure
Date Mon, 17 Dec 2018 08:11:49 GMT
Hello Laird,

I didn't manage to reproduce with this test:

import static org.junit.Assert.assertEquals;

import java.io.Serializable;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Intercepted;
import javax.enterprise.inject.spi.Bean;
import javax.inject.Inject;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;

import org.apache.webbeans.test.AbstractUnitTest;
import org.apache.webbeans.test.component.event.normal.Transactional;
import org.junit.Test;

public class BeanMetadataInterceptedTest extends AbstractUnitTest
{
    @Test
    public void checkIntercepted()
    {
        addInterceptor(TransactionalInterceptor.class);
        startContainerInnerClasses();
        assertEquals(SomeBean.class.getName(),
getInstance(SomeBean.class).name());
    }

    @Transactional
    @ApplicationScoped
    public static class SomeBean
    {
        public String name() {
            return "failed";
        }
    }

    @Interceptor
    @Transactional
    public static class TransactionalInterceptorBase implements Serializable
    {
        @Inject
        @Intercepted
        protected Bean<?> interceptedBean;
    }

    @Interceptor
    @Transactional
    public static class TransactionalInterceptor extends
TransactionalInterceptorBase
    {


        @AroundInvoke
        public Object caller(final InvocationContext context)
        {
            return interceptedBean.getBeanClass().getName();
        }
    }
}


However I guess you can use

<dependency>
    <groupId>org.apache.meecrowave</groupId>
    <artifactId>meecrowave-jta</artifactId>
    <version>1.2.4</version>
</dependency>

in the meantime

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le lun. 17 déc. 2018 à 08:50, Mark Struberg <struberg@yahoo.de> a écrit :

> Hi Laird, sorry for the delay!
>
> Gonna look at your example soon.
>
> LieGrue,
> strub
>
>
> > Am 14.12.2018 um 20:08 schrieb Laird Nelson <ljnelson@gmail.com>:
> >
> > Hello; before I file an issue I'd like to check the behavior I'm
> observing with this list.  I've also put this on StackOverflow (
> https://stackoverflow.com/questions/53771466/is-intercepted-bean-a-legal-type-and-qualifier-pair-to-inject
> ).
> >
> > I am using the Narayana transaction CDI machinery (
> https://github.com/jbosstm/narayana/tree/master/ArjunaJTA/cdi/classes/com/arjuna/ats/jta/cdi).
> It works fine in a standalone CDI 2.0 application when Weld is the
> implementation.  It fails in OpenWebBeans 2.0.8.
> >
> > Specifically, the Narayana project includes several interceptors (
> https://github.com/jbosstm/narayana/tree/master/ArjunaJTA/cdi/classes/com/arjuna/ats/jta/cdi/transactional).
> The common base class they all share has this code (
> https://github.com/jbosstm/narayana/blob/77a4ea35287cb2057b62b6d65e99efd96c55074a/ArjunaJTA/cdi/classes/com/arjuna/ats/jta/cdi/transactional/TransactionalInterceptorBase.java#L69-L71
> ):
> >
> > @Inject
> > @Intercepted
> > private Bean<?> interceptedBean;
> >
> > A standalone CDI application attempting to use a transactional method:
> >
> > @Transactional(TxType.REQUIRED)
> > public void frobnicate() {
> >   // whatever
> > }
> >
> > …fails with (ultimately):
> >
> > Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Api
> type [javax.enterprise.inject.spi.Bean] is not found with the qualifiers
> > Qualifiers:
> [@javax.enterprise.inject.Intercepted(),@javax.inject.Named(value="interceptedBean")]
> > for injection into Field Injection Point, field name :  interceptedBean,
> Bean Owner : [TransactionalInterceptorNotSupported,
> WebBeansType:INTERCEPTOR, Name:null, API
> Types:[com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase
> [and so on]
> >
> > Note the @Named(value="interceptedBean") qualifier.  I'm not sure why
> that shows up as the Narayana extension does not add that qualifier and it
> is not present in the interceptor.
> >
> > I assume this is a bug in OpenWebBeans, yes?
> >
> > Best,
> > Laird
>
>

Mime
View raw message