2

I have the following setup

 - tokenmanager.jar
    - SecurityService.class
    - MyService.class (@Inject SecurityService)
    - META-INF
        - beans.xml

 - MyApplication.war
     - SecurityServiceProducer.class
     - WEB-INF
        - beans.xml
        - web.xml
     - lib
         - tokenmanager.jar

The idea is that the application can decide how the SecurityService is composed and injected in the classes of the tokenmanager. So the tokenmanager.jar could be used by several teams with their own injections of dependencies. However the SecurityServiceProducer is never used on startup. I'm making use of liberty 20.0.0.x as server environment (with the addendum that everything still needs to run on WAS 8.5.5.9). For that reason I'm still forced to be using beans 1.0

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">

</beans>

Producer

import javax.inject.Inject;
import javax.ws.rs.Produces;

public class SecurityServiceProducer {

    @Inject
    @RedisTokenStoreQualifier
    private TokenStoreDao tokenStoreDao;

    @Inject
    @AdfsIdentityProviderServiceQualifier
    private IdentityProviderService identityProviderService;

    @Inject
    private SecurityServiceFactory securityServiceFactory;

    @Produces
    public SecurityService producer() {
        return securityServiceFactory.produce(tokenStoreDao, identityProviderService);
    }
}

I tried several steps already

  • Tried putting @Singleton on the producer
  • Tried putting @ApplicationScoped on the producer
  • Tried putting @Startup on the producer
  • read on bean-discovery-mode=all but that seems to be beans 1.1 and i'm on beans 1.0

Can anyone point me to something else I overlooked ?

covener
  • 17,402
  • 2
  • 31
  • 45
kenny
  • 1,157
  • 1
  • 16
  • 41
  • Asked 28 minutes ago, just 7 views and two upvotes... Remarkable... – Kukeltje May 27 '20 at 11:55
  • and best of all I didn't even cheat and ask a coworker to upvote, even more remarkable. I'm more embarrassed about the actual solution :( – kenny May 27 '20 at 13:09
  • Don't be embarrassed... if it is the first time, it will happen again, believe me (yes, personal experience ;-)) – Kukeltje May 27 '20 at 13:12

1 Answers1

4

For the @Produces annotation, you're using javax.ws.rs.Produces instead of javax.enterprise.inject.Produces

Azquelt
  • 1,380
  • 10
  • 15
  • How could I have missed that !!! thanks this is embarrassing :( I've been looking at this for two hours now – kenny May 27 '20 at 13:08