adding newrelic addon heroku java - java

I'm trying to add the newrelic addon to my application that is deployed in heroku using Jetty.
This is what i'm trying to do and the answer I get. I Already unpack the newrelic folder in the root.
~ $ java -jar newrelic/newrelic.jar install
Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true -Djava.rmi.server.useCodebaseOnly=true
Jul 16, 2014 03:20:57 +0000 [95 1] com.newrelic INFO: Agent is using Logback
***** ( ( o)) New Relic Java Agent Installer
***** Installing version 3.8.1 ...
Could not edit start script because:
.:. Could not locate a Tomcat, Jetty, JBoss, JBoss7 or Glassfish instance in /app
Try re-running the install command with the -s <AppServerRootDirectory> option or from <AppServerRootDirectory>/newrelic.
If that doesn't work, locate and edit the start script manually.
No need to create New Relic configuration file because:
.:. A config file already exists: /app/newrelic/newrelic.yml
***** Install incomplete
***** Next steps:
For help completing the install,
thank you for the help

What is in /app? Is that where your dispatcher (e.g. Tomcat, Jetty, JBoss, Glassfish, etc.) is located? If your dispatcher is not in /app you should move the newrelic directory to the same directory as your dispatcher. As an alternative, you could edit the startup script (catalina.sh, for example) for the dispatcher and provide the fully qualified path to the newrelic.jar. The error message is telling you that the installer attempted to edit the startup script for the dispatcher (see below) and could not find it. If you were using Tomcat, say, then the installer would want to find a catalina.sh file and add a couple of lines to that file. The installer looked in the parent of newrelic (i.e. /app) and didn't find a bin directory which it would have if Tomcat were a child of /app.
Example 1:
Tomcat is in /var/opt/tomcat and you want to put newrelic in the same directory. If you then took the newrelic directory and made its path /var/opt/tomcat/newrelic then your command java java -jar newrelic/newrelic.jar install will work because the installer will look in /var/opt/tomcat/bin and see the catalina.sh file which it will edit to put a pointer to the newrelic.jar file.
Example 2:
Tomcat is in /var/opt/tomcat and you do not want newrelic to be a child of tomcat and instead want it to live in /app/newrelic. In that case you would edit the catalina.sh file and add the following two lines:
NR_JAR=/app/newrelic/newrelic.jar; export NR_JAR
JAVA_OPTS="$JAVA_OPTS -javaagent:$NR_JAR"; export JAVA_OPTS
Please let me know if you need clarification on any of the above.
Cheers
Adrienne
(New Relic Support)

Related

How to restart/start/stop tomcat as non-root when tomcat is running as service under root?

I have seen lots of tutorials and tips around running tomcat on centos/ubuntu/linux.
I am using centos image in aws to run tomcat.
I did NOT do sudo yum install tomcat7*. This would have created a tomcat service account under with tomcat run will run. The reason I did not do this is because I need to copy (scp) the war file into webapps directory and I cannot scp directly as tomcat user.
Instead, I created a tomcat user with password.
I downloaded the tar.gz, unzipped and moved tomcat into /usr/share/tomcat7.
Following the instructions by this blog, I edited /etc/rc.d/init.d/tomcat as follows.
!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64
CATALINA_HOME=/usr/share/tomcat7
export JAVA_HOME CATALINA_HOME
exec $CATALINA_HOME/bin/catalina.sh $*
Then I executed the following commands
sudo chmod 755 /etc/rc.d/init.d/tomcat
sudo chkconfig --level 2345 tomcat on
I rebooted the machine and on startup tomcat is fired by root user.
I could also see the tomcat page showing corectly.
Now, I scp'ed my war into webapps directory (as tomcat user).
stopped the tomcat and restarted
sudo /etc/init.d/tomcat stop
sudo /etc/init.d/tomcat start
I get permission denied error when trying to write to catalina.out. This is because the catalina.out file is touched by root after centos reboot and now when I restarted tomcat as "tomcat" user, it does not have permission to write to it.
I changed the ownership on catalina.out (chown tomcat:tomcat catalina.out). After this change, I see tomcat starting and logging correctly.
Now the question is what is the right way to do it.
1) I will have jenkins jobs copying the war file to tomcat. so to restart the service, I need to sudo, which I cant from jenkins.
2) changing ownership of catalina.out is not right thing to do. if machine reboots, catalina.out is owned by tomcat and root cannot write to it. so there are problems of this catalina.out owned by either root or tomcat user.
Thanks for suggestions

