Index: resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/server/servlet/ResteasyBootstrap.java =================================================================== --- resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/server/servlet/ResteasyBootstrap.java (revision 996) +++ resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/server/servlet/ResteasyBootstrap.java (working copy) @@ -124,17 +124,32 @@ if (scanProviders || scanResources) { + logger.debug("Scanning..."); if (applicationConfig != null) throw new RuntimeException("You cannot deploy a javax.ws.rs.core.Application and have scanning on as this may create errors"); URL[] urls = WarUrlFinder.findWebInfLibClasspaths(event); + for (URL u : urls) + { + logger.debug("Scanning WEB-INF/lib/: " + u); + } URL url = WarUrlFinder.findWebInfClassesPath(event); + if (url != null) logger.debug("Scanning WEB-INF/classes at: " + url); AnnotationDB db = new AnnotationDB(); String[] ignoredPackages = {"org.jboss.resteasy.plugins", "org.jboss.resteasy.annotations", "org.jboss.resteasy.client", "org.jboss.resteasy.specimpl", "org.jboss.resteasy.core", "org.jboss.resteasy.spi", "org.jboss.resteasy.util", "org.jboss.resteasy.mock", "javax.ws.rs"}; db.setIgnoredPackages(ignoredPackages); + + // only index class annotations as we don't want sub-resources being picked up in the scan + db.setScanClassAnnotations(true); + db.setScanFieldAnnotations(false); + db.setScanMethodAnnotations(false); + db.setScanParameterAnnotations(false); try { - if (url != null) db.scanArchives(url); + if (url != null) + { + db.scanArchives(url); + } db.scanArchives(urls); try { @@ -299,6 +314,21 @@ if (paths != null) classes.addAll(paths); for (String clazz : classes) { + Class cls = null; + try + { + // Ignore interfaces and subresource classes + // Scanning is different than other deployment methods + // in other deployment methods we don't want to ignore interfaces and subresources as they are + // application errors + cls = Thread.currentThread().getContextClassLoader().loadClass(clazz.trim()); + if (cls.isInterface()) continue; + } + catch (ClassNotFoundException e) + { + throw new RuntimeException(e); + } + logger.info("Adding scanned resource: " + clazz); deployment.getResourceClasses().add(clazz); } Index: resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/ResteasyDeployment.java =================================================================== --- resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/ResteasyDeployment.java (revision 996) +++ resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/ResteasyDeployment.java (working copy) @@ -10,9 +10,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.ws.rs.Path; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; +import javax.ws.rs.ext.Provider; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -215,32 +215,40 @@ { for (Class clazz : config.getClasses()) { - if (clazz.isAnnotationPresent(Path.class)) + if (GetRestful.isRootResource(clazz)) { logger.info("Adding class resource " + clazz.getName() + " from Application " + Application.class.getName()); registry.addPerRequestResource(clazz); } - else + else if (clazz.isAnnotationPresent(Provider.class)) { logger.info("Adding class @Provider " + clazz.getName() + " from Application " + Application.class.getName()); factory.registerProvider(clazz); } + else + { + throw new RuntimeException("Application.getClasses() returned unknown class type: " + clazz.getName()); + } } } if (config.getSingletons() != null) { for (Object obj : config.getSingletons()) { - if (obj.getClass().isAnnotationPresent(Path.class)) + if (GetRestful.isRootResource(obj.getClass())) { logger.info("Adding singleton resource " + obj.getClass().getName() + " from Application " + Application.class.getName()); registry.addSingletonResource(obj); } - else + else if (obj.getClass().isAnnotationPresent(Provider.class)) { logger.info("Adding singleton @Provider " + obj.getClass().getName() + " from Application " + Application.class.getName()); factory.registerProviderInstance(obj); } + else + { + throw new RuntimeException("Application.getSingletons() returned unknown class type: " + obj.getClass().getName()); + } } } } @@ -259,24 +267,6 @@ providerFactory.registerProvider(provider); } - protected void processResource(String clazz) - { - Class resource = null; - try - { - resource = Thread.currentThread().getContextClassLoader().loadClass(clazz.trim()); - } - catch (ClassNotFoundException e) - { - throw new RuntimeException(e); - } - if (resource.isInterface()) return; - if (GetRestful.isRootResource(resource) == false) return; - - System.out.println("FOUND JAX-RS resource: " + clazz); - registry.addPerRequestResource(resource); - } - public String getApplicationClass() { return applicationClass;