Ich habe ein ähnliches Problem auf die hier angesprochen: How do I get my Jersey 2 Endpoints to eagerly initialize on startup?@Immediate Anmerkung Verwendung in Jersey2
Aber etwas weiter auf der ganzen Linie. Ich kann meine Ressource sofort geladen bekommen, aber wenn ich versuche, sie durch Aufruf der REST-URL zu benutzen, bekomme ich die folgende Stack-Trace.
java.lang.IllegalStateException: Could not find an active context for org.glassfish.hk2.api.Immediate
2. java.lang.IllegalStateException: While attempting to create a service for
SystemDescriptor(
implementation=com.service.MyResource
contracts={com.service.MyResource}
scope=org.glassfish.hk2.api.Immediate
qualifiers={}
descriptorType=CLASS
descriptorVisibility=NORMAL
metadata=
rank=0
loader=null
proxiable=null
proxyForSameScope=null
analysisName=null
id=150
locatorId=0
identityHashCode=1249600275
reified=true) in scope org.glassfish.hk2.api.Immediate an error occured while locating the context
Meine TResource Klasse ist so kommentiert:
@Immediate
@Path("/test/v1")
public class TResource {
Mein Grizzly basierter Server ist Setup wie so:
ResourceConfig rc = new ResourceConfig()
.packages(true,
"com.mystuff"
)
.property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");
HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(base_uri), rc);
ApplicationHandler handler = new ApplicationHandler(rc);
ServiceLocatorUtilities.enableImmediateScope(handler.getServiceLocator());
Jede mögliche Anleitung geschätzt sein! prost, Phil
Dank! Das löst das Problem tatsächlich. Sehr geschätzt! Phil – Phil