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 (#3949)

Signed-off-by: Gaurav Gupta <gaurav.gupta.jc@gmail.com>
  • Loading branch information
jGauravGupta authored and senivam committed Jun 24, 2019
1 parent a843c05 commit 1719b46
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 1719b46

Please sign in to comment.