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

PAYARA-3119 NullPointerException when starting Jersey/EJB Containers with <initialize-in-order> flag true in Ear #3949

Merged
merged 2 commits into from
Jun 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<String> 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<EjbDescriptor> 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<Class<?>> providerContracts) {
}

if (!ejbInterceptorRegistered) {
registerEjbInterceptor();
registerEjbInterceptor(component);
}

Binding binding = Bindings.supplier(new EjbFactory(component, initialContext, EjbComponentProvider.this))