CDI ClassNotFoundException Exception At Deployment Time (Doc ID 1552823.1)

Last updated on NOVEMBER 05, 2016

Applies to:

Oracle Weblogic Server - Version 12.1.1.0 and later
Information in this document applies to any platform.

Symptoms

When deploying an application using CDI feature into WLS 12.1.1.0.3 version , it fails with the following ClassNotFoundException exception :

Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
  at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
  at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
  at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
  at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:178)
  at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:43)
  at it.esselunga.oracle.DummyActivity.(DummyActivity.java:7)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:264)
  at com.oracle.injection.provider.weld.BasicResourceLoader.classForName(BasicResourceLoader.java:27)
  at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:77)
  at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:115)
  at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:168)
  at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:331)
  at com.oracle.injection.provider.weld.WeldInjectionContainer.deploy(WeldInjectionContainer.java:98)

 
The applicaton is composed of web module which is having a servlet TestCaseServlet injecting a bean (MyManagedBean.class) and a not used class  (DummyActivity.class) .

The  related WAR file consists of :
  - Web-inf \ classes \myweb\TestCaseServlet.class
  - Web-inf \lib  \ again_ncdfeCDI.jar
  which contains
             Metain-inf
             beans.xml               
        mypackage \MyManagedBean.class
        mypackage \DummyActivity.class
 
 
TestCaseServlet  servlet  is injecting MyManagedBean bean as  the following  :

Note that the static field  (LOG) in DummyActivity class  refering  anohter class (org.apache.log4j.Logger class is not packaged in the deployed application or in WLS classpath) .

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