I am running Jetty during some integration tests in daemon mode and am getting an out-of-memory error. So I'd like to set the heap size to something substantial. This question is a bit like this one except I am running in daemon mode.
try to put this in your ~/.bashrc:
export MAVEN_OPTS="-Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"
Related
In our web application deployed on tomcat, catalina.out file keeps growing (it grows in GB's).
So to disable it I found solution where I set CATALINA_OUT=/dev/null.
This worked as expected but we also use kill -3 <PID> command to capture Thread Dump whenever it requires.
This thread dump gets written into catalina.out file but now I have disabled catalina.out so I cannot see thread dump.
How can I get thread dump?
Since it is a production system therefore we are using JRE and not JDK otherwise we would have used jmap/jcmd/jstack commands to capture thread dump.
So, I would like, tomcat should stop creating catalina.out file or do not write log4j statements in it. And if it is disabled then how to get thread dump?
Finally I found the solution which I was looking for. I added below lines of statement in tomcat/bin/startup.sh file
export CATALINA_OUT=/dev/null
export JAVA_OPTS="$JAVA_OPTS -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=thread_dump.log"
CATALINA_OUT set to /dev/null will stop writing log statements in catalina.out log.
JAVA_OPTS -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=thread_dump.log configurations is used to write thread dump statements generated using kill –3 <PID> command. It will also print JVM-related configuration being used.
I hope this will help someone.
I'm receiving AttachNotSupportedException when trying to start a JFR recording.
It was working normally, until now.
jcmd 3658 JFR.start maxsize=100M filename=jfr_1.jfr dumponexit=true settings=profile
Output:
3658:
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
What might be happening?
SO: Oracle Linux Server release 6.7
$ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
One of the probable reasons is that /tmp/.java_pid1234 file has been deleted (where 1234 is PID of a Java process).
Tools that depend on Dynamic Attach Mechanism (jstack, jmap, jcmd, jinfo) communicate to JVM through a UNIX domain socket created at /tmp.
This socket is created by JVM lazily on the first attach attempt or eagerly at JVM initialization if -XX:+StartAttachListener flag is specified.
Once the file corresponding to the socket is deleted, tools cannot connect to the target process, and unfortunately there is no way to re-create communication socket without restarting JVM.
For the description of Dynamic Attach Mechanism see this answer.
With personal experience... This problem also occurs in scenarios where the development environment is divided into partitions, and the partition where the operating system is located is different from the operating system partition. Example, operating system partition is EXT4 and the development environment partition is NTFS (where the JVM is). Problem occurs because you can not create a file "/tmp/.java_pid6024" (where 6024 is the PID of the java process).
To troubleshoot add -XX: + StartAttachListener at the start of the JVM, or application server.
Another possibility: your app is running under systemd with 'PrivateTmp=yes'. This prevents the /tmp/.java_pid1234 file from being found.
So I'm running an integration test/spec using configuration for an ActiveMQ in-memory broker.
SomeSpec.groovy:
#SpringApplicationConfiguration(SomeApplication.class)
#WebIntegrationTest(randomPort = true)
class SomeSpec extends Specification {
application.properties
spring.activemq.in-memory=true
spring.activemq.pooled=false
The in memory broker starts up and runs fine when I do gradle test and
also runs fine when used with gradle bootRun at the command line. However when I run inside IntelliJ without explicitly having it run gradle test the in memory broker does not start and the tests fail.
How can I take and advantage of the nice test/spec running features in IntelliJ but still have it initialize the in memory queue properly? I know with Grails you could run with JUnit or Grails. Is there something similar with Spring/SpringBoot so everything starts up properly.
It's probably because your config files are not refreshed under project/out/production/config/ location.
When you run it from cmd line, it takes the latest application.properties, so every thing is fine.
But Idea takes the already compiled config files, and if they are not rebuilt inside Idea then it still loads the load configuration.
I am trying to run Apache Tomcat 8.0.21 in debug mode.
When I give the command
sh catalina.sh jpda start
it gives this error.
error message
ERROR: Cannot load this JVM TI agent twice, check your java command
line for duplicate jdwp options. Error occurred during initialization
of VM agent library failed to init: jdwp
Can anyone help ?
Either
unset CATALINA_OPTS
unset JPDA_ADDRESS
unset JPDA_OPTS
unset JPDA_TRANSPORT
catalina.sh jpda start
Or
# in .bashrc, .profile etc.
export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 -Djava.security.egd=file:/dev/urandom -Denv=dev -Xms1024M -Xmx2048M -XX:PermSize=256M -XX:MaxPermSize=768m"
# At your shell prompt
./startup.sh
Explanation
As Arnab said in the comments, if your shell configuration includes environment variables mentioning jdpw (such as CATALINA_OPTS, JDPA_ADDRESS, JPDA_OPTS), just launch using ./startup.sh as if you were not trying to do remote debugging and the script will pick up the jdpw option from your environment variables.
The launch option syntax catalina.sh jpda start should only be used if you don't have any environment variables that already specified a remote debug port. It's meant to be convenient but if you've previously configured your shell to support java remote debugging you're probably mixing the two alternative approaches.
You can just add env variable and run the tomcat as usual
Debug port is 8000 in this case
export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
Then run the tomcat
sh ./catalina.sh start
This happened to me with Eclipse when I tried to add the debugging parameters (-Xdebug -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y) so I could suspend Tomcat on start. Unfortunately I then launched my Tomcat (within Eclipse) using the Debug button.
Why this is a problem
When you are launching Tomcat in Debug mode Eclipse itself inserts the debug parameters. When you have your own debug parameters in the launch configuration you are indeed passing them twice.
So if you need to launch Tomcat from within Eclipse and suspend it on start (so you can connect with debugger) you need to:
- add the debugging parameters to the "Arguments -> VM arguments" box of your launch config,
- and then Run this config, not Debug.
This way only the debugging parameters from your launch config are added.
There is alternative approach, recommended in 'catalina.sh':
"Do not set the variables in this script. Instead put them into a script
setenv.sh in CATALINA_BASE/bin to keep your customizations separate."
For Windows, the file name with environment variables will be 'setenv.bat'.
Thank you mr Dimitar II
Verified this works perfectly and is consumed automatically when running startup.bat
file: setenv.bat
#echo off
rem The proper way to set environment up for running Catalina
set "CATALINA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
I'm trying to start jconsole to monitor Weblogic beans.
I'm following this website, but changed the command to Windows format.
https://blogs.oracle.com/WebLogicServer/entry/managing_weblogic_servers_with
Command:
jconsole
-J-Djava.class.path=%JAVA_HOME%/lib/jconsole.jar;%JAVA_HOME%/lib/tools.jar;%WL_HOME%/server/lib/wljmxclient.jar
-J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote
-J-Dcom.sun.tools.jconsole.mbeans.keyPropertyList=type,Type,j2eeType,name,Name -debug
Values of the environment variables:
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_51
WL_HOME=C:\Oracle\Middleware\wlserver_10.3
When I run that command, jconsole never starts. When I run just "jconsole", the jconsole window pops up.
I saw this question of someone who also had trouble running jconsole, but my path looks right:
Where check log why VM doesn't running for jconsole with custom jar?
I also tried running just jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar , but it still did not start.
You simply need quotes around your classpath, likely because of the space in Program Files. For instance this works for me:
"C:\Program Files\Java\jdk1.6.0_37\bin\jconsole" -J-Djava.class.path="%JAVA_HOME%/lib/jconsole.jar"