private void addServletWithExistingRegistration(ServletContext sc, ServletRegistration sr,
Class<? extends Application> a, Set<Class<?>> classes) {
if (sr.getClassName() == null) {
final ResourceConfig rc = new DeferredResourceConfig(a, getRootResourceAndProviderClasses(classes));
final Map<String, Object> initParams = new HashMap<String, Object>();
for(Map.Entry<String, String> entry : sr.getInitParameters().entrySet())
initParams.put(entry.getKey(), entry.getValue());
rc.setPropertiesAndFeatures(initParams);
final ServletContainer s = new ServletContainer(rc);
sr = sc.addServlet(a.getName(), s);
if (sr.getMappings().isEmpty()) {
final ApplicationPath ap = a.getAnnotation(ApplicationPath.class);