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 1 commit
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
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018 [Payara Foundation and/or its affiliates].
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -166,24 +167,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
Expand All @@ -206,7 +209,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
Expand Down Expand Up @@ -257,7 +260,7 @@ public boolean bind(Class<?> component, Set<Class<?>> providerContracts) {
}

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

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