# Error:Could not find or load main class elastic.war . While using elasticsearch APM

**URL:** <https://discuss.elastic.co/t/error-could-not-find-or-load-main-class-elastic-war-while-using-elasticsearch-apm/185142>\
**Category:** Elasticsearch\
**Created:** [June 11, 2019, 9:34am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class-elastic-war-while-using-elasticsearch-apm/185142 "2019-06-11T09:34:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tahseen\_fatima](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tahseen_fatima/32/67789_2.png) [@tahseen\_fatima](https://discuss.elastic.co/u/tahseen_fatima)\
**Post date:** [June 11, 2019, 9:34am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class-elastic-war-while-using-elasticsearch-apm/185142/1 "2019-06-11T09:34:03Z")

</div>

Hey,  
I am connecting elastic apm with spring boot application, I am able to connect my application with .jar file, but now when I am trying it with .war file I am not able to do it due to the following errors.  
When I am running this command I am getting this error.

**java -javaagent:/home/abcd/Desktop/elastic-apm/apm-agent-attach-1.5.0/elastic-apm-agent.jar -war spring-mvc-example.war**  
getting this error.

> Unrecognized option: -war  
> Error: Could not create the Java Virtual Machine.  
> Error: A fatal exception has occurred. Program will exit.

And when I am running this command  
**java -javaagent:/home/abcd/Desktop/elastic-apm/apm-agent-attach-1.5.0/elastic-apm-agent.jar spring-mvc-example.war**

Getting this error

> 2019-06-11 14:57:24.477 [apm-server-healthcheck] INFO co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM server is available: {"ok":{"build\_date":"2019-03-21T14:28:17Z","build\_sha":"56b4ebe0088c9a15ea5eb5f4d491da19f08c1bc6","version":"6.7.0"}}  
> 2019-06-11 14:57:24.564 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.5.0 as war on Java 1.8.0\_191 (Oracle Corporation) Linux 3.10.0-862.el7.x86\_64  
> 2019-06-11 14:57:24.565 [main] WARN co.elastic.apm.agent.configuration.StartupInfo - To enable all features and to increase startup times, please configure application\_packages  
> Error: Could not find or load main class spring-mvc-example.war

Kindly guide.  
Thanks.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 11, 2019, 11:25am UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class-elastic-war-while-using-elasticsearch-apm/185142/2 "2019-06-11T11:25:31Z")

</div>

A `war` is something meant to be deployed in a Web Server like Tomcat for example (WAR mean Web ARchive). It is not meant to be run as a jar unless it has also an embedded `main` jar.

---

<div class="post-metadata">

**Author:** ![tahseen\_fatima](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tahseen_fatima/32/67789_2.png) [@tahseen\_fatima](https://discuss.elastic.co/u/tahseen_fatima)\
**Post date:** [June 11, 2019, 12:25pm UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class-elastic-war-while-using-elasticsearch-apm/185142/3 "2019-06-11T12:25:08Z")

</div>

Okay,  
I'll try with that.  
Thanks,

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 9, 2019, 12:25pm UTC](https://discuss.elastic.co/t/error-could-not-find-or-load-main-class-elastic-war-while-using-elasticsearch-apm/185142/4 "2019-07-09T12:25:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
