Byte Buddy with JBOSS / Wildfly EJB 3 classes

198 views Asked by At

I'm try to intercept all method into a javaEE application running under widlfly/jboss (in specific case JBOSS EAP 7.3.x)

But really it seems EJB 3.x methods are not intecepted

my code is

      new AgentBuilder.Default()
      .type((ElementMatchers.any()))
      .transform((builder, typeDescription, classLoader, module) -> builder
            .method(ElementMatchers.any()).intercept(Advice.to(MyProfilerTimer.class)))
      .installOn(inst);

So, I enabled "any" as ElementMatcher but also in this case, EJB are not considered

EJBs are annotetad as Stateless (they are not remote ejb)

@SuppressWarnings("all")
@Stateless(name = "MyEJBSession")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class MyEJBSession 
{

I believe due the JBOSS logic to instantiate it via proxy or delegation etc

Do you have idea how can add my intercetor ? i'm using latest byte buddy version

thanks

1

There are 1 answers

0
Rafael Winterhalter On

Byte Buddy registers an implicit .ignore matcher that excludes synthetic types, the bootstrap class loader and Byte Buddy's own types. Mostly, this is what people want but if you use JBoss, it might generate classes that are marked as synthetic. Probably, you need to register a custom ignore matcher that does not exclude the classes.

You can also always register a listener to your agent builder to see if the class is discovered at all.