Splunk AppDynamics

Exception in thread "main" JAVA Agent Spring Boot Application container

CommunityUser
Splunk Employee
Splunk Employee

Hi! I am new on AppDynamics and I want to configure a Java Agent on a simple Spring Boot Application, for trial proposes. but when I put the line -javaagent an error is going on.

[root@ip-172-31-33-180 docker-apm]# docker logs docker
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1967)
        at com.singularity.ee.agent.appagent.AgentEntryPoint.getAgentDirFromCommandLine(AgentEntryPoint.java:1976)
        at com.singularity.ee.agent.appagent.AgentEntryPoint.getAgentInstallDirectory(AgentEntryPoint.java:992)
        at com.singularity.ee.agent.appagent.AgentEntryPoint.premain(AgentEntryPoint.java:471)
        ... 6 more
FATAL ERROR in native method: processing of -javaagent failed
Aborted (core dumped)

this is my dockerfile

FROM openjdk:8
ADD docker-spring-boot.jar docker-spring-boot.jar
EXPOSE 8080
ADD AppServerAgent AppServerAgent
RUN apt-get update && apt-get install telnet
RUN chmod -R o+x /AppServerAgent
RUN chmod 777 /AppServerAgent
WORKDIR /AppServerAgent
ENV JAVA_OPTS=-javaagent:javaagent.jar
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /docker-spring-boot.jar" ]
#ENTRYPOINT [ "sh", "-c", "java -Djava.security.egd=file:/dev/./urandom -jar /docker-spring-boot.jar" ]

thanks

Labels (1)
0 Karma
1 Solution

Peter_Holditch
Builder

Walter,

I suspect if you change

ENV JAVA_OPTS=-javaagent:javaagent.jar

to

ENV JAVA_OPTS=-javaagent:/AppServerAgent/javaagent.jar

The agent may load successfully.

Note, we have published some docker files illistrating how you can install the agent in a docker environment.  This one is pretty close to what you're trying to achieve.

Warm regards,

Peter

View solution in original post

Peter_Holditch
Builder

Walter,

I suspect if you change

ENV JAVA_OPTS=-javaagent:javaagent.jar

to

ENV JAVA_OPTS=-javaagent:/AppServerAgent/javaagent.jar

The agent may load successfully.

Note, we have published some docker files illistrating how you can install the agent in a docker environment.  This one is pretty close to what you're trying to achieve.

Warm regards,

Peter

CommunityUser
Splunk Employee
Splunk Employee

So Simple, thanks!

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...