Reputation: 4464
So, we've built a webapp using Grizzly/Jersey. You run the produced jar file, and it then provides REST endpoints, which allow pulling data from the database and creating new entries, etc. For one reason or another, we now want to migrate to a webserver, like Payara or Glassfish or something. I'm having trouble getting it to work. It compiles to a war, now, and gets deployed to Payara. Following Deploying jersey web services on Payara 4 doesn´t expose methods, I got it to at least acknowledge that there are endpoints. However, they rely on an injected EntityManager, which we define/bind (along with its dependencies) in a ResourceConfig subclass, which isn't getting loaded, so it crashes. Anybody know how to load the ResourceConfig? Also, anything else that will need to be done to get this working?
Upvotes: 0
Views: 308
Reputation: 209102
If you're going off the answer from your linked post
@javax.ws.rs.ApplicationPath("API_PATH_FOR_JAXRS")
public class SampleApplication extends Application {
}
This would explain the behavior you are seeing. An empty Application
annotated with @ApplicationPath
will cause the Jersey bootstrap to scan the classpath for @Path
and @Provider
class, and register those classes.
But you are using a ResourceConfig
to do all your registration yourself. It just happens that ResourceConfig
is actually a subclass of Application
. So instead of creating a new Application
subclass to put the @ApplicationPath
annotation on, just put on your ResourceConfig
subclass.
If you were not subclassing ResourceConfig
previously, e.g.
ResourceConfig config = new ResourceConfig()
.packages("...")
.register(...);
Then just subclass it now
@ApplicationPath("...")
public class AppConfig extends ResourceConfig {
public AppConfig() {
packages("...");
register(...);
}
}
Upvotes: 0