2

I have no idea, but my @Inject objects are not initialized with Weld inside of the ManagedService, my example is like this,

@ManagedService(path = "/chat") public class EntryPointWS {
  private final Logger logger = LoggerFactory.getLogger(EntryPointWS.class);
  @Inject private ServiceFactory factory;
}

The same project or code, If i use a normal Servlet to access Weld will initialize the objects for me. Also, I'm running on Tomcat 8, it works fine with the Servlet injection though. Also, ServiceFactory is annotated as @ApplicationScoped.

Just to be clear, to add some more points,

  • org.atmosphere.cdi.CDIObjectFactory (from the cdi pom) is defined in
  • The @Inject doesn't work in AtmosphereInterceptorServices as well.
Fahad
  • 858
  • 1
  • 8
  • 15
  • 1
    I found that the CDI spec doesnt have proper context sharing when we have Websockets, so I plan to use Guice for DI. – Fahad May 15 '15 at 17:04

1 Answers1

0

have you enabled the CDI extension : https://github.com/Atmosphere/atmosphere/wiki/Configuring-Atmosphere's-Classes-Creation-and-Injection

-- Jeanfrancois

jfarcand
  • 1,705
  • 9
  • 6
  • 1
    Yes, I enabled that, the WIKI is actually giving wrong information, with latest 2.3.1 the implementation of CDIObjectFactory is different to what the WIKI says. So I included the pom dep and updated the init-param as follows, org.atmosphere.cpr.objectFactory org.atmosphere.cdi.CDIObjectFactory – Fahad May 14 '15 at 12:19
  • 1
    And I'm using 2.3.1 of atmosphere framework, that should not be a problem right? In the samples I see there is a 3.0.0-SNAPSHOT, – Fahad May 14 '15 at 12:23
  • @Fahad, have you solved this issue? I am also trying to use that pom dep and update init-param. – zygimantus Jun 22 '20 at 13:20