Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Newrelic installation on amazon aws ec2-user


#1

I am trying to install Newrelic Java agent on my amazon aws ec2-user linux 64 bit server.

  1. i have tomcat7 installed using yum

yum install tomcat7 which is running perfectly.

  1. I have created an account on newrelic and downloaded the zip file.
  2. installation path is : /home/ec2-user/newrelic_new/newrelic/newrelic.jar
  3. i have made below entry in tomcat7/conf/tomcat7.conf file
    export JAVA_OPTS="$JAVA_OPTS
    -javaagent:/home/ec2-user/newrelic_new/newrelic/newrelic.jar"

But now my tomcat7 is not starting after making above entry in tomcat7.conf.

Please help me out where i am missing & to start reporting newrelic to amazon aws linux and tomcat webapp


#2

Hi, @yugdeep: You might check the catalina.yyyy-mm-dd.log file in your Tomcat installation’s logs folder for information about why Tomcat will not start.


#3

Hello Phil,

Thanks for your reply.
I have removed below entry from my tomcat7/conf/tomcat7.conf
export JAVA_OPTS="$JAVA_OPTS
-javaagent:/home/ec2-user/newrelic_new/newrelic/newrelic.jar"

Now my tomcat and webapp running fine without any issue.

Please help me out where i can make the JAVA_OPTS entry to make newrelic reporting.


#4

Your JAVA_OPTS entry looks fine. The Tomcat logs should tell you why it’s not starting.

You might see if this helps: Java agent with Spring boot application = OutOfMemoryError


#5

Thanks Phil,
But there is no out of memory like error in logs.
Please let me know if i am making the JAVA_OPTS entry in right file i.e tomcat7/conf/tomcat7.conf or i will have to make the JAVA_OPTS entry in /usr/sbin/tomcat7 startup script.

below is my tomcat7.conf file


#6

Also my /usr/sbin/tomcat7 startup script:

!/bin/bash

if [ -r /usr/share/java-utils/java-functions ]; then
. /usr/share/java-utils/java-functions
else
echo “Can’t read Java functions library, aborting”
exit 1
fi

Get the tomcat config (use this for environment specific settings)

if [ -z “${TOMCAT_CFG}” ]; then
TOMCAT_CFG="/etc/tomcat7/tomcat7.conf"
fi

if [ -r “$TOMCAT_CFG” ]; then
. $TOMCAT_CFG
fi

Only source the sysconfig file if TOMCAT_NAME or NAME is defined

This prevents issues when defining NAME in the config file while

still allowing the NAME environment variable to be set when executing

this script

By default the init script exports TOMCAT_NAME

if [ -n “${TOMCAT_NAME}” -a -r “/etc/sysconfig/${TOMCAT_NAME}” ]; then
. /etc/sysconfig/${TOMCAT_NAME}
elif [ -n “${NAME}” -a -r “/etc/sysconfig/${NAME}” ]; then
. /etc/sysconfig/${NAME}
fi

set_javacmd

CLASSPATH munging

if [ -n “$JSSE_HOME” ]; then
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)"
fi
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/bootstrap.jar"
CLASSPATH="${CLASSPATH}:${CATALINA_HOME}/bin/tomcat-juli.jar"
CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)"

if [ “$1” = “start” ]; then
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS
-classpath “$CLASSPATH”
-Dcatalina.base="$CATALINA_BASE"
-Dcatalina.home="$CATALINA_HOME"
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS"
-Djava.io.tmpdir="$CATALINA_TMPDIR"
-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties"
-Djava.util.logging.manager=“org.apache.juli.ClassLoaderLogManager”
org.apache.catalina.startup.Bootstrap start
>> ${CATALINA_BASE}/logs/catalina.out 2>&1 &
if [ ! -z “$CATALINA_PID” ]; then
echo $! > $CATALINA_PID
fi
elif [ “$1” = “start-security” ]; then
${JAVACMD} $JAVA_OPTS $CATALINA_OPTS
-classpath “$CLASSPATH”
-Dcatalina.base="$CATALINA_BASE"
-Dcatalina.home="$CATALINA_HOME"
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS"
-Djava.io.tmpdir="$CATALINA_TMPDIR"
-Djava.security.manager
-Djava.security.policy=="${CATALINA_BASE}/conf/catalina.policy"
-Djava.util.logging.config.file="${CATALINA_BASE}/conf/logging.properties"
-Djava.util.logging.manager=“org.apache.juli.ClassLoaderLogManager”
org.apache.catalina.startup.Bootstrap start
>> ${CATALINA_BASE}/logs/catalina.out 2>&1 &
if [ ! -z “$CATALINA_PID” ]; then
echo $! > $CATALINA_PID
fi
elif [ “$1” = “stop” ]; then
${JAVACMD} $JAVA_OPTS
-classpath “$CLASSPATH”
-Dcatalina.base="$CATALINA_BASE"
-Dcatalina.home="$CATALINA_HOME"
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS"
-Djava.io.tmpdir="$CATALINA_TMPDIR"
org.apache.catalina.startup.Bootstrap stop
>> ${CATALINA_BASE}/logs/catalina.out 2>&1
elif [ “$1” = “version” ]; then
${JAVACMD} -classpath ${CATALINA_HOME}/lib/catalina.jar
org.apache.catalina.util.ServerInfo
else
echo “Usage: $0 {start|start-security|stop|version}”
exit 1
fi


#7

This is the error i am getting while making JAVA_OPTS entry in tomcat7.conf
Please have a look.


#8

What are the permissions on your ~/newrelic_new/newrelic folder? Try changing them to 755:

chmod 755 ~/newrelic_new/newrelic


#9

I have changed the permissions to 755
i.e. chmod 755 ~/newrelic_new/newrelic

But now i am getting error could not find or load main class.


#10

Hello Phil,

I am still not able to make it work due to above error : could not find or load main class.
Please have a look.


#11

Hi, @yugdeep: I don’t have any other suggestions. Hopefully one of our support engineers or a member of the community will step in to help.


#12

Is your app located in /home/ec2-user/newrelic_new/ ? Or have you created that path just for newrelic? You have to include proper classpath.


#13

@yugdeep,

Could you verify that the permissions for the entire newrelic directory are owned by the correct user? My understanding of the yum install of tomcat is that it will create the tomcat user to own the running of the server. Make sure that everything in the newrelic directory is owned by tomcat

sudo chown -R tomcat ~/newrelic_new/newrelic

Also, just echo @Anish.Dharmakkan, make sure that is the correct location of the newrelic.jar file.

Best regards,