I had a stateless EJB:
@Stateless
public class A {
private static final Logger LOG = Logger.getLogger(A.class);
@EJB
private B b;
@EJB
private C c;
private D d = new D();
private E e = new E();
...
}
This EJB was successfully deployed and did its job. Now I no longer have the need in the variable d, therefore, I remove it from the class. The class looks like this now:
@Stateless
public class A {
private static final Logger LOG = Logger.getLogger(A.class);
@EJB
private B b;
@EJB
private C c;
private E e = new E();
...
}
However, after I rebuild the artifact and restart the server with the new artifact, I get the following stacktrace when the bean is called:
Caused by: java.lang.NoClassDefFoundError: D
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
at java.lang.Class.getConstructor0(Class.java:2895)
at java.lang.Class.newInstance(Class.java:354)
at com.oracle.pitchfork.spi.BaseComponentBrokerImpl.getBean(BaseComponentBrokerImpl.java:62)
at com.oracle.pitchfork.spi.EjbComponentCreatorBrokerImpl.getBean(EjbComponentCreatorBrokerImpl.java:33)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbComponentCreatorImpl.java:76)
at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(BaseEJBManager.java:218)
at weblogic.ejb.container.manager.BaseEJBManager.allocateBean(BaseEJBManager.java:244)
at weblogic.ejb.container.manager.StatelessManager.createBean(StatelessManager.java:306)
at weblogic.ejb.container.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:179)
at weblogic.ejb.container.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:108)
at weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:187)
at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:149)
... 39 more
Caused by: java.lang.ClassNotFoundException: D
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:335)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:302)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:180)
... 53 more
The problem goes away when I manually clean the server's cache, but this is the second time I stumbled upon this issue and manual cleaning is certainly not an optimal solution. Does anybody know where the problem could be? Why does Weblogic uses cached stateless(!) EJB? I'm ruing Weblogic 12.1.2 and Ejb 3.0.
