Web Services in WLS 12.2.1.3 - Unable to Inject ServletContext Into JAX-RS Resource Through CDI

(Doc ID 2388560.1)

Last updated on APRIL 25, 2018

Applies to:

Oracle WebLogic Server - Version 12.2.1.3.0 to 12.2.1.3.0 [Release 12c]
Information in this document applies to any platform.

Symptoms

Unable to inject ServletContext into a JAX-RS resource through CDI Producer using Web Services on WLS 12.2.1.3.

Trying to inject ServletContext into a JAX-RS resource. They can inject it directly in the resources but can't do it through a CDI producer.

Error:

<Error> <HTTP> <BEA-101017> <[ServletContext@2035473191[app:test-case-servletcontext-inject module:test-case-servletcontext-injectWeb path:null spec-version:3.1],
request: weblogic.servlet.internal.ServletRequestImpl@680ee8e6[ GET /test-case-servletcontext-injectWeb/resources/tests/1 HTTP/1.1 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1]] Root cause of ServletException.

javax.ejb.EJBTransactionRolledbackException: EJB Exception:
at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:416)
at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:161)
at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:103)
at weblogic.ejb.container.internal.BaseLocalObject.__WL_preInvoke(BaseLocalObject.java:69)
at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:22)
Truncated. see log file for complete stacktrace
Caused By: org.jboss.weld.exceptions.IllegalStateException: WELD-000713: Unable to inject ServletContext. None is associated with weblogic.utils.classloaders.GenericClassLoader@32b432b finder:
weblogic.utils.classloaders.CodeGenClassFinder@6a659611 annotation: test-case-servletcontext-inject@test-case-servletcontext-injectWeb, ServletContextService [{weblogic.utils.classloaders.ChangeAwareClassLoader@d0cb5b8 finder:
weblogic.utils.classloaders.CodeGenClassFinder@1762dc32 annotation:
test-case-servletcontext-inject@test-case-servletcontext-injectWeb=ServletCont
ext@2035473191[app:test-case-servletcontext-inject
module:test-case-servletcontext-injectWeb
path:/test-case-servletcontext-injectWeb spec-version:3.1]}]
at org.jboss.weld.bean.builtin.ee.ServletContextBean.newInstance(ServletContextBean.java:53)
at org.jboss.weld.bean.builtin.ee.ServletContextBean.newInstance(ServletContextBean.java:39)
at org.jboss.weld.bean.builtin.AbstractDecorableBuiltInBean.create(AbstractDecorableBuiltInBean.java:52)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:101)
Truncated. see log file for complete stacktrace
>



Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms