I'm dealing with some weird stuff regarding a legacy application, weblogic and ejb's. I have some code that is deployed in weblogic 10 as an EAR without any errors but now, I'm testing it against 12 version. Unfortunately, it doesn't deploy successfully.
I have a singleton class called "Monitor", with this constructor:
private Monitor(){
if(MonitorProperties.getInstance().getEnabled()){
try{
Context objContext = new InitialContext();
monitorJmsGatewayRemote = (MonitorJmsGatewayRemote)objContext.lookup(MonitorProperties.getInstance().getJndiEjbGatewayProperty());
active = true;
if(tracer.isInfoEnabled()){
tracer.info("'"+FrameworkApplicationContext.getInstance().getApplicationId()+"' Framework monitor is initialize");
}
}catch(Exception excep){
tracer.warn("'"+FrameworkApplicationContext.getInstance().getApplicationId()+"' It's not possible to initialize the framework monitor. "+ excep.getMessage());
active = false;
}
init();
}else{
active = false;
}
}
So, at runtime, the monitor might be enabled or disabled.
On the other hand, I have the MonitorJMSGateway ejb:
@Stateless(name="FwkMonitorJmsGatewayBean")
@Remote(MonitorJmsGatewayRemote.class)
public class MonitorJmsGateway implements MonitorJmsGatewayRemote {
private static Tracer tracer = null;
static{//Inicializamos el log4j
PropertyConfigurator.configure(Thread.currentThread().getContextClassLoader().getResourceAsStream(MonitorJmsGatewayConstants.LOG4J_PROPERTIES_FILE));
tracer = Tracer.getTracer(MonitorJmsGateway.class);
}
The problem is that I'm getting a nullpointer because the log4.properties file doesn't exists. That's fine, ok. But the weird stuff is that this app deploys right in weblogic 10, but not in 12. It sounds like like lazy initialization stuff in 10 (due to the fact that custom monitoring is disabled, the ejb is not initialized, the exception is not raised and the application is successfully deployed)
The log error traces are the following
####<18-sep-2017, 8:42:29,43 AM CEST> <Error> <Deployer> <CASER-5041> <AdminServer> <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <a7a2e7ff-e3ef-4cf9-8686-75d7d0d27689-00000013> <1505716949043> <[severity-value: 8] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-149265> <Failure occurred in the execution of deployment request with ID "2686211063156" for task "0" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: java.lang.NoClassDefFoundError: Could not initialize class es.caser.archit.monitor.jmsgateway.FwkMonitorJmsGatewayBean_nrwnbe_Impl"
weblogic.application.ModuleException: java.lang.NoClassDefFoundError: Could not initialize class es.caser.archit.monitor.jmsgateway.FwkMonitorJmsGatewayBean_nrwnbe_Impl
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:192)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:187)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
at weblogic.work.ContextWrap.run(ContextWrap.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused By: java.lang.NoClassDefFoundError: Could not initialize class es.caser.archit.monitor.jmsgateway.FwkMonitorJmsGatewayBean_nrwnbe_Impl
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at weblogic.utils.classloaders.GenericClassLoader.defineCodeGenClass(GenericClassLoader.java:1357)
at weblogic.ejb.container.ejbc.bytecodegen.GeneratorFactory.generateClass(GeneratorFactory.java:100)
at weblogic.ejb.container.ejbc.bytecodegen.GeneratorFactory.generate(GeneratorFactory.java:51)
at weblogic.ejb.container.ejbc.EJBCompiler.generate(EJBCompiler.java:606)
at weblogic.ejb.container.ejbc.EJBCompiler.doCompile(EJBCompiler.java:201)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:345)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:313)
at weblogic.ejb.container.deployer.EJBDeployer.compileEjbs(EJBDeployer.java:420)
at weblogic.ejb.container.deployer.EJBDeployer.compileIfNecessary(EJBDeployer.java:351)
at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:716)
at weblogic.ejb.container.deployer.EjbModuleExtension.postPrepare(EjbModuleExtension.java:97)
at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:297)
at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:285)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:109)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:192)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:187)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
at weblogic.work.ContextWrap.run(ContextWrap.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
>
####<18-sep-2017, 8:42:29,43 AM CEST> <Error> <Deployer> <CASER-5041> <AdminServer> <[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <a7a2e7ff-e3ef-4cf9-8686-75d7d0d27689-00000012> <1505716949043> <[severity-value: 8] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-149265> <Failure occurred in the execution of deployment request with ID "2686211063156" for task "weblogic.deploy.configChangeTask.0" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: java.lang.NullPointerException"
weblogic.application.ModuleException: java.lang.NullPointerException
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:192)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:187)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
at weblogic.work.ContextWrap.run(ContextWrap.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused By: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:434)
at java.util.Properties.load0(Properties.java:353)
at java.util.Properties.load(Properties.java:341)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:532)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:427)
at es.caser.archit.monitor.jmsgateway.MonitorJmsGateway.<clinit>(MonitorJmsGateway.java:23)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at weblogic.utils.classloaders.GenericClassLoader.defineCodeGenClass(GenericClassLoader.java:1357)
at weblogic.ejb.container.ejbc.bytecodegen.GeneratorFactory.generateClass(GeneratorFactory.java:100)
at weblogic.ejb.container.ejbc.bytecodegen.GeneratorFactory.generate(GeneratorFactory.java:51)
at weblogic.ejb.container.ejbc.EJBCompiler.generate(EJBCompiler.java:606)
at weblogic.ejb.container.ejbc.EJBCompiler.doCompile(EJBCompiler.java:201)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:345)
at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:313)
at weblogic.ejb.container.deployer.EJBDeployer.compileEjbs(EJBDeployer.java:420)
at weblogic.ejb.container.deployer.EJBDeployer.compileIfNecessary(EJBDeployer.java:351)
at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:716)
at weblogic.ejb.container.deployer.EjbModuleExtension.postPrepare(EjbModuleExtension.java:97)
at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:297)
at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:285)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:109)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:192)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:187)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
at weblogic.work.ContextWrap.run(ContextWrap.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
The error log is pointing to the fact that there is no log4j properties file in the classpath. The funny thing is that error doens't appear in weblogic 10.
I think i've found the answer. When the ear is deployed, weblogic 10.3 expects a ejb-descriptor and weblogic 12 uses annotations. That's why weblogic 10 runs "well"