Main class not found or loaded while using elasticsearch apm

Error: Could not find or load main class DummyProject

I have set this in catalina.sh
JAVA_OPTS="$JAVA_OPTS -javaagent:/home/abc/Pictures/apm-agent-attach-1.5.0/elastic-apm-agent.jar"

I have set this in setenv.sh
export CATALINA_OPTS="$CATALINA_OPTS -Xms1048m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx2048m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=4096m"
#export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/home/abc/Downloads/elastic-apm-agent-1.5.0.jar"
#-Delastic.apm.service_name=my-cool-service-tahseen
#-Delastic.apm.server_urls=http://localhost:8200"
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/home/abc/Pictures/apm-agent-attach-1.5.0/elastic-apm-agent.jar"
#export CATALINA_OPTS="$CATALINA_OPTS -Delastic.apm.service_name=SampleApp"
export CATALINA_OPTS="$CATALINA_OPTS -Delastic.apm.service_name=DummyProject"
export CATALINA_OPTS="$CATALINA_OPTS -Delastic.apm.application_packages="
export CATALINA_OPTS="$CATALINA_OPTS -Delastic.apm.server_urls=http://172.25.8.45:8200"

when i am running below command i am getting the error.

java -javaagent:/home/abc/Pictures/apm-agent-attach-1.5.0/elastic-apm-agent.jar -Delastic.apm.service_name=DummyProject -Delastic.apm.application_packages= -Delastic.apm.server_urls=http://172.25.8.45:8200 DummyProject

I'm sure that this will not work either:

java DummyProject

Right?

You did not add your own jar and full classname.
That's not related to APM.

Yaa im trying to run a war project DummyProject

java -javaagent:/home/abc/Pictures/apm-agent-attach-1.5.0/elastic-apm-agent.jar -Delastic.apm.service_name=DummyProject -Delastic.apm.application_packages= -Delastic.apm.server_urls=http://172.25.8.45:8200 DummyProject.war

Getting the same error.

Seems like there is a -jar missing before the war file:

java -javaagent:/home/abc/Pictures/apm-agent-attach-1.5.0/elastic-apm-agent.jar -Delastic.apm.service_name=DummyProject -Delastic.apm.application_packages= -Delastic.apm.server_urls=http://172.25.8.45:8200 -jar DummyProject.war

I assume this is a .war file created by Spring Boot which contains an embedded tomcat? If that's a regular .war file, you obviously have to deploy it to your servlet container and start the container with the -javaagent flag.

If it's still not working, please try out what happens if you do

java -jar DummyProject.war

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