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

NPE BeanManager #340

Closed
dmatej opened this issue Nov 8, 2022 · 1 comment
Closed

NPE BeanManager #340

dmatej opened this issue Nov 8, 2022 · 1 comment

Comments

@dmatej
Copy link
Contributor

dmatej commented Nov 8, 2022

The Lookup can end with returning null or throwing an NamingException. The rest of the code should expect that, but doesn't, so I am seeing this in GlassFish's server.log while running the TCK. Despite that all tests passed.

[2022-11-08T17:52:17.540112+01:00] [GlassFish 7.0] [SEVERE] [] [jakarta.enterprise.web.core] [tid: _ThreadID=121 _ThreadName=AutoDeployer] [levelValue: 1000] [[
Error invoking ServletContainerInitializer org.glassfish.soteria.servlet.SamRegistrationInstaller
java.lang.NullPointerException: Cannot invoke "jakarta.enterprise.inject.spi.BeanManager.getBeans(java.lang.reflect.Type, java.lang.annotation.Annotation[])" because "beanManager" is null
at org.glassfish.soteria.cdi.CdiUtils.getBeanReferenceByType(CdiUtils.java:141)
at org.glassfish.soteria.cdi.CdiUtils.getBeanReference(CdiUtils.java:134)
at org.glassfish.soteria.servlet.SamRegistrationInstaller.onStartup(SamRegistrationInstaller.java:81)
at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5282)
at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:629)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5182)
at com.sun.enterprise.web.WebModule.start(WebModule.java:551)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:877)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:144)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:134)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:858)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:644)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1796)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1484)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:88)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:97)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:262)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:353)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:535)
@dmatej
Copy link
Contributor Author

dmatej commented Nov 8, 2022

I am working on a PR ...

dmatej added a commit to dmatej/soteria that referenced this issue Nov 8, 2022
…tion

- Both usages in Soteria require an object, null results in exceptions
- BeanManager can have two possible JNDI names, we don't care which, we need
  an instance.
- The lookup now allows to provide a list contexts which are processed in order.
- IllegalStateException was replaced by NamingException. It's message simply
  reports used unsuccessful names.
- BeanManager is used in functions etc, so the exception may be wrapped by
  IllegalStateException again. Null cannot be provided (old impl then resulted
  in NullpointerException).
- DataSource can still result in the same exception if it is not available, but
  new impl simplified the code.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
arjantijms added a commit that referenced this issue Nov 8, 2022
Fix for #340 - JNDI lookup returns object or throws exception
@dmatej dmatej closed this as completed Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant