0

I'm trying out the APM MoSKito and been trying to deploy the embedded Web UI that will be mapped to [context]/mui/* where the MoSKito interface will be shown.

The problem is that I get the following error when deploying app:

CDI definition failure:WELD-001476: Interceptor [class net.anotheria.moskito.integration.cdi.CountInterceptor intercepts @Count] must be @Dependent

The interceptors are declared in the beans.xml:

<interceptors>
    <class>net.anotheria.moskito.integration.cdi.CountInterceptor</class>
    <class>net.anotheria.moskito.integration.cdi.CallInterceptor</class>
</interceptors>   

But since I'm not able to modify the Maven repositories for this APM, I can't really make These classes use the @Dependent annotation so I don't really understand the problem, I would really apreciate some help. Thanks!

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Esteban Rincon
  • 2,040
  • 3
  • 27
  • 44
  • 1
    Please use better tags next time. I retagged (fully!!!) your question – Kukeltje Nov 17 '16 at 08:00
  • I don't yet see the problem, just wanted to add that from Moskito perspective, all looks good. The interceptor classes are in fact both `@Dependent` (by default CDI add this annotation if you don't pick any other). Are you doing something special with these interceptors yourself? Like building something on top of them? – Siliarus Nov 21 '16 at 13:52
  • @Siliarus, well not really I've been following step by step guide in the MosKito documentation. – Esteban Rincon Nov 21 '16 at 14:01
  • Been following this guide: http://www.moskito.org/integration.html#section-cdi – Esteban Rincon Nov 21 '16 at 14:02
  • 1
    Ok that might explain it :) I suppose you used the same dependencies they have there - e.g. Moskito 2.4.0/2.5.0? Checking code at that release, their interceptors are marked as `@Singleton`, which is indeed incorrect and that is probably why Weld screams at you. It seems this was fixed in version 2.7.0+. Try upgrading and tell me if that helps. – Siliarus Nov 21 '16 at 14:27
  • @Siliarus, that did it! thanks! i had to change the beans.xml interceptor to `net.anotheria.moskito.integration.cdi.count.CountInterceptor` and the monitor class also but it works now. :) – Esteban Rincon Nov 21 '16 at 14:43
  • Glad to hear that, let me put that as an answer so we can close this question. – Siliarus Nov 21 '16 at 15:10

1 Answers1

1

The problem is that MoSKito in versions lower than 2.7.0 has the @Singleton annotation on their interceptors. That doesn't pass Weld validation (interceptors have to be @Dependent beans) and causes the described exception.

The solution is therefore to upgrade the framework to 2.7.0+.As a result of this, an update to beans.xml is needed as the package names of interceptors changed as well.

Siliarus
  • 6,393
  • 1
  • 14
  • 30