Why does Jersey say "Array of packages must not be null or empty" when I
create my own PackagesResourceConfig?
I created my own PackagesResourceConfig that looks like this:
import com.sun.jersey.api.core.PackagesResourceConfig;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
public class ResourceConfigClass extends PackagesResourceConfig {
@Override
public Map<String, MediaType> getMediaTypeMappings() {
Map<String, MediaType> map = new HashMap<String, MediaType>();
map.put("xml", MediaType.APPLICATION_XML_TYPE);
map.put("json", MediaType.APPLICATION_JSON_TYPE);
return map;
}
}
But now when I start my app, it gives me an error that says:
Array of packages must not be null or empty
That comes from this source code in Jersey:
/**
* Search for root resource classes declaring the packages as an
* array of package names.
*
* @param packages the array package names.
*/
public PackagesResourceConfig(String... packages) {
if (packages == null || packages.length == 0)
throw new IllegalArgumentException("Array of packages must not be
null or empty");
init(packages.clone());
}
But I've already set the packages in my web.xml by setting the
com.sun.jersey.config.property.packages param so it shouldn't be null.
No comments:
Post a Comment