Over a million developers have joined DZone.

Monitoring ADF Application Deployed on Weblogic Using Newrelic Java Agent

Evolve your approach to Application Performance Monitoring by adopting five best practices that are outlined and explored in this e-book, brought to you in partnership with BMC.

I had registered on Newrelic some time back. I was lured into the registration by the free T-Shirt on offer for anyone who deploys Newrelic agent and use it to monitor the application. I never thought one could monitor the applications deployed locally. And then again today there was an email about anyone registering gets one month of CodeSchool subscription. So why not give Newrelic a try.

I have been developing the tool for my project in ADF and deploying it to weblogic server. So I thought of using the Newrelic for monitoring Java applications. In this post I am using WebLogic Server of version 10.3.5.0. The documentation provided here didn’t really help in setting up completely.

I used JDeveloper with IntegratedWebLogicServer for managing the weblogic server.

Here are the steps to follow:
1. Download the Java Agent from here. And unzip to the Weblogic server home which is by default at this location:C:\Oracle\Middleware\wlserver_10.3. So you will now see a newrelic folder in your weblogic home directory.

2. Now you have to attach the Java agent which is the newrelic.jar to your weblogic server at the time of its startup. For the version of weblogic server I used and on the Windows machine the weblogic startup is managed by startWebLogic.cmd. In my case this script was present in:C:\Users\USER_NAME\AppData\Roaming\JDeveloper\system11.1.2.1.38.60.81\DefaultDomain\bin. Another way to find which script is being used is that when you try to start the IntegratedWebLogicServer from your JDeveloper you see some logging happening and in that you can find out which script was used to start your weblogic server. The screenshot shows the logging showing the script name:
WeblogicStartCommand

Open the startWebLogic.cmd file and add the following line somewhere at the top of the script:

set JAVA_OPTIONS=%JAVA_OPTIONS% -javaagent:"C:\Oracle\Middleware\wlserver_10.3\newrelic\newrelic.jar"

the path should be the path where you extracted the newrelic zip.

3. Now start the weblogic server and deploy your application to it using JDeveloper. When the server starts it picks the NewRelic agent and you can see some logging similar to:

Jun 26, 2013 23:21:38 +0530 NewRelic 1 INFO: Agent is using Logback
Jun 26, 2013 23:21:38 +0530 NewRelic 1 INFO: Loading configuration file "C:\Oracle\Middleware\wlserver_10.3\newrelic\.\newrelic.yml"

And you will also see a logs directory being created in your agent directory and see the logs being updated on newrelic_agent.log

Once you are confirmed that your Newrelic agent has attached itself to the weblogic server, you can visit the Newrelic dashboard from their site and view the data being sent by the Newrelic agent.

Some issues I found

Issue 1: Failed hostname verification check
Once the agent is running it keeps communicating with the Newrelic Saas application to send the application statistics. I found that the Weblogic server was reporting the following error:

<Jun 26, 2013 10:47:58 PM IST> <Warning> <Security> <BEA-090504> <Certificate chain received from collector.newrelic.com. - 204.93.223.153 failed hostname verification check. Certificate contained *.newrelic.com but check expected collector.newrelic.com.>

One can resolve this by turning off the Domain name verification which I found here. I opened the startWebLogic.cmd file and appended the following line: -Dweblogic.security.SSL.ignoreHostnameVerification=true. You would have to append this at two places. Your startWebLogic.cmd will not look something like:

if "%WLS_REDIRECT_LOG%"=="" (
echo Starting WLS with line:
echo %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy -Dweblogic.security.SSL.ignoreHostnameVerification=true %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
%JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy -Dweblogic.security.SSL.ignoreHostnameVerification=true %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
) else (
echo Redirecting output from WLS window to %WLS_REDIRECT_LOG%
%JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy -Dweblogic.security.SSL.ignoreHostnameVerification=true %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%  >"%WLS_REDIRECT_LOG%" 2>&1
)

Issue 2: Proxy settings related issue
One can set the proxy settings in the newrelic.yml file which can be found in the newrelic directory or the directory where your newrelic agent is present.

With this I was able to manage my ADF application deployed to a local weblogic server using the Newrelic Java application monitoring tool.

Let me know if you are stuck trying the above steps.

Learn tips and best practices for optimizing your capacity management strategy with the Market Guide for Capacity Management, brought to you in partnership with BMC.

Topics:

Published at DZone with permission of Mohamed Sanaulla, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}