New Relic Java Installation for Confluence

I'm trying to install New Relic on an Ubuntu 14.04 server, to monitor a Confluence installation on the same server. When I try and run the installer, I get:
***** ( ( o)) New Relic Java Agent Installer
***** Installing version 3.22.0 ...
* Could not edit start script because:
Could not locate a Tomcat, Jetty, JBoss, JBoss7 or Glassfish instance in /srv/data-confluence
* Try re-running the install command with the -s <AppServerRootDirectory> option or from <AppServerRootDirectory>/newrelic.
If that doesn't work, locate and edit the start script manually.
* No need to create New Relic configuration file because:
A config file already exists: /srv/data-confluence/newrelic/newrelic.yml
***** Install incomplete
I tried to manually install it by following the information here: https://docs.newrelic.com/docs/agents/java-agent/installation/java-agent-manual-installation and running the command for Tomcat, still no joy - same error.
For those who run into this same issue:
Wrap up
Historical note: This is Confluence running an instance of Tomcat 8.
Luca attempted to install using the New Relic Agent self-installer. Running java -jar newrelic.jar install within the /newrelic/ folder located in the Confluence home folder (in this case/srv/atlassian-confluence/bin/) successfully added the -javaagent switch to the catalina.sh, but then output into the console
***** Installing version 3.22.0 ...
Could not edit start script because:
Could not locate a Tomcat, Jetty, JBoss, JBoss7 or Glassfish instance in /srv/data-confluence
Try re-running the install command with the -s option or from /newrelic.
If that doesn't work, locate and edit the start script manually.
No need to create New Relic configuration file because:
A config file already exists: /srv/atlassian-confluence/newrelic/newrelic.yml
***** Install incomplete
At this point, Luca moved the newrelic.jar and newrelic.yml from /srv/atlassian-confluence/bin/newrelic to the folder above, namely /srv/atlassian-confluence/bin/. The new relic agent attempted to start up with confluence after running the startup-confluence.sh startup script but was (1) unable to create a log file, and (2) caused confluence to throw an exception.
In order to remedy this situation, Luca and I needed to:
(1) Remove the multi-line switch added by new relic to catalina.sh
(2) Run through the java agent manual installation instructions but instead of putting export JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/newrelic.jar" into catalina.sh we put it into the confluence startup script startup-confluence.sh.
At this point, Luca needed to run the stop and start scripts for Confluence to get the agent reporting to the New Relic APM dashboard.
The confusion herein was that the auto-installer didn't work, so the auto-installer's changes needed to be reversed and the JAVA_OPTS environment variable set within the appropriate script.

Could not load the Tomcat server configuration

