diff --git a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java b/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java index 7e183d7a2f..e301251c4c 100644 --- a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java +++ b/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java @@ -166,24 +166,26 @@ private ApplicationInfo getApplicationInfo(EjbContainerUtil ejbUtil) throws Nami throw new NamingException("Application Information Not Found"); } - private void registerEjbInterceptor() { + private void registerEjbInterceptor(Class component) { try { final Object interceptor = new EjbComponentInterceptor(injectionManager); initialContext = getInitialContext(); final EjbContainerUtil ejbUtil = EjbContainerUtilImpl.getInstance(); final ApplicationInfo appInfo = getApplicationInfo(ejbUtil); - final List tempLibNames = new LinkedList<>(); for (ModuleInfo moduleInfo : appInfo.getModuleInfos()) { final String jarName = moduleInfo.getName(); if (jarName.endsWith(".jar") || jarName.endsWith(".war")) { final String moduleName = jarName.substring(0, jarName.length() - 4); - tempLibNames.add(moduleName); final Object bundleDescriptor = moduleInfo.getMetaData(EjbBundleDescriptorImpl.class.getName()); if (bundleDescriptor instanceof EjbBundleDescriptorImpl) { final Collection ejbs = ((EjbBundleDescriptorImpl) bundleDescriptor).getEjbs(); for (final EjbDescriptor ejb : ejbs) { final BaseContainer ejbContainer = EjbContainerUtilImpl.getInstance().getContainer(ejb.getUniqueId()); + if (ejbContainer.getEJBClass() != component) { + continue; + } + libNames.add(moduleName); try { AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override @@ -206,7 +208,7 @@ public Object run() throws Exception { } } } - libNames.addAll(tempLibNames); + final Object interceptorBinder = initialContext.lookup("java:org.glassfish.ejb.container.interceptor_binding_spi"); // Some implementations of InitialContext return null instead of // throwing NamingException if there is no Object associated with @@ -257,7 +259,7 @@ public boolean bind(Class component, Set> providerContracts) { } if (!ejbInterceptorRegistered) { - registerEjbInterceptor(); + registerEjbInterceptor(component); } Binding binding = Bindings.supplier(new EjbFactory(component, initialContext, EjbComponentProvider.this))