0

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.

Jukkales
  • 117
  • 2
  • 11

1 Answers1

0

can you try tomee 1.6 snapshot (https://repository.apache.org/content/groups/snapshots/org/apache/openejb/apache-tomee/1.6.0-SNAPSHOT/apache-tomee-1.6.0-20130330.041018-36-webprofile.zip)

btw, did you provided in your app the api? it can lead to classloading issues with some versions

Romain Manni-Bucau
  • 3,354
  • 1
  • 16
  • 13