I have installed apache tomcat7 using sudo apt get in ubuntu. I have added apache tomcat 7 to eclipse using Windows > Preferences > Server > Runtime Environment.But when I'm starting the server from server view by right clicking the shown Tomcat v7.0 Server at localhost [Stopped,Republish]
It says:
Could not load the Tomcat server configuration at /Servers/Tomcat v7.0
Server at localhost-config. The configuration may be corrupt or
incomplete.
The path to tomcat7 that I've provided is /usr/share/tomcat7
I've just been encountering a very similar issue in Ubuntu while trying to get Eclipse Mars and Tomcat7 integrated because Eclipse was expecting the tomcat configuration files etc to be all in the same location, and with the necessary permissions to be able to change those files.
The following instructions from this blog article helped me in the end:
cd /usr/share/tomcat7
sudo ln -s /var/lib/tomcat7/conf conf
sudo ln -s /var/log/tomcat7 log
sudo ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
sudo chmod -R a+rwx /usr/share/tomcat7/conf
I've just solved this exact problem on my Ubuntu 14.04 with Eclipse Mars 2.
This could happen when Eclipse is not finding Tomcat's configuration files where they are expected to be. This place is in
$eclipse_workspace_folder/$version_of_your_tomcat_server_at_localhost/
(by default if you didn't changed server's name). So you have to copy all the files under your $tomcat_installation_folder/conf/* to the workspace server's folder.
But it was easier to just remove the server from your server list and add it again. Eclipse will automatically recreate all these files again into the proper folders. Like in the picture below:
In my case I've downloaded tomcat-8.0.35 from the website, so the configuration files needed are in /opt/apache-tomcat-8.0.35/conf/ filesystem.
Just delete the desired server from the Servers view (Window -> Show View -> Servers) and then go to Window -> Preferences -> Server -> Runtime Environment -> Add and add the server again.
You can install tomcat7 in ~/tomcat7 instead of /usr/share/tomcat7.
Close Eclipse.
Delete org.eclipse.wst.server.core.prefs and org.eclipse.jst.server.tomcat.core.prefs in {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings.
Launch Eclipse.
Go to Window->Show View->Other... and choose the Servers.
Select Tomcat v7.0 Server from the server type and press Next.
Enter /home/user/tomcat7 (not /usr/share/tomcat7) into the "Tomcat installation directory" and press Download.
Wait a few minutes and press Finish.
tomcat7 worked correctly with Eclipse 4.4 on my Ubuntu 15.04 in this way.
I know it's an old question and it has been solved already but for me the Tomcat conf/tomcat-users.xml file was created with a different encoding from the rest of the configuration files. The first line of that file looked like this:
<?xml version='1.0' encoding='cp65001'?>
All I had to do to solve the issue was change that line for:
<?xml version="1.0" encoding="UTF-8"?>
And voila.
I have no idea what 'cp65001' means or why it was created like that.
Maybe this will help other users facing the same issue.
The application is trying to load /usr/share/tomcat7/conf/ which doesn't exist. Eclipse assumes conf is in the same directory as bin
In Ubuntu, conf is placed in /etc/tomcat7/ and there is a symbolic link in /var/lib/tomcat7/.
To solve this, you can either
Download package from Apache Tomcat, and place them in a specific directory, say /opt/ or
Create a symbolic link in /usr/share/tomcat7/ pointing to /etc/tomcat7/conf
A quick solution in eclipse to resolve when Tomcat could not load as per the following error:
Just refresh the Tomcat folder should do the trick. If it still does not work, delete all files in eclipse under the Tomcat folder, re-copy the server files then refresh the Tomcat folder. Tomcat should restart correctly after that.
I have Windows 8.1, Eclipse Neon, Tomcat 8.
The solution is to copy all the files from folder ".../Tomcatxxx/conf" to the ".../Workspace_directory/Servers" and try to launch server again.
You tried to start Tomcat and got the following error:
Could not load the Tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config. The configuration may be corrupt or incomplete
How to solve:
Close Eclipse
Copy all files from TOMCAT_7_HOME/conf to WORKSPACE_FOLDER/Servers/Tomcat v7.0 Server at localhost-config
Start Eclipse
Expand the Servers project, click on the Tomcat 7 project and hit F5
Start Tomcat from Eclipse
I know it's been a while since this question was posted, but I was just getting this exact error, and I have a really simple solution that MIGHT work for some. All I did was double click on the folder 'Servers', which then allowed me to start the server with no error message. Sometimes the solution is right in front of your eyes. This might work for some people like me who go straight to google without trying fix the issue themselves!
on Centos 7, this will do it, for Tomcat 7 :
(my tomcat install dir: opt/apache-tomcat-7.0.79)
mkdir /var/lib/tomcat7
cd /var/lib/tomcat7
sudo ln -s /opt/apache-tomcat-7.0.79/conf conf
mkdir /var/log/tomcat7
cd /var/log/tomcat7
sudo ln -s /opt/apache-tomcat-7.0.79/logs log
not sure the log link is necessary, the configuration is the critical one.
:
Had the same issue with Kepler (after trying to add a Tomcat 7 server).
Whilst adding the server I opted to install the Tomcat binary using the download/install feature inside Eclipse. I added the server without adding any apps. After the install I tried adding an app and got the error.
I immediately deleted the Tomcat 7 server from Eclipse then repeated the same steps to add Tomcat 7 back in (obviously skipping the download/install step as the binary was downloaded first time around).
After adding Tomcat 7 a second time I tried adding / publishing an app and it worked fine. Didn't bother with any further RCA, it started working and that was good enough for me.
I had the same problem in Eclipse Oxygen with Tomcat 8 in ubuntu 16.04 LTS.
Solution:
1. Give permission to entire tomcat folder (chmod 777 -R /Tomcat)
2. Delete and re-add the server in eclipse
3. Restart eclipse
4. Start the tomcat server. It will work..........
In the Servers tab of eclipse, go to the properties of the server and Switch location to latest downloaded tomcat version.
This resolved the issue for me.
Tomcat Server Properties
I solved this problem. DON'T USE THE .exe
Unistall Tomcat and download the .zip from Tomcat's web site. Then unpack and put it in C:\Program Files. Open Eclipse and set the server. it will work.

Unable to install new relic on linux using tomcat server

I have created account on new relic and downloaded zip for new relic agent and uploaded to /etc directory in my linux machine(tomcat server).
As per documentations, I follow the following code
cd /etc/newrelic
java -jar newrelic.jar install
But I am getting following error:
Dec 31, 2013 06:14:04 +0000 NewRelic 1 INFO: Agent is using Logback
***** ( ( o)) New Relic Java Agent Installer
***** Installing version 3.2.3 ...
Could not edit start script because:
.:. Could not locate a Tomcat, Jetty, JBoss, JBoss7 or Glassfish instance in /etc
Try re-running the install command with the -s <AppServerRootDirectory> option or from <AppServerRootDirectory>/newrelic.
If that doesn't work, locate and edit the start script manually.
No need to create New Relic configuration file because:
.:. A config file already exists: /etc/newrelic/newrelic.yml
***** Install incomplete
***** Next steps:
For help completing the install, see https://newrelic.com/docs/java/new-relic-for-java
Can anyone give me solution for this?
As the log information provide that it Could not locate a Tomcat, you need to provide env var like TOMCAT_HOME and so on.
In linux, even if you have installed some software, it can not be conveniently used without adding into PATH or some other env var.
In your situation, seems you need to add TOMCAT_HOME and export it.
Make sure the tomcat is correctly installed!
I was dealing with the same error, you only need to copy the new-relic.jar file inside the root of your tomcat server and then type:
java -jar new-relic.jar install
And that's it, it worked for me. Hope it helps
I work in support at New Relic, specializing in the Java agent.
Since Tomcat installations vary between Linux environments, your best bet is to follow the manual installation instructions:
https://docs.newrelic.com/docs/java/java-agent-manual-installation
Scroll down to the Tomcat instructions, which advise you to add the -javaagent flag to your Tomcat startup script. Once you've made that change and started your Tomcat instance, you can verify that the newrelic.jar is included in the startup arguments by issuing a ps -ef | grep java command.
If you need further help, please open a support ticket at support.newrelic.com and we'll be glad to assist.
Before installing the New Relic the code will fetch the requisite environment parameters like JAVA_HOME, TOMCAT_HOME, etc ( depends on your configuration) and then install the agent on your server. Make sure all the required env variables are defined.
After you have done the above, also check the following:
a) The New Relic should be extraced/installed in your home directory ( in my case /APP)
cd /APP
Unzip newrelic-java-3.26.1.zip –d /APP
b) The Java agent should be defined in the local properties file ( I have configured it for Hybris server in Dev environment)
vim /APP/hybris/config/local.properties
Add : -javaagent:/APP/newrelic/newrelic.jar –D newrelic.environment=Development
c) In some cases, it requirs the application specific yml file along with the newrelic.yml file ( in my case hybris.yml)
Cd /APP/newrelic
mkdir extensions
chmod 755 extensions
cd /APP/newrelic/extensions
vim hybris.yml
Hybris specific configuration for the hybris.yml file ( use jmx.yml)
Add the jmx.yml data in the hybris.yml after creating the file.
d) Restart your application:
I did it using the following commands:
cd /APP/hybris/bin/platform
ant clean all
e) You should see the data in sometime. Keep monitoring the new relic logs in:
tail -f /APP/newrelic/logs/newrelic_agent.log
Before you do any of these steps, make sure that your new relic folder is in inside the folder of your server. That immediately fixed my problem.
The folder newrelic belongs to /usr/share/tomcat/. At least on Ubuntu 16.04 with Tomcat 7. Then also the install command works. Please do not forget to read and adapt the whole newrelic.yml file.

Glassfish server open source addition failed to install

i got the following error when i tried to install GlassFish Server glassfish-3.1.2.2-windows().exe
Executing command :C:\glassfish3\glassfish\bin\asadmin.bat --user admin --passwordfile - create-domain --savelogin --checkports=false --adminport 4646 --instanceport 7070 --domainproperties=jms.port=7676:domain.jmxPort=8686:orb.listener.port=3700:http.ssl.port=8181:orb.ssl.port=3820:orb.mutualauth.port=3920 domain1
C:\glassfish3\glassfish\bin\asadmin.bat --user admin --passwordfile - create-domain --savelogin --checkports=false --adminport 4646 --instanceport 7070 --domainproperties=jms.port=7676:domain.jmxPort=8686:orb.listener.port=3700:http.ssl.port=8181:orb.ssl.port=3820:orb.mutualauth.port=3920 do main1 The system cannot find the path specified.
print screen of error is following
I just ran into this same problem and it appears to be created by the batch files asadmin.bat and asenv.bat. The batch files read as follows (I've removed the REM statements and lines that didn't pertain to the problem:
asadmin.bat in c:\glassfish3\glassfish\bin
REM Always use JDK 1.6 or higher
REM Depends on Java from ..\config\asenv.bat
call "%~dp0..\config\asenv.bat"
if "%AS_JAVA%x" == "x" goto UsePath
set JAVA="%AS_JAVA%\bin\java"
goto run
:UsePath
set JAVA=java
:run
%JAVA% -jar "%~dp0..\modules\admin-cli.jar" %*
asenv.bat in c:\glassfish3\glassfish\conf
set AS_JAVA=C:\Program Files (x86)\Java
I could not figure out how to get Glassfish to just use the environment variable during install. I attempted to use the -j "(javapath)" argument, but this didn't solve the problem for me.
What worked, and I'm not proud of this solution, is to give Glassfish what it's looking for. If you put together the path its constructing above, you get C:\Program Files (x86)\Java\bin\java.exe. Since Java installs to C:\Program Files (x86)\Java\jre7\bin\java.exe, I simply copied the contents of C:\Program Files (x86)\Java\jre7\ to C:\Program Files (x86)\Java\ and Glassfish installed correctly.
If someone else has a better solution to this problem, PLEASE post it!
Full Disclosure:
Installing Glassfish 3.1.2.2 on Windows Server 2008, running on a VM.
Update: A co-worker of mine came up with a different solution that doesn't involve copying the contents of C:\Program Files(x86)\java\jre7.
During the Glassfish install, at the point where it's requesting a password for the admin account, edit the asenv.bat file and add the "jre7\" to the line I quoted above. This forces Glassfish to look in the proper folder.

Categories