Saturday, December 12, 2015

Multiple time Invoking custom Nucleus initializer for Apache Tomcat in JBOSS EAP 6 and ATG 11


Issue:

During server startup in JBOSS EAP 6.X version with ATG 11, nucleus tries to initialize multiple times.
It prints the CLASSPATH and CONFIGPATH multiple times in logs.
You may see errors like ERROR [stderr] (ServerService Thread Pool -- 52)   at atg.nucleus.servlet.NucleusServlet.init(NucleusServlet.java:465)

The stack trace could also be:
ERROR [stderr] (ServerService Thread Pool -- 126) java.lang.NoSuchFieldException: policy
ERROR [stderr] (ServerService Thread Pool -- 126)  at java.lang.Class.getDeclaredField(Class.java:1953)
ERROR [stderr] (ServerService Thread Pool -- 126)  at atg.servlet.ServletUtil.setJBoss5PageCompileClasspath(ServletUtil.java:680)
ERROR [stderr] (ServerService Thread Pool -- 126)  at atg.nucleus.servlet.NucleusServlet.setJBoss5PageCompileClasspath(NucleusServlet.java:1371)
ERROR [stderr] (ServerService Thread Pool -- 126)  at atg.nucleus.servlet.NucleusServlet.initBigEarNucleus(NucleusServlet.java:1299)
ERROR [stderr] (ServerService Thread Pool -- 126)  at atg.nucleus.servlet.NucleusServlet.init(NucleusServlet.java:465)
ERROR [stderr] (ServerService Thread Pool -- 126)  at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194)
ERROR [stderr] (ServerService Thread Pool -- 126)  at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1100)
ERROR [stderr] (ServerService Thread Pool -- 126)  at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3593)
ERROR [stderr] (ServerService Thread Pool -- 126)  at org.apache.catalina.core.StandardContext.start(StandardContext.java:3802)
ERROR [stderr] (ServerService Thread Pool -- 126)  at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163)
ERROR [stderr] (ServerService Thread Pool -- 126)  at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61)
ERROR [stderr] (ServerService Thread Pool -- 126)  at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96)
ERROR [stderr] (ServerService Thread Pool -- 126)  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
ERROR [stderr] (ServerService Thread Pool -- 126)  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
ERROR [stderr] (ServerService Thread Pool -- 126)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
ERROR [stderr] (ServerService Thread Pool -- 126)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
ERROR [stderr] (ServerService Thread Pool -- 126)  at java.lang.Thread.run(Thread.java:745)
ERROR [stderr] (ServerService Thread Pool -- 126)  at org.jboss.threads.JBossThread.run(JBossThread.java:122)
ERROR [stderr] (ServerService Thread Pool -- 61) java.lang.NoSuchFieldException: policy
ERROR [stderr] (ServerService Thread Pool -- 61)   at java.lang.Class.getDeclaredField(Class.java:1953)


Cause:

 JBOSS 6  introduce a new element <initialize-in-order> element in <ear>/META_INF/application.xml

Solution:

When running runAssembler use the argument -jboss which adds the <initialize-in-order> element in application.xml