Wildfly throws “Unable to find a constructor that takes a String param or a valueOf() or fromString() method for javax.ws.rs.QueryParam” error

≯℡__Kan透↙ 提交于 2019-12-04 14:15:56

When you are using classpath scanning, JAX-RS components annotated with @Path or @Provider will get picked up and registered. There are a couple way to use classpath scanning. The most common way is to just have an empty Application class annotated with @ApplicationPath

@ApplicationPath("/api")
public class MyApplication extends Application {}

This is enough for a JAX-RS application to be loaded, and to have the application's classpath scanned to components to register.

But, per the specification, once we override any of the Set<Object> getSingletons or Set<Class> getClasses methods of the Application class, and return a non-empty set, this automatically disables classpath scanning, as it is assumed we want to register everything ourselves.

So in previous cases, you were probably just using classpath scanning. In this case, you need to explicitly add the provider to the set of classes in your getClasses method, since you overrode the method to add other component classes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!