how do i find where JAVA_OPTS data is stored? - java

A CentOS 7 server has Java 7 and tomcat 8 installed. I need to set the permgen space, but typing printenv on the command line does not include JAVA_OPTS in the list of environmental variables. I typed ps to get the list of running processes, and then I typed jmap -heap <pid> with the pid from the running java process, which listed values for MaxPermSize and PermSize among other values.
How do I set new values for these properties in a way that will persist when the system is rebooted, etc.? I hesitate to just create a JAVA_OPTS variable if the server in question has another place where it stores these persistent values.
EDIT:
As per #ChrisRobak's suggestion, I went searching for tomcat conf files. There is no /etc/tomcat directory, but /etc has directories called /etc/java, /etc/.java, /etc/jvm, and /etc/jvm-common. Also, the tomcat conf is as follows:
[root#myserver tomcat]# cd /opt/tomcat/conf
[root#myserver conf]# ls -al
total 280
drwxrwx---. 3 root root 4096 Oct 30 20:02 .
drwxr-xr-x. 14 root root 4096 Oct 30 20:58 ..
drwxrwx---. 7 root root 4096 Oct 30 21:00 Catalina
-rwxrwx---. 1 root root 12624 Nov 2 2014 catalina.policy
-rwxrwx---. 1 root root 6560 Nov 2 2014 catalina.properties
-rwxrwx---. 1 root root 1852 Jan 2 2015 context.xml
-rwxrwx---. 1 root root 3451 Nov 2 2014 logging.properties
-rwxr-x--- 1 root root 5018 Oct 30 21:52 server.xml
-rwxrwx---. 1 root root 1783 Nov 2 2014 tomcat-users.xml
-rwxrwx---. 1 root root 1888 Nov 2 2014 tomcat-users.xsd
-rwxrwx---. 1 root root 168082 Nov 2 2014 web.xml
[root#myserver conf]#
Which file should I look in?
Alternatively, is there a command line way of setting the Java options which will not only be persistent, but also not cause side effects due to conflicts with config files? I would just create a JAVA_OPTS variable if I thought the rest of the server would go to the JAVA_OPTS as the default.
ANSWER?
When none of the config files and scripts seemed to have JAVA_OPTS set, I finally just decided to type the following in the CENTOS 7 terminal:
export JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"
The result is that the MaxPermSize has been reset. If anyone else has a specific answer to CentOS 7 that is better than this, please alert me.

I think you can persist those in
/etc/tomcat8/tomcat8.conf
or a similar variant, the server i had access to was /etc/tomcat5/tomcat5.conf but i don't know about your version in particular

Related

Elastic Beanstalk .ebextensions ignored in WAR

I am trying to change the client_max_body_size property of my Elastic Beanstalk NGINX reverse-proxy in order to allow uploads for larger JPEG files. Therefore, I added the folder ".ebextensions" to the root directory of my WAR file (the WAR file is also including a Spring Boot application) and added a file ".ebextensions/01_files.config" with the following content:
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
I deploy the WAR file via Travis-CI to Elastic Beanstalk. However, it seems that the file is beeing ignored by Elastic Beanstalk since uploads with a filesize e.g. 2MB do not work and when connecting with SSH to the instance and looking for "/etc/nginx/conf.d/proxy.conf" the file does not exist.
I already successfully validated above content with an YAML validator. I know, there exists plenty of related questions but non of those seem to fix my problem. I also checked if ".ebextensions/01_files.config" is included in the WAR file in root directory. And when I check "/tmp/eb_extracted_jar", the file ".ebextensions/01_files.config" also exists with the correct content. I can't even find any errors in the "/var/log/cfn-init.log". I noticed that, just for some seconds, the file "proxy.conf" appeared in "/etc/nginx/conf.d/" during deployment but then it has been removed.
Can this problem occure because of the deployment to Elastic Beanstalk via Travis-CI? Or did I miss something else that is important?
EDIT:
I just recognized that the "proxy.conf" file is created every time for a few seconds when the application is deployed but after a few seconds it disappears (checked with ls -lsa in "/etc/nginx/conf.d/", see the timestamps with 13:34 for "elasticbeanstalk" directory and "healthd_http.conf" and 13:43 for "proxy.conf")
4 drwxr-xr-x 3 root root 4096 6. Dec 13:43 .
4 drwxr-xr-x 4 root root 4096 6. Dec 13:34 ..
4 drwxr-xr-x 2 root root 4096 6. Dec 13:34 elasticbeanstalk
4 -rw-r--r-- 1 root root 148 6. Dec 13:34 healthd_http.conf
4 -rwxr-xr-x 1 root root 26 6. Dec 13:43 proxy.conf
And after a few seconds ls -lsa "/etc/nginx/conf.d/":
4 drwxr-xr-x 3 root root 4096 6. Dec 13:44 .
4 drwxr-xr-x 4 root root 4096 6. Dec 13:44 ..
4 drwxr-xr-x 2 root root 4096 6. Dec 13:44 elasticbeanstalk
4 -rw-r--r-- 1 root root 148 6. Dec 13:44 healthd_http.conf
After hours of reading docs, I found out that I missed some important parts of the official AWS docs for the Elastic Beanstalk Java SE Platform (see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html).
Definitely my mistake: I used the wrong file extension, the file extension in the folder ".ebextensions" has to be ".conf" but not ".config".
At least for the Java SE Platform: one can directly add NGINX config files within the ".ebextensions" directory without using the "files: ..." syntax to generate a file with a specific content, i.e. to create the proxy file in "/etc/nginx/conf.d/proxy.conf" just add ".ebextension/nginx/conf.d/proxy.conf" with the content client_max_body_size 20M; directly. Subsequently, "proxy.conf" will then be deployed to "/etc/nginx/conf.d/proxy.conf" and automatically included by the default NGINX config.
Hope this answer saves someone else the time it took me to figure that out.

Can't startup Tomcat

I'm just trying to setup a tomcat server. I got the following setting:
Tomcat 9 installation inside: /opt/apache-tomcat-9.0.0.M1
WebAppliction located at: /srv/appsiting-dev/
Structure of the WebApplication:
drwxrwsr-x 2 root appsiting 4096 Jan 15 20:08 bin
drwxrws--- 2 root appsiting 4096 Jan 16 18:52 doc
drwxrwsr-x 2 root www-data 4096 Jan 16 19:48 etc
drwxr-xr-x 2 root root 4096 Jan 15 19:56 log
drwxrwsr-x 2 root appsiting 4096 Jan 15 19:56 php-lib
drwxrwsr-x 2 root appsiting 4096 Jan 16 02:38 public_html
drwxrwxrwt 2 root root 4096 Jan 15 19:57 tmp
drwxrwsr-x 7 root root 4096 Jan 16 00:45 tomcat
drwxrwsr-x 3 root appsiting 4096 Jan 15 21:30 var
drwxrwsr-x 2 root appsiting 4096 Jan 15 19:57 zend-app
Inside the tomcat directory there is the following:
drwxrwsr-x 3 appsiting appsiting 4096 Jan 16 20:25 conf
drwxrws--- 2 appsiting appsiting 4096 Jan 16 20:07 logs
drwxrwsr-x 2 appsiting appsiting 4096 Jan 16 20:20 temp
-rwxr-xr-x 1 root root 3015 Jan 16 00:45 tomcat
drwxrwsr-x 7 appsiting appsiting 4096 Jan 15 23:32 webapps
drwxrwsr-x 2 appsiting appsiting 4096 Jan 15 23:32 work
tomcatis a start-up script. I got the following inside of my tomcat.conf, which is located inside of conf
USERNAME="appsiting"
PORTBASE="40000"
JAVA_OPTS="$JAVA_OPTS -Xmx1024m -XX:MaxPermSize=256m"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=$(($PORTBASE+2))"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"
#JAVA_OPTS="$JAVA_OPTS -XX:+CMSPermGenSweepingEnabled"
#JAVA_OPTS="$JAVA_OPTS -verbose:gc -XX:+PrintClassHistogram"
JAVA_OPTS="$JAVA_OPTS -server"
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
export JAVA_OPTS
export JAVA_HOME="/usr"
export CATALINA_HOME="/opt/apache-tomcat-9.0.0.M1"
export CATALINA_BASE="/srv/appsiting-dev/tomcat"
So when I startup my server I get a tomcat.err and a catalina.out. And even though the tomcat.errtells me the Tomcat has started, catalina.out doesn't have a "Server starup in xx ms" inside of it.
tomcat.err
Using CATALINA_BASE: /srv/appsiting-dev/tomcat
Using CATALINA_HOME: /opt/apache-tomcat-9.0.0.M1
Using CATALINA_TMPDIR: /srv/appsiting-dev/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat- 9.0.0.M1/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M1/bin/tomcat-juli.jar
Using CATALINA_PID: /srv/appsiting-dev/tomcat/temp/tomcat.pid
Tomcat started.
catalina.out is empty. Here is the start up script as well:
https://www.refheap.com/113725
When running it I'm getting a
sudo ./tomcat start
Starting Tomcat (appsiting-dev) ............................... failed.
Does anyone know what the issue is here?
Thanks in advance
local host port is already using in other service or process.find and kill(stop) it.

Why is Tomcat throwing FileNotFoundExceptions for existing JAR files?

I'd like to know what could cause Tomcat or the native Java ZipFile.open
method to claim that a file does not exist when it actually does? This
has been a blocking issue for some of my work for the past month. It's
happening when attempting to run the tomcat7-maven-plugin. It works fine
on most machines, including mine (OSX), but fails on our build server
(LINUX) and one of my co-workers' boxes (OSX, same model laptop as mine).
Here's the error as seen in a Maven build:
[INFO] --- tomcat7-maven-plugin:2.2:run (start-tomcat) # PROJECT ---
[INFO] Running war on http://localhost:8080/contentmain
[INFO] Using existing Tomcat server configuration at
/WORKSPACE/PROJECT/tomcat7
Feb 05, 2015 11:17:53 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal
performance in production environments was not found on the
java.library.path:
/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Feb 05, 2015 11:17:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Feb 05, 2015 11:17:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Feb 05, 2015 11:17:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8443"]
Feb 05, 2015 11:17:54 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 651 ms
Feb 05, 2015 11:17:54 PM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service Catalina
Feb 05, 2015 11:17:54 PM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
Feb 05, 2015 11:17:54 PM org.apache.tomcat.util.scan.StandardJarScanner
scan
WARNING: Failed to scan JAR
[file:/WORKSPACE/tomcat7/webapps/../../target/PROJECT/WEB-INF/lib/openws-1.
5.1.jar] from WEB-INF/lib
java.io.FileNotFoundException:
/WORKSPACE/PROJECT/tomcat7/webapps/../../target/PROJECT/WEB-INF/lib/openws-
1.5.1.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.jar.JarFile.<init>(JarFile.java:154)
at java.util.jar.JarFile.<init>(JarFile.java:91)
at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:99)
at
sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122
)
at
sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:
89)
at org.apache.tomcat.util.scan.FileUrlJar.<init>(FileUrlJar.java:41)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:34)
at
org.apache.catalina.startup.ContextConfig$FragmentJarScannerCallback.scan(C
ontextConfig.java:2612)
at
org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.j
ava:259)
at
org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java
:178)
at
org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(Contex
tConfig.java:1868)
at
org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1256
)
at
org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java
:873)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java
:371)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppo
rt.java:117)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.jav
a:90)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java
:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1
559)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1
549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1
145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:
615)
at java.lang.Thread.run(Thread.java:745)
This error repeats for every JAR file in the project which was pulled in
from Maven dependencies. There are hundreds of these.
Note that I've placed a breakpoint at the ZipFile.open call on one of the
failing machines and performed the following in a separate terminal:
cd /WORKSPACE/PROJECT/tomcat7/webapps/../../target/PROJECT/WEB-INF/lib/
ls -la
I can confirm that all of the "missing" JAR files were there immediately
before the native open method is called and the exceptions are thrown
which claim that the files aren't there. This led me to suspect that the
JAR files may be corrupted, so I copied one of the failing JAR files from
my co-workers' machine and performed a diff with a local copy I had
following a successful build and execution. They were identical, so it
appears that the "corrupt JAR" theory is out.
I've also tried the following (without success):
Shortening the path used (I read somewhere that there might be a 256
character limit).
Moving the JAR files to a different directory and changing the Tomcat
configuration to point to the new location (they were under resources and
I moved them to the project base.dir).
Setting various JVM heap sizes from Xmx256 to Xmx4096 (I read in a few
posts that memory issues can cause Tomcat to claim that files are missing).
Removing the permgen settings that we normally use for our webapp.
Setting the "jarScanAllDirectories" option to either false or true for
the tomcat7-maven-plugin.
Downloading the sources for the tomcat-maven-plugin (this includes the
tomcat7-maven-plugin) from Apache SVN, attaching them with a remote
debugger to Maven and stepping through the execution (everything seems
identical right up until the native ZipFile.open call).
Playing around with various Jenkins job settings for Maven on the build
server (probably irrelevant since this also fails on a coworker's machine
without Jenkins being involved).
Comparing all of the environment variables used by our webapp to those
used by my coworker (they're identical).
Comparing JDK versions (our entire org is standardized on 1.7.0_45).
Comparing Tomcat versions (we have explicit pom.xml file dependencies for
the tomcat7-maven-plugin on version 7.0.53).
Waiting and hoping that the problem solves itself.
Asking all of my co-workers to take a look (this led to trying some of
the above, but the problem still has not been solved).
I'm at my wit's end here. I've been up past midnight for several days
just trying to get this thing to work. What's left to look at?
UPDATE (2/10/2015): It's been suggested that this is caused by missing file permissions on the Jenkins machine where this is running. I don't have access to the server where this is happening, but I did get a script to run there:
echo Displaying JAR files with current permissions...
ls -la ./target/MyProject/WEB-INF/lib/
echo Adding read, write, and execute permissions to JAR files...
chmod -R 777 ./target/MyProject/WEB-INF/lib/
echo Displaying JAR files with updated permissions...
ls -la ./target/MyProject/WEB-INF/lib/
This produces output like the following:
[INFO] --- exec-maven-plugin:1.3.2:exec (update_jar_file_permissions) #
MyProject ---
Displaying JAR files with current permissions...
total 124556
drwxr-xr-x 2 jenkins users 20480 Feb 10 17:26 .
drwxr-xr-x 6 jenkins users 4096 Feb 10 17:26 ..
-rw-r--r-- 1 jenkins users 62983 Jan 22 00:11 activation-1.1.jar
-rw-r--r-- 1 jenkins users 351656 Jan 22 00:25 amqp-client-3.1.3.jar
-rw-r--r-- 1 jenkins users 74080 Jan 22 00:25 annotations-2.0.0.jar
-rw-r--r-- 1 jenkins users 445288 Jan 22 00:25 antlr-2.7.7.jar
-rw-r--r-- 1 jenkins users 895124 Jan 22 00:25 antlr-3.2.jar
Adding read, write, and execute permissions to JAR files...
Displaying JAR files with updated permissions...
total 124556
drwxrwxrwx 2 jenkins users 20480 Feb 10 17:26 .
drwxr-xr-x 6 jenkins users 4096 Feb 10 17:26 ..
-rwxrwxrwx 1 jenkins users 62983 Jan 22 00:11 activation-1.1.jar
-rwxrwxrwx 1 jenkins users 351656 Jan 22 00:25 amqp-client-3.1.3.jar
-rwxrwxrwx 1 jenkins users 74080 Jan 22 00:25 annotations-2.0.0.jar
-rwxrwxrwx 1 jenkins users 445288 Jan 22 00:25 antlr-2.7.7.jar
-rwxrwxrwx 1 jenkins users 895124 Jan 22 00:25 antlr-3.2.jar
As you can see, there were missing permissions. However, this hasn't
solved the problem:
Feb 10, 2015 5:27:54 PM org.apache.tomcat.util.scan.StandardJarScanner scan
WARNING: Failed to scan JAR [file:/opt/jenkins/workspace/MY_JENKINS_JOB/tomcat7/webapps/../../target/MY_PROJECT/WEB-INF/lib/activation-1.1.jar] from WEB-INF/lib
java.io.FileNotFoundException: /opt/jenkins/workspace/MY_JENKINS_JOB/tomcat7/webapps/../../target/MY_PROJECT/WEB-INF/lib/activation-1.1.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
The script was run right before tomcat7-maven-plugin. The permissions should have been in place and the JAR files should have been extractable. I still don't understand why this isn't working.
It turns out this wasn't a permissions issue at all. For some reason copying the JAR files out of the directory and back into it caused them to be picked up (I read this in a suggestion somewhere). Reading the 'man' entry for cp I see that it doesn't preserve "Access Control Lists (ACLs) and Extended Attributes (EAs), including resource forks" unless the -p flag is set (this is on by default when using mv). My guess is that removing this "access control" information somehow made the files accessible to the tomcat7-maven-plugin. It seems a little sketchy that I don't really know the root cause of the problem, but I'm happy that it's now fixed.
If somebody can definitively explain why this worked then I'll accept that as an answer instead of this one.

JConsole location in Linux

I am trying to run jconsole from my machine but I can't find the location of the .sh . I have tried finding it in different directories and setting JAVA_HOME to the jdk.
$which java
/usr/bin/java
$java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (rhel-2.4.4.1.el6_5-x86_64 u51-b02)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
$whereis java
java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /usr/share/man/man1/java.1.gz
I looked in /usr/lib/jvm and I found
drwxr-xr-x. 3 root root 4096 Apr 23 2013 java-1.5.0-gcj-1.5.0.0
drwxr-xr-x. 3 root root 4096 Jan 27 2014 java-1.6.0-openjdk-1.6.0.0.x86_64
drwxr-xr-x. 3 root root 4096 Feb 5 2014 java-1.7.0-openjdk-1.7.0.51.x86_64
lrwxrwxrwx. 1 root root 21 Feb 5 2014 jre -> /etc/alternatives/jre
lrwxrwxrwx. 1 root root 27 Apr 23 2013 jre-1.5.0 -> /etc/alternatives/jre_1.5.0
lrwxrwxrwx. 1 root root 26 Apr 23 2013 jre-1.5.0-gcj -> java-1.5.0-gcj-1.5.0.0/jre
lrwxrwxrwx. 1 root root 27 Feb 5 2014 jre-1.6.0 -> /etc/alternatives/jre_1.6.0
lrwxrwxrwx. 1 root root 37 Feb 5 2014 jre-1.6.0-openjdk.x86_64 -> java-1.6.0-openjdk- 1.6.0.0.x86_64/jre
lrwxrwxrwx. 1 root root 27 Feb 5 2014 jre-1.7.0 -> /etc/alternatives/jre_1.7.0
lrwxrwxrwx. 1 root root 38 Feb 5 2014 jre-1.7.0-openjdk.x86_64 -> java-1.7.0-openjdk-1.7.0.51.x86_64/jre
lrwxrwxrwx. 1 root root 25 Apr 23 2013 jre-gcj -> /etc/alternatives/jre_gcj
lrwxrwxrwx. 1 root root 29 Feb 5 2014 jre-openjdk -> /etc/alternatives/jre_openjdk
and in java-1.7.0-openjdk-1.7.0.51.x86_64/jre/bin/, I only found
[root#portal01 bin]# ll
total 200
-rwxr-xr-x. 1 root root 9536 Jan 14 2014 java
-rwxr-xr-x. 1 root root 9656 Jan 14 2014 keytool
-rwxr-xr-x. 1 root root 9856 Jan 14 2014 orbd
-rwxr-xr-x. 1 root root 9688 Jan 14 2014 pack200
-rwxr-xr-x. 1 root root 10984 Jan 14 2014 policytool
-rwxr-xr-x. 1 root root 9648 Jan 14 2014 rmid
-rwxr-xr-x. 1 root root 9656 Jan 14 2014 rmiregistry
-rwxr-xr-x. 1 root root 9688 Jan 14 2014 servertool
-rwxr-xr-x. 1 root root 9896 Jan 14 2014 tnameserv
-rwxr-xr-x. 1 root root 92264 Jan 14 2014 unpack200
..even though there are 200 files. How can I find and run jconsole?
jconsole is part of the Java SDK, it appears you only have the JRE installed.
You can run jconsole directly from your terminal by running the command jconsole.
reena#IM-1500:~$ jconsole
It will launch java monitoring console dialog.
From https://serverfault.com/questions/179908/fedora-jconsole-location:
Try running: yum provides */jconsole
that will tell you what package you need as well as where it's located in the package.
Once you set the path of JDK in Linux then this command execute easily might be you had not included the JAVA_HOME with PATH variable.
plz follow this discussion
If you have Java JDK installed in your Linux machine, usually jconsole is located at /usr/bin/ as a symbolic link.
Example from my Linux VM running Centos6
$ which jconsole
/usr/bin/jconsole
$ ls -l /usr/bin/jconsole
lrwxrwxrwx. 1 root root 26 Sep 4 10:05 /usr/bin/jconsole -> /etc/alternatives/jconsole
$ ls -l /etc/alternatives/jconsole
lrwxrwxrwx. 1 root root 51 Sep 4 10:05 /etc/alternatives/jconsole -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/jconsole
But you mentioned you got the a command not found error when you typed jconsole at the prompt. Can you find if jconsole is available in one of the jdk's bin directory?
$ ls -l /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin | grep jconsole
If yes, then add this in your PATH environment variable like so
$ export PATH=$PATH:/usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin
or put this in your ~/.bashrc if you are using Bash.
If jconsole is not there, then maybe you need to try another jdk which you have installed or re-install the jdk.
Please install JDK Development Package to get Jconsole

Play! not shutting down H2 correctly

I'm using Play to write a webapp which is deployed in Tomcat. Because the app won't be processing very much data I'm using the default H2 database with Hibernate. When I want to deploy a new version of the app, I shut down tomcat, wipe the old webapp and WAR, add my new WAR, and start back up.
This worked until a few days ago, when I added the database component. Now, I am often unable to redeploy the app. When I delete the old directory, it is automatically regenerated with this structure:
$ ls -laR myapp/
myapp/:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20 .
drwxr-xr-x 13 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 3 root root 4096 Aug 24 17:20 WEB-INF
myapp/WEB-INF:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20 .
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 3 root root 4096 Aug 24 17:20 application
myapp/WEB-INF/application:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20 .
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 3 root root 4096 Aug 24 17:20 db
myapp/WEB-INF/application/db:
total 24
drwxr-xr-x 3 root root 4096 Aug 24 17:20 .
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
drwxr-xr-x 2 root root 4096 Aug 24 17:20 h2
myapp/WEB-INF/application/db/h2:
total 24
drwxr-xr-x 2 root root 4096 Aug 24 17:20 .
drwxr-xr-x 3 root root 4096 Aug 24 17:20 ..
-rw-r--r-- 1 root root 100 Aug 24 17:20 play.lock.db
The same happens when the WAR unzips.
I recently noticed a message whiz by in the catalina.out log complaining about my app not shutting down a process called something like "H2 File Lock Watchdog". Based on a brief search of the H2 docs, I think that process is what's interfering with my app.
EDIT
Here's the complaining line in the log file:
SEVERE: The web application [/myapp] appears to have started a thread named [H2 File Lock Watchdog /var/lib/apache-tomcat-6.0.32/webapps/myapp/WEB-INF/application/db/h2/play.lock.db] but has failed to stop it. This is very likely to create a memory leak.
So, how do I kill this process? I can't restart the machine because it's not mine, and I can't find the watchdog with top or ps. I'd prefer a way for Play to shut it down automagically, but I'm not above building it into my deployment script.
Thanks a million if you've read this far!
I shut down tomcat
Are you sure you have shut down tomcat completely? Because the H2 database is sill running. If you shut down the tomcat process, the database is also stopped (because H2 is running within the tomcat process). Except if you run the database in a different process.
Or did you just shut down the web application within tomcat? If that is the case, then at least one database connection was not closed, so that the database keeps running (and creates this .lock.db file).
Now, I don't know the play framework, and can't say how to ensure all database connections are closed.
One way to force the database to close is to run the SQL statement SHUTDOWN.
I can't find the watchdog with top or ps
top and ps only display processes. The H2 watchdog is a thread within a java process. To see the thread, use:
jps -l (to get the list of Java processes)
jstack -l <pid> (to get a full thread dump)

Categories