Closed mathieuancelin closed 13 years ago
Started something here :
https://github.com/mathieuancelin/core/commit/bccdd3323bd9f687de16b59179cd37be29e5b079
Calling a method on a application scoped service bean obtain using the Service interface give me a "Singleton is not set for bundle 7"
Here the service interface and implementation:
public interface ContextualService {
long getId();
}
@Publish
@Name("Application")
@ApplicationScoped
public class ApplicationScopedContextualService implements ContextualService {
private final long id = System.nanoTime();
@Override
public long getId() {
return id;
}
}
The way the service is obtained:
@Inject
@Name("Application")
private Service<ContextualService> applicationScopedContextualService;
public ContextualService getApplicationScopedContextualService() {
return applicationScopedContextualService.get();
}
The test code:
ContextualService applicationScopedContextualService = provider.getApplicationScopedContextualService();
Assert.assertNotNull("The application scoped contextual service was null", applicationScopedContextualService); //Okay
long applicationScopedContextualServiceId = applicationScopedContextualService.getId(); //throws the exception
The same thing work just fine using a @Dependent service bean. I'm going to commit the test code on my fork.
Did you try with the patched version of Weld ? If so, it's always the same Weld issue and we need to fix it (at least for OSGi environment).
If you want to start investigations about that, I can show you some tests I ran and you can also speak with @pmuir on how to do it the best way.
If I remember well, last time we spoke about it, one of the solution was to patch SingletonProviders so they can use some kind of contextual ID (a String) to target the right Weld container and embed this ID in beans or proxy.
Let me know.
The title speaks for itself