Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource interface class may not be found #251

Open
reckart opened this issue Sep 19, 2022 · 0 comments
Open

Resource interface class may not be found #251

reckart opened this issue Sep 19, 2022 · 0 comments
Labels
⭐️ Enhancement Improvement or new feature for users

Comments

@reckart
Copy link
Member

reckart commented Sep 19, 2022

Describe the bug
When running in an OSGI environment, the TCCL may have access to a component, but the component might be accessing a resource implementing an interface to which the TCCL has no access.

Expected behavior
If the interface class cannot be looked up through the usual path (TCCL, extension classloader), also try the classloader of the resource itself.

        try {
          String name = aDependencies[i].getInterfaceName();
          if (name != null && name.length() > 0) {
>>          Class<?> theInterface = loadUserClass(name); // <= this may only be available through the resourceClass'es classloader

>>          Class<?> resourceClass = getResourceClass(qname); // <= this may be available
            if (!theInterface.isAssignableFrom(resourceClass)) {
              throw new ResourceInitializationException(
                      ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE,
                      new Object[] { qname, aDependencies[i].getInterfaceName(),
                          aDependencies[i].getSourceUrlString() });
            }
          }
        } catch (ClassNotFoundException e) {
          throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND,
                  new Object[] { aDependencies[i].getInterfaceName(),
                      aDependencies[i].getSourceUrlString() });
        }

Please complete the following information:

  • Version: 3.2.0
@reckart reckart added the ⭐️ Enhancement Improvement or new feature for users label Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐️ Enhancement Improvement or new feature for users
Projects
None yet
Development

No branches or pull requests

1 participant