I have running TomEE+ 1.5.1 and trying to create an CDI extension. I created a class implementing javax.enterprise.inject.spi.Extension and put that class name into the file META-INF/services/javax.enterprise.inject.spi.Extension
The class itself is simple:
import java.util.HashSet;
import java.util.Set;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
public class ScanAllClassesExtension implements Extension {
private Set<Class<?>> allClasses;
public void handleProcessAnnotatedTypeEvent(@Observes ProcessAnnotatedType<?> processAnnotatedTypeEvent) throws Exception {
Class<?> type = processAnnotatedTypeEvent.getAnnotatedType().getJavaClass();
getAllClasses().add(type);
}
public Set<Class<?>> getAllClasses() {
if (allClasses == null) {
allClasses = new HashSet<Class<?>>();
}
return allClasses;
}
}
On deploying on TomEE i got this error:
java.util.ServiceConfigurationError: javax.enterprise.inject.spi.Extension: Provider test.extensions.ScanAllClassesExtension not found
While debugging in OpenEJB this error is caused by an ClassNotFoundException, but the right path is in the url list of the class loader.
I have no clue why this is happening and i hope anyone can help me.