Skip to content

Commit

Permalink
PAYARA-3119 NullPointerException when starting Jersey/EJB Containers …
Browse files Browse the repository at this point in the history
…in Order

Signed-off-by: Gaurav Gupta <[email protected]>
  • Loading branch information
jGauravGupta committed Sep 27, 2018
1 parent 0bb4252 commit 54e1fe1
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) [2018] Payara and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -190,24 +191,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 @@ -230,7 +233,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 @@ -281,7 +284,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

0 comments on commit 54e1fe1

Please sign in to comment.