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

Deploying jar to Elastic Beanstalk

aws
elasticbeanstalk

#1

Hi,

I understand the instructions here: https://docs.newrelic.com/docs/agents/java-agent/additional-installation/aws-elastic-beanstalk-installation-java on how to deploy a Java application with NewRelic.

However I believe the assumption being made is that one has a WAR file (re: WEB-INF/lib).

If I have a JAR file (a spring boot application packaged using maven), which does not have a WEB-INF/lib folder, where would these files need to be placed in the application and where should we look for them in EC2.


#2

Hi, @ashish8: You may find this post helpful, specifically the first option of using .ebextensions to download the agent to the /var folder:


#3

Thanks Phil!

It looks like ebextensions will be the best option for me. However, may you please advise where exactly in my application directory the .ebextensions folder needs to be created? Below is my application structure:



I followed the instructions here: https://github.com/jkubrynski/spring-boot-new-relic-agent/blob/master/pom.xml to unpack the newrelic resources during build to copy the contents of the agent (v4.9.0) into the classes folder of the build (classes) directory so they get packaged into the final jar file.

For the ebextensions route, do I need the above?


#4

According to the AWS documentation:

Place all of your configuration files in a single folder, named .ebextensions , in the root of your source bundle.

I would think that is at the same level as your pom.xml file.

I don’t think you need to package the New Relic files into your jar file; they will be downloaded to the host’s /var directory by the .ebextensions configuration.


#5

Perfect thanks!

I’ll try that and post results here for future reference.


#6

I tried the above and was able to get newrelic setup on the my ec2 but I’m not seeing anything on my NewRelic dashboard. This is what is under my /var/newrelic:

-rw-rw-r-- 1 root root 122 Nov 16 09:05 CHANGELOG
-rw-rw-r-- 1 root root 4488 Nov 16 09:05 extension-example.xml
-rw-rw-r-- 1 root root 16564 Nov 16 09:05 extension.xsd
-rw------- 1 root root 6279 Dec 18 11:24 LICENSE
-rw-rw-r-- 1 root root 44232 Dec 18 11:23 newrelic-api.jar
-rw-rw-r-- 1 root root 199000 Dec 18 11:50 newrelic-api-javadoc.jar
-rw-rw-r-- 1 root root 34523 Dec 18 11:50 newrelic-api-sources.jar
-rw-rw-r-- 1 root root 10840288 Dec 18 11:34 newrelic.jar
-rw-rw-r-- 1 root root 12463 Nov 16 09:05 newrelic.yml
-rw-rw-r-- 1 root root 83581 Nov 16 09:05 nrcerts
-rw-rw-r-- 1 root root 3456 Nov 16 09:05 README.txt

One thing I did differently is instead of

namespace: "aws:elasticbeanstalk:container:tomcat:jvmoptions"

I used

namespace: "aws:elasticbeanstalk:application:environment"

because EBS could not find the param jvmoptions

Not sure what to troubleshoot and where to start. Any advice much appreciated?


#7

I am pretty sure it has to be jvmoptions. Are you running on Apache Tomcat?


#8

Yes. Below is a log output for my application being started:

2018-12-21 14:25:38.719 INFO 24953 — [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 5000 (http) with context path ‘’
2018-12-21 14:25:38.724 INFO 24953 — [ main] com.spendingpowre.MyApplication : Started MyApplication in 29.917 seconds (JVM running for 31.891)
2018-12-21 14:26:08.932 INFO 24953 — [nio-5000-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet ‘dispatcherServlet’


#9

What happens when you use the container:tomcat:jvmoptions namespace? Do you get an error message?


#10

I’m getting the following error:

InvalidParameterValue: Unknown template parameter: JVMOptions

with the following config:

namespace: "aws:elasticbeanstalk:container:tomcat:jvmoptions"
option_name: "JVM Options"
value: "-javaagent:/var/newrelic/newrelic.jar -Dnewrelic.config.app_name=My App Prod -Dnewrelic.config.license_key=xxxxxxxxx"

#11

Hey @ashish8,
I’m noticing something a little odd on the InvalidParameterValue. Take note of each character… The parameter the error message references is JVMOptions but the namespace value is jvmoptions (all lowercase).

I’m wondering if there is another config file or something else in the file that is causing an issue. The option_name: is “JVM Options” but it has a space, of course. Are there any additional stanzas in the config file or files in the .ebextensions folder?

In general, the format we have presented in our level-up post should work. There are a few rules around making config files for the .ebextensions directory that you may find helpful. You’ll note on the AWS site that their yaml configuration is presented a little differently, but this one and the ones on their site are each valid yaml syntax formats. Another thought is that I’m wondering if the Spring startup doesn’t like the quotations marks in the file. Note that in the AWS examples on their site that they are omitted, so it might be worth trying without quotes.

Can you take a look at the following docs on AWS and ensure that the config file and structure you are using conforms to the AWS specification?

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform.html

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions-optionsettings.html


#12

I finally figured this out. I’ve provided step-by-step instructions for the community here:


#13

Thanks for sharing your findings @ashish8 - I’m glad to see you got this figured out :smiley: