Add JBoss 7 server in domain mode to Eclipse - java

I can add JBoss 7 to eclipse in standalone mode but when i try to add a JBoss 7 server in domain mode the path to the config file is always resolved by Eclipse relative to standalone folder. So if I put in full path to domain.xml it doesn;t like it and if i just put in the file name it tires to resolve it standalone.
Any ideas?
Thanks
w

Not Supported Currently.
Sources: JBoss Community Post & JBoss Issue JBIDE-12161

Not formally supported indeed... but there's a way to start and stop it from Eclipse so that you can enjoy all server logs in the Eclipse console and the start/stop icons. However, You won't be able to benefit from "run as -> run on server" because Eclipse won't identify which server you target among the process server, host controller, and main server instances. Yet, there's a remedy to that too because EAP7 supports a "unmanaged deployment mode" on exploded archives that can target your Eclipse/Maven build directories, allowing you to "refresh" deployed archives with enable/disable commands from JBoss-cli or the JBoss admin console (JBoss won't detect .class changes and trigger class loader reloads... you have to enforce it). Cherry on the cake, if you happen to work with GWT web front end technologies, you can enjoy hot redeployment of your GWT artifacts via the CodeServer in SuperDevMode within a Domain mode server instance...
Here is how to proceed:
I assume you have the JBoss Tools plug in installed in Eclipse
Create a "new server" into the 'Servers' view alike for standalone mode, and create a JBoss that takes the domain as server base dir and domain.xml as configuration file. Fill the rest and save it. As such, this server won't start properly.
select the just created server and right-click 'open'. In the Overview panel that fills the main Eclipse Window, click on the underlined "open launch configuration" link
You need to adjust the launch configuration to match the actual launch made by the domain.bat / domain.sh. So you'll need to update the long Program and VM arguments as explained below. Please, edit all paths strings illustrated below to match that of YOUR environment, e.g. "/jBOSS/EAP70/domain" may become "/projects/jb/as7/domain" in your context... and so forth
DO NOT forget to check OUT the option 'Always update arguments related to the runtime'
Program arguments:
-mp "C:/jBOSS/EAP70/modules" org.jboss.as.process-controller -jboss-home "C:\jBOSS\EAP70" -jvm "C:\java\JDK8U66\jre\bin\java" -mp "C:/jBOSS/EAP70/modules" -- "-Dorg.jboss.boot.log.file=C:/jBOSS/EAP70/domain/log/boot.log" "-Dlogging.configuration=file:/C:/jBOSS/EAP70/domain/configuration/logging.properties" -Xms64M -Xmx512M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -server -- -default-jvm "C:\java\JDK8U66\jre\bin\java"
VM arguments:
-Xms64M -Xmx512M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -server "-Dorg.jboss.boot.log.file=C:/jBOSS/EAP70/domain/log/boot.log" "-Dlogging.configuration=file:/C:/jBOSS/EAP70/domain/configuration/logging.properties" -cp "C:\jBOSS\EAP70\jboss-modules.jar" -Djboss.home.dir=C:/jBOSS/EAP70 -Djboss.bind.address.management=localhost
Working Directory: C:/jBOSS/EAP70/bin (of course you adapt values to equivalent paths in your context)
Main class: org.jboss.modules.Main
Classpath: (bootstrap) JRE system Library + (user entries) jboss-modules.jar
And you have done. Note that for stopping the server, the Servers' view red stop button will not work and you must instead use the similar-looking red button in the Console view (that kills the live java process launched in the console, here the JBoss process controller that in turn stops everything).
If you are curious to understand where the trick is...(continue reading)
In the long java command line, there is a separation around the main java class to launch, where "VM arguments" stand on the right of it, and "program arguments" on the left of it. You may capture the actual complete java command line that launches your server in domain mode with a tool like Microsoft sysinternals' process-explorer on Windows, or the "ps -eaf" or "pargs" shell command in LINUX/UNIX, after you have started jBOSS with domain.bat or domain.sh.
But you will observe here that the java command takes a "-jar module.jar" argument whereas Eclipse launch requires a conventional "-cp module.jar main-class" argument form. the '-jar' argument is indeed a variant spec where the main class is specified by the manifest file inside the jar.
In my case, the (very long) command line I captured from a classical domain.sh or domain.bat launch was:
C:\jBOSS\EAP70\bin>"C:\Program Files\Java\jre1.8.0_66\bin\java" -Xms64M -Xmx512M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -server "-Dorg.jboss.boot.log.file=C:\jBOSS\EAP70\domain\log\process-controller.log" "-Dlogging.configuration=file:C:\jBOSS\EAP70\domain\configuration/logging.properties" -jar "C:\jBOSS\EAP70\jboss-modules.jar" -mp "C:\jBOSS\EAP70\modules" org.jboss.as.process-controller -jboss-home "C:\jBOSS\EAP70" -jvm "C:\Program Files\Java\jre1.8.0_66\bin\java" -mp "C:\jBOSS\EAP70\modules" -- "-Dorg.jboss.boot.log.file=C:\jBOSS\EAP70\domain\log\host-controller.log" "-Dlogging.configuration=file:C:\jBOSS\EAP70\domain\configuration/logging.properties" -Xms64M -Xmx512M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -server -- -default-jvm "C:\Program Files\Java\jre1.8.0_66\bin\java"
which breaks as follows:
JAVA_COMMAND>> "C:\Program Files\Java\jre1.8.0_66\bin\java"
followed by
VM_ARGS_____>> -Xms64M -Xmx512M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -server "-Dorg.jboss.boot.log.file=C:\jBOSS\EAP70\domain\log\process-controller.log" "-Dlogging.configuration=file:C:\jBOSS\EAP70\domain\configuration/logging.properties"
followed by:
MAIN_CLASS__>> -jar "C:\jBOSS\EAP70\jboss-modules.jar"
whose equivalent is rewritten (peeking into the manifest of jboss-modules.jar):
MAIN_CLASS__>> -cp "C:\jBOSS\EAP70\jboss-modules.jar" org.jboss.modules.Main
followed by final chunk:
PROGRAM-ARGS>> -mp "C:\jBOSS\EAP70\modules" org.jboss.as.process-controller -jboss-home "C:\jBOSS\EAP70" -jvm "C:\Program Files\Java\jre1.8.0_66\bin\java" -mp "C:\jBOSS\EAP70\modules" -- "-Dorg.jboss.boot.log.file=C:\jBOSS\EAP70\domain\log\host-controller.log" "-Dlogging.configuration=file:C:\jBOSS\EAP70\domain\configuration/logging.properties" -Xms64M -Xmx512M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -server -- -default-jvm "C:\Program Files\Java\jre1.8.0_66\bin\java"
From the point you understand this quite surprising program argument section that replicates many of the VM aguments (because the launched process controller has to invoke the server JVM with these args...), you can then map the pieces in Eclipse server launch configuration.

Related

Execute KILL command from JAVA_OPTS using -XX:OnOutOfMemoryError

I am trying to execute kill command on OnOutOfMemoryError for a SpringBoot application.
Below is the .conf file having command.
JAVA_OPTS="-Xmx512M -XX:OnOutOfMemoryError=\"kill $(lsof -t -i:8080)\""
If I run Spring boot application as "java -jar" with Java Hostspot VM commands it works fine, but while running as Linux systemd service, application is not getting killed.
Exception : "Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space"
In my scenario, I run an instance of GeoServer using tomcat with a container in the docker swarm.
I expect swarm to recreate the container after any problem with this instance, but after an OutOfMemory error, the container will never be restarted because the JVM is still running, although the application no longer responds.
For this case, I use OnOutOfMemoryError and the container is eliminated after this type of error, so that the swarm can recreate it.
Tomcat environment to set the JVM parameters.
CATALINA_OPTS="-XX:OnOutOfMemoryError=\"kill -9 %p\"
-Djava.awt.headless=true \
-Dfile.encoding=UTF-8 -server \
-Xms1024m -Xmx3072m -Xss1024k -XX:NewSize=768m \
-XX:+UseParallelGC -XX:MaxGCPauseMillis=500"
You can try to adapt it to your use.
Importantly, i use these software:
Tomcat 9
OpenJDK-11
GeoServer 2.16.x
Debian GNU/Linux 10 (buster)
Docs for consult JVM openJDK-11 configuration options: https://manpages.debian.org/testing/openjdk-11-jre-headless/java.1.en.html

PlayFramework memory setting options are not respected

I have a Play Framework application that I want to run on production mode but whenever I run activator start -mem 512 or activator start -J-Xms512m -J-Xmx512m I get errors about JVM not being able to allocate enough memory. The odd thing is that error logs indicate that arguments passed on to jvm was:
-Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -Duser.dir=/home/oguz/dev/rhymo-server/target/universal/s$
but when I print the command information from the activator bash script I get:
java -Dactivator.home=/home/oguz/frameworks/activator-1.2.12 -Xms512m -Xmx512m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=256m -jar /home/oguz/frameworks/activator-1.2.12/activator-launch-1.2.12.jar start
It seems that play is running the right command but somewhere along the lines the arguments get discarded. What is wrong here? Am I forgetting something?
I think that you are facing a bug in Activator. You can work around it using JAVA_OPTS:
$ JAVA_OPTS="-Xms512m -Xmx512m -XX:MetaspaceSize=64m" ./activator start
or add an alias to this to your .bashrc/.zshrc. Also you can run activator stage and then start your app using
$ target/universal/stage/bin/YOUR-APP-NAME -mem 512

Tomcat says OutOfMemoryError every time when I visit JasperServer application deployed to wepapps

I installed the jasperserver(version: 5.6) in Windows 7 through the official document, use an exsiting Tomcat(version: 7) and an existing PostgreSQL(version: 9.2.8), I checked the installation.log file in JasperServer's installation path, and everything is OK.
But when I starting the Tomcat by double click 'Tomcat.exe' and it always says the following error:
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "RMI TCP Connection(idle)"
I searched for these problem and some says to configure the JVM options in %CATALINA_HOME%\bin\setenv.bat or %CATALINA_HOME\bin\%catalina.bat, but I can't find any one of them. I think this is because I'm using an exsiting Tomcat and the installation of JasperServer modified some files in %CATALINA_HOME%. So I searched 'setenv.bat' from %JasperServer% and find it in %JasperServer%\scripts. Here is my configuration:
set JAVA_OPTS=%JAVA_OPTS% -Xms2048m -Xmx3072m -XX:PermSize=1024m -XX:MaxPermSize=2048m -Xss2m -XX:+UseCompressedOoops -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
Also, I did followed the official document here, and nothing helps, Error exists.
Is there anyone who met the same problem? What should I do? I really need help. Thanks.
It seems like the memory parameters you have specified have not been picked up? Check it out, for example by looking at the process table similar to following example:
ivos-mbp:demo ivomagi$ jps
1562 start.jar
1572 Jps
my-mbp:demo me$ ps axu 1562
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
me 1562 0.2 2.8 2965576 230784 s001 S 12:17PM 0:22.62 /usr/bin/java -Dcom.sun.management.jmxremote -Xmx168m
In case you do not see the specified -Xmx3072m in the printout, you need to doublecheck where from the configuration is loaded.
Please, set CATALINA_OPTS instead of JAVA_OPS. Tomcat refers to CATALINA_OPTS on the start:
set "CATALINA_OPTS= -Xms2048m -Xmx3072m -XX:PermSize=1024m -XX:MaxPermSize=2048m -Xss2m -XX:+UseCompressedOoops -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"

Remote debugging in eclipse issue

echo "LSE Parser v1.0"
javac -d ../build -classpath ../build:${MY_CLASSPATH} *.java
cd ../build
jar -cf ../lib/lse.jar .
cd ../src
The above is my build script for a java application. there is a serperate run file which has all the CLASSPATH defined and runs the application.
I am trying to remote debug the application on eclipse but facing issues. The code is sitting on unix server host. i've closely followed instructions about debug configurations... for eclipse.
This is what I'm doing:
I locate my build (above) in putty terminal and execute with . ./build
I type java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999
On eclipse debug config... I enter a random name, project is lse, gave correct host and gave port number as 9999. checked termination of remote VM. When I click debug, it does not stop on the breakpoint.
NOTE: in the project "lse" are 3 .java source that the application uses. the "lse" project has only src content, however in the Unix host it has all the lib, scripts, config folder.
Please can someone tell me what I'm doing wrong. after step 2, I managed to get
Listening for transport dt_socket at address: 9999
then after step 3, I get some messages on putty
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is server,
because you are running on a server-class machine.
....
and see on eclipse a terminated status on debug mode. java hotspot server [host bla bla]
I imagine you solved this by now...but looks like you forgot to provide the name of the class for java to run. If your main method was in a source file like foo/Bar.java, then you would need to add foo.Bar to your java line. Something like:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999 foo.Bar
You might also consider adding -g to your javac to generate debug info.
You could avoid all (or most) of this pain if your source was in the IDE that you're trying to debug with...

Unable to use JConsole with Tomcat running as windows service

I am running tomcat 6.0.18 as a windows service. In the service applet the jvm is configured default, i.e. it is using jvm.dll of the JRE.
I am trying to monitor this application with JConsole but cannot connect to it locally. I added the parameter -Dcom.sun.management.jmxremote (which works when starting tomcat with the start.bat script). But the jvm does not seem to pick up the parameter.
There's a nice GUI to edit the options, no need to muck around in the registry.
Open up the C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\tomcat6.exe (or just double-click on the monitor icon in the task bar). Go to the Java pane, add the following to the list of arguments, and restart Tomcat.
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Then you can connect with JConsole or the newer VisualVM.
Here's the prescribed way for changing jvmoptions & interacting with the service:
http://tomcat.apache.org/tomcat-5.5-doc/windows-service-howto.html
I would try going into your registry at HKLM/Software/Apache Software Foundation/Procrun 2.0//Parameters/Java and editing the "Options" multi-string value directly.
If Tomcat is running as a Windows service, and you want to attach to the JVM locally, you need to run VisualVM or JConsole as the System account. You can use Sysinternals PsExec.exe to accomplish this.
psexec.exe -i -s c:\visualvm\bin\visualvm.exe
I'm posting it mainly to record this information to myself, I haven't validated it - but this is supposed to work as well:
http://mysqlandsqlserver.blogspot.com/2010/02/jconsolejmap-and-tomcat-as-windows.html
There is still a rather simple way to connect JConsole to Java process started as Windows Service using the local mode which I discovered here.
Basically it says that in order to connect to Java process launched as a Windows Service you need to launch JConsole as a Windows Service (you can do it using windows native api or using any wrapper like yajsw.)
By the way, this will free you from restarting the Java Process which was critical for me.
Add the following near the top of your catalina.bat
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote ^
-Dcom.sun.management.jmxremote.port=8086 ^
-Dcom.sun.management.jmxremote.ssl=false ^
-Dcom.sun.management.jmxremote.authenticate=false
Stop and restart tomcat (obviously)
Run jconsole.exe. If your tomcat is running as service, then run jconsole.exe as administrator.
Select Remote Process and enter localhost:8086

Categories

Resources