Function Plugin ClassNotFoundException - Spring Framework AnnotationConfiguration

I have created a function plugin that uses a Spring ApplicationContext to manage service objects.  The context is instantiated in a static initializer block of the @Category class.  @Function methods use the getBean() method to access services required by the functions.  When I deploy the plugin, the configuration class can not be found when my @Category class is initialized (ClassNotFoundException).  I've also deployed with a modification to use package scanning, which deploys successfully without the exception, but fails when the function is used from a user interface.  The failure is caused by one of the services not being available from the application context when the @Function method attempts to retrieve it, so it still remains that the classes are not being found on the classpath.  I have already double checked the JAR file to ensure the classes were added.

This sounds like a class loader issue.  Perhaps OSGi not permitting the reflection required by Spring ??  Is it possible to run small Spring applications within plugin JARs?  Below is my approach with real names redacted.

@MyFunctionsCategory
public class MyFunctionsFacade {
    
    // make the Spring container static in case the Appian plugin architecture creates new instances of plugin objects
    // ensures that the container is only created and loaded once
    private static final AnnotationConfigApplicationContext context;
    
    static {
        context = new AnnotationConfigApplicationContext();
        context.register(MyConfig.class);        
        context.refresh();
    }

    @Function    
    public MyCDT myCustomFunction(@Parameter Integer id, @Parameter String param2){
        MyService service = context.getBean(MyService.class);

        MyCDT result = service.serviceMethod(id, param2);
        return result;
    }
}

  Discussion posts and replies are publicly visible