Thank you for the help @Eyal_Koren !
Made changes to the code to call the attacher at the beginning of the application. On start of the server could see the following logs being printed
17:21:14,097 INFO [stdout] (apm-server-healthcheck) 2019-05-20 17:21:14.096 [apm-server-healthcheck] INFO co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM server is available: {"ok":{"build_date":"2019-04-02T14:55:26Z","build_sha":"5665711214eb3fcb956e7d1c61795e427bf97097","version":"6.7.1"}}
17:21:14,143 INFO [stdout] (Attach Listener) 2019-05-20 17:21:14.143 [Attach Listener] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.6.1 as Main on Java 1.8.0_201 (Oracle Corporation) Linux 4.18.0-20-generic
After the above logs, there are bunch of NoClassDefFoundError and ClassNotFoundExceptions as shown below
> 17:21:17,381 ERROR [stderr] (ServerService Thread Pool -- 76) java.lang.NoClassDefFoundError: co/elastic/apm/agent/bci/ElasticApmInstrumentation
> 17:21:17,382 ERROR [stderr] (ServerService Thread Pool -- 76) at javax.servlet.GenericServlet.init(GenericServlet.java:243)
> 17:21:17,382 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
> 17:21:17,382 ERROR [stderr] (ServerService Thread Pool -- 76) at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
> 17:21:17,384 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
> 17:21:17,384 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:303)
> 17:21:17,384 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:143)
> 17:21:17,385 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:583)
> 17:21:17,385 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:554)
> 17:21:17,386 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
> 17:21:17,386 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
> 17:21:17,386 ERROR [stderr] (ServerService Thread Pool -- 76) at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
> 17:21:17,387 ERROR [stderr] (ServerService Thread Pool -- 76) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
> 17:21:17,387 ERROR [stderr] (ServerService Thread Pool -- 76) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
> 17:21:17,387 ERROR [stderr] (ServerService Thread Pool -- 76) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
> 17:21:17,388 ERROR [stderr] (ServerService Thread Pool -- 76) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
> 17:21:17,388 ERROR [stderr] (ServerService Thread Pool -- 76) at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:596)
> 17:21:17,389 ERROR [stderr] (ServerService Thread Pool -- 76) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)
> 17:21:17,390 ERROR [stderr] (ServerService Thread Pool -- 76) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
> 17:21:17,391 ERROR [stderr] (ServerService Thread Pool -- 76) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> 17:21:17,391 ERROR [stderr] (ServerService Thread Pool -- 76) at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> 17:21:17,392 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
> 17:21:17,392 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
> 17:21:17,399 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
> 17:21:17,399 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
> 17:21:17,399 ERROR [stderr] (ServerService Thread Pool -- 76) at java.lang.Thread.run(Thread.java:748)
> 17:21:17,400 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.threads.JBossThread.run(JBossThread.java:485)
> 17:21:17,400 ERROR [stderr] (ServerService Thread Pool -- 76) Caused by: java.lang.ClassNotFoundException: co.elastic.apm.agent.bci.ElasticApmInstrumentation from [Module "javax.servlet.api" version 1.0.0.Final from local module loader @dfd3711 (finder: local module finder @42d3bd8b (roots: /opt/wildfly/wildfly-16.0.0.Final/modules,/opt/wildfly/wildfly-16.0.0.Final/modules/system/layers/base))]
> 17:21:17,401 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
> 17:21:17,401 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
> 17:21:17,401 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
> 17:21:17,402 ERROR [stderr] (ServerService Thread Pool -- 76) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
> 17:21:17,402 ERROR [stderr] (ServerService Thread Pool -- 76)
ElasticApmInstrumentation is a part of elastic-apm-agent-1.6.1.jar if i am not wrong. I have tried adding the jar to
- .classpath
- MANIFEST.MF
- added to WEB-INF/lib
but the error does not seem to go away !