How to setup in IntelliJ IDEA VM options.
I need to setup
set JAVA_OPTS="-Dtomee.serialization.class.whitelist="
set CATALINA_OPTS="-Dtomee.serialization.class.blacklist=-"
In run/debug configuration for my local tomee server I pass into VM options
-tomee.serialization.class.whitelist=*
-tomee.serialization.class.blacklist=-
also tried without *.
It still giving me "invalid arguments" error after run/debug the server. How to set it properly?
ps.If I run the server manually everything works correct.
You need to specify the two properties as Java system properties (-D) in the VM options of your run configuration:
-Dtomee.serialization.class.whitelist=*
-Dtomee.serialization.class.blacklist=-
you can set them in idea.exe.vmoptions (should be in bin directory of idea installation) to force it for client side and in conf/system.properties of the tomee instance for the server.
Related
Here's what I do in SpringBoot on Windows to read an environment variable (location of log folder).
In Windows Server, I set a System environment variable for "LOG_HOME" with the value with the directory that SpringBoot should use to write logs.
In SpringBoot's application.properties, I have:
logging.file.name= ${LOG_HOME}/ws.log
Works great!
But in Ubuntu Linux 20.04, the same approach doesn't work for me at all.
When the WAR file tries to deploy on Ubuntu 20.04 using this similar technique:
(in .bashrc): export LOG_HOME = /home/ubuntu/logs
reboot (to reload the environment for sure)
I get this error in the Tomcat log when trying to deploy the WAR file:
java.lang.IllegalArgumentException: Could not resolve placeholder 'LOG_HOME' in value "${LOG_HOME}/ws.log"
So, it seems that Spring doesn't see the environment variable set in Ubuntu.
I wrote a simple Java program just to check the value of the environment variables and they were all created as expected including the LOG_HOME as shown in Linux "printenv".
If possible, I need a technique that will work on Ubuntu without changing the working SpringBoot implementation on Windows Server.
Thanks in advance for suggestions.
Instead of exporting in shell session like
export LOG_HOME = /home/ubuntu/logs
try this as -D VM argument in your starup command
eg:
java -cp=xxx mainclass -DLOG_HOME=/home/ubuntu/log
if you are using tomcat then :
VM args can be added catalina.sh file under CATALINA_OPTS.
For tomcat, add your environment variables to $TOMCAT_HOME/bin/setenv.sh where $TOMCAT_HOME is the directory of your tomcat installation.
The solution for me posted by the extremely helpful satyesht above, was to edit the Catalina.sh file and add the "-D" name-value pair option under CATALINA_OPTS. Thanks to all who posted. :)
In our project , in ide we are providing few vm arguements in ecipse run configurations. But when we are deploying the application, we are trying to provide these arguements. But not sure how to provide through tomcat to run on server startup. Can anybody help us here. Thanks in avdance.
The proper way to set VM arguments in Tomcat is to create a file in the Tomcat bin directory called "setenv.bat" (or "setenv.sh" if you're in Linux or Mac). In that file, you can set JVM options by setting the JAVA_OPTS variable, like for instance:
set JAVA_OPTS="-Xmx2G -Xms128M -Dvariable=2"
https://docs.oracle.com/cd/E40520_01/integrator.311/integrator_install/src/cli_ldi_server_config.html
I am using "Tomcat for Java" plugin in my Visual Studio Code for starting and stopping tomcat server.
This plugin provide following options
1. "jvm.option" to specify JVM arguments
2. "server.xml" to specify tomcat server.xml configuration.
I want to pass some additional environment variables like below while starting tomcat. I could pass additional JVM arguments in STS/Eclipse by double clicking tomcat.
Can someone help me how I could pass below environment variable in VSCode.
-Dconfig=/x/app/config/production.conf
-DlogbackFile=x/app/config/logback.xml
After adding tomcat to your VS code, you can right click on the tomcat and select 'Customize JVM Options'.
After it is open, you can add the parameters that you add in VM arguements in eclipse in here.
I did the RAD set up recently and trying to start websphere server.
In the log, it hangs at the following line and get terminated after timeout:
Server server1 open for e-business
Thanks for the help.
In my case, I did following configuration which solved the issue and server started.
Double click on the server (in the servers tab).
In Server connection types and administrative ports select Automatically determine connection settings and save the changes.
Your workspace folder/name could be the issue.
the WAS installation itself. When moved it to C:\was8 everything started to work properly. The default puts it into c:\Program Files... and that was hanging at 23%
a. Please use websphere jre to replace sun hotspot vm to launch the eclipse, like below setting in the eclipse.ini
-vm
D:/IBM/WebSphere/AppServer/java/bin/javaw.exe
b. Please make sure there is not a specail character (like 23%) in the websphere path or eclipse workpsace.
Copy the jar com.ibm.ws.orb_8.5.0.jar from C:\IBM\WebSphere\AppServer\runtimes
to C:\development\endorsed and in eclipse.ini add this just JVM param (under -vmargs)
-Djava.endorsed.dirs=C:\development\endorsed
There are numerous places on the Internet, suggesting that it is easily achieved by any (or all) of the following methods:
through CATALINA_OPTS
through JAVA_OPTS
through TOMCAT_OPTS
by placing the set statements in the setenv.bat file inside the tomcat's bin folder
My problem, is that I have tried all of the above and my web application still does not see my system property!
Here is what I am doing:
Stop tomcat7 service
set CATALINA_OPTS=-Dabc.def=true in the system environment
set JAVA_OPTS=-Dabc.def=true in the system environment
set TOMCAT_OPTS=-Dabc.def=true in the system environment
put all of the above into c:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\setenv.bat (seems totally redundant, but just in case)
Start tomcat7 service
Inspect the environment of the tomcat7 process using the Process Explorer tool - the environment is correct, I do see both CATALINA_OPTS and JAVA_OPTS and TOMCAT_OPTS equal to -Dabc.def=true
run my web app, which is a simple servlet dumping all the system properties to the response stream - abc.def is not amongst them
Please, put me out of my misery and tell me how to do it.
For the Tomcat service, startup settings are stored in the registry under Options key at:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat<X>\Parameters\Java
(substitute appropriate Tomcat version where needed).
Edit:
On 64-bit Windows, the registry key is:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\Tomcat<X>\Parameters\Java
even if Tomcat is running under a 64-bit JVM.
I know this post is almost 9 years old but thought someone might find this useful.
Although #prunge and #mark answers were very accurate and following their logic I was able to add system properties to my tomcat 7 instance running on Windows, there is an easier way.
In the installation directory of Tomcat there is an exe you can run called
%INSTALL_DIRECTORY%\bin\tomcat7w.exe
This opens up a Tomcat properties windows where you can control the service i.e. start and stop tomcat and there is a tab (Java) that allows you to set the Java properties as well
Scroll to the end of that panel under "Java Options" and add your system properties
-Dpropertyname=value
Then navigate back to the General tab and restart tomcat
I have tested this and my grails app now can see my properties. I use the following Groovy code to get the property out
System.properties.getProperty("propertyname")
Adding the system properties in the Windows registry showed up in this window as well so its one and the same thing, just this application seems to me to be slightly more convenient.
Hope this helps someone else