WildFly 14 migration | RestEasy issues
abhinav.gupta01 Sep 18, 2018 7:44 AMHello,
we are currently on wildfly 10 and now planning to move to WildFly 14.0.1 Final.
while we attempt to deploy our ear , we see issues around deployment for existing Filters written in our application.
we see that with WIldFly 14 , org.jboss.resteasy.spi.Registry is not available in ServletContext.
Below is what we are initializing :
@Override
public void init(FilterConfig cfg) throws ServletException {
super.init(cfg);
ServletContext context = cfg.getServletContext();
Registry registry = (Registry) context.getAttribute(Registry.class.getName());
ResteasyProviderFactory providerFactory =
(ResteasyProviderFactory) context.getAttribute(ResteasyProviderFactory.class.getName());
// This code is copied as-is from (private) ModuleProcessor.processInjector()
for (final Binding<?> binding : injector.getBindings().values()) {
final Type type = binding.getKey().getTypeLiteral().getType();
if (type instanceof Class) {
final Class<?> beanClass = (Class) type;
if (GetRestful.isRootResource(beanClass)) {
final ResourceFactory resourceFactory = new GuiceResourceFactory(binding.getProvider(), beanClass);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Registering factory for " + beanClass.getName());
}
registry.addResourceFactory(resourceFactory);
}
if (beanClass.isAnnotationPresent(Provider.class)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Registering provider instance for " + beanClass.getName());
}
providerFactory.registerProviderInstance(binding.getProvider().get());
}
}
}
}
PS : I am getting nullpointerexception @ registry.addResourceFactory(resourceFactory); and this is working fine for WildFly10.
Any help is appreciated.
Thanks,
Abhinav