how to update if search patten is found - shell

$cat sample.txt
<name>server1</name>
Oracle
/usr/bin/java/jdk64
<class-path>/run1/getd/commn/modules/oracle.jdbc_11.1.1/ojdbc6dms.jar:/run1/getd/commn/util/jdk64/lib/tools.jar</class-path>
-XX:PermSize=128m -XX:MaxPermSize=384m -Xms512m -Xmx512m -XX:NewRatio=2 .............
.............
.............
<name>server2</name>
<java-vendor>Oracle</java-vendor>
<java-home>/usr/bin/java/jdk64</java-home>
<class-path>/run1/getd/commn/modules/oracle.jdbc_11.1.1/ojdbc6dms.jar:/run1/getd/commn/util/jdk64/lib/tools.jar</class-path>
<arguments>-XX:PermSize=128m -XX:MaxPermSize=384m -Xms64m -Xmx256m -XX:NewRatio=2 ............. </arguments>
I have a file for my weblogic server, sample.txt like this, so If I see name as server1, I need to update part of arguments to -Xms1024m -Xmx1024m and If I see name as server2 I need to update part of arguments to -Xms256m -Xmx512m. any help on this would be great.

Related

Sonarqube 9.6.1 not starting - Windows10 cmd

I've set the environmental variable SONAR_JAVA_PATH.
It's taken in the SonarServiceWrapper.xml
<!-- Path to the Java executable. To be replaced by SonarService.bat script -->
<executable>D:\Programmes\Java\jdk-13.0.2\bin\java.exe</executable>
<!-- DO NOT EDIT THE FOLLOWING SECTIONS -->
<arguments>
-Xms8m -Xmx32m
-Djava.awt.headless=true
--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.management/sun.management=ALL-UNNAMED
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
-cp "..\..\..\lib\sonar-application-9.6.1.59531.jar" "org.sonar.application.App"
</arguments>
<id>SonarQube</id>
<name>SonarQube</name>
<description>SonarQube</description>
<logpath>../../../logs</logpath>
<log mode="none"/>
</service>
No error in the command line.
Only one log file SonarServiceWrapper.wrapper.log with this line :
2022-10-11 12:26:01,286 DEBUG - Starting WinSW in console mode
I've tried with jdk-11.0.2, jdk-13.0.2 and jdk-19 : same thing
Add the following system environment, Ex:
SONAR_JAVA_PATH : C:\Program Files\Java\jdk-11.0.17\bin\java.exe
In StartSonar.bat, i've commented
REM call :check_if_sonar_is_running FAIL || goto:eof
Next, i use jdk-11.0.2
And sonarqube is up

How fix "Invalid ODBC handle" for sajdbc4 under Wildfly 20?

I had Wildfly 10 running previously and have just upgraded to Wildfly 20 (under Ubuntu 20). My configuration from the past no longer works when it comes to getting the Sybase SQL Anywhere 17 sajdbc4 driver working.
A quick summary of what's going wrong is that I installed sajdbc4.jar and the supporting files in /opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main/. I then ran a simple Java test app to confirm that it can connect to a test database and it works fine. I configured a driver and datasource in standalone.xml and run Wildfly with the following. When I Test Connection for the datasource it fails with "Invalid ODBC handle":
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main
export CLASSPATH=$CLASSPATH:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main
sudo ./standalone.sh
Can anyone explain what I still need to do to get the sajdbc4 driver to work?
Here are detailed notes:
*** I used tar to install Wildfly 20 in:
/opt/wildfly-20.0.1.Final
*** Placed the Sybase Sql Anywhere 17 sajdbc4.jar and other supporting files in /opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main
*** I have a simple Java app that tests the connection which I run with:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main
java -classpath .:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main/sajdbc4.jar sajdbc4DriverTest.java
This simple test app runs and dumps a database table so I conclude that everything I need to work is in /opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main
*** Here is module.xml (in .sybase/main):
<?xml version="1.0" encoding="utf-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mydomain.sybase">
<resources>
<resource-root path="sajdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
*** To test Wildfly I added the driver definition in standalaone.xml as:
<drivers>
...
<driver name="sajdbc4" module="com.mydomain.sybase"/>
</drivers>
*** I then add the following datasource in standalaone.xml:
<datasource jndi-name="java:jboss/datasources/TestDB" pool-name="TestDB" spy="true" tracking="true">
<connection-url>jdbc:sqlanywhere:Host=192.168.1.89:11111,192.168.1.89:11112;ServerName=TestDB;</connection-url>
<driver>sajdbc4</driver>
<pool>
<min-pool-size>0</min-pool-size>
<max-pool-size>30</max-pool-size>
</pool>
<security>
<user-name>...</user-name>
<password>...</password>
</security>
</datasource>
*** I then run in /opt/wildfly-20.0.1.Final/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main
export CLASSPATH=$CLASSPATH:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main
sudo ./standalone.sh
At the top of the Terminal's log we see:
...
JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED
Note that the two exports were ignored!
*** If I then try to test the datasource connection (in the Admin console) we crash with:
...
Caused by: java.lang.UnsatisfiedLinkError: no dbjdbc17 in java.library.path: [/usr/java/packages/lib, /usr/lib/x86_64-linux-gnu/jni, /lib/x86_64-linux-gnu, /usr/lib/x86_64-linux-gnu, /usr/lib/jni, /lib, /usr/lib]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2670)
...
]) - failure description: "WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid"
In an attempt to get around the "export failures" I modified standalone.config (everything after "# ADDED FOLLOWING HACK")
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
# ADDED FOLLOWING HACK
JAVA_OPTS="$JAVA_OPTS -Djava.library.path=/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main -cp .:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main/sajdbc4.jar"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
*** Again I run in /opt/wildfly-20.0.1.Final/bin
sudo ./standalone.sh
At the top of the Terminal's log we now see:
JAVA_OPTS: -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djava.library.path=/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main -cp .:/opt/wildfly-20.0.1.Final/modules/system/layers/base/com/mydomain/sybase/main/sajdbc4.jar --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED
So that suggests that we now have the java.library.path and classpath as needed.
*** If I again try to test the datasource connection we now crash with:
...
Caused by: java.sql.SQLException: Invalid ODBC handle
at com.mydomain.sybase//sap.jdbc4.sqlanywhere.IDriver.makeODBCConnection(Native Method)
at com.mydomain.sybase//sap.jdbc4.sqlanywhere.IDriver.connect(IDriver.java:809)
at org.jboss.ironjacamar.jdbcadapters#1.4.22.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
... 35 more
]) - failure description: "WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid"
Why are the export LD_LIBRARY_PATH and export CLASSPATH being ignored? (I expect that is what's causing the "no dbjdbc17 in java.library.path" error). How do I specify these to Wildfly?
Even when JAVA_OPTS shows the java.library.path and cp are set we still fail with "Invalid ODBC handle". This is very strange because my simple Java app test showed that when both java.library.path and cp are set to ./sybase/main "everything works". Note that the test app uses the same connection string I use in the in standalone.xml.
Thank you in advance.
The problem turned out to be related to the fact that I was running Wildfly as a service and apparently my efforts above to set the java.library.path is failing. I know the reason for the error but I do not know how to set the path when running as a service.

SonarQube 6.1 stopping itself. Not starting

I have installed Sonar qube 6.1. I have started sonar by executing sonar.sh start and checked status with sonar.sh status. After few seconds, sonar stopping itself by writing below statements in the wrapper.log file. Please help me on this issue to get resolve.
2017.05.04 07:01:13 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube-6.1/temp
2017.05.04 07:01:13 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[es]: /usr/java/jdk1.8.0_111/jre/bin/java -Djava.awt.headless=true -Xmx1G -Xms256m -Xss256k -Djna.nosys=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/opt/sonarqube-6.1/temp -javaagent:/usr/java/jdk1.8.0_111/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/search/* org.sonar.search.SearchServer /opt/sonarqube-6.1/temp/sq-process4451619261882420874properties
2017.05.04 07:01:23 INFO app[][o.s.p.m.Monitor] Process[es] is up
2017.05.04 07:01:23 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[web]: /usr/java/jdk1.8.0_111/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false -Djruby.compile.invokedynamic=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/opt/sonarqube-6.1/temp -javaagent:/usr/java/jdk1.8.0_111/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/server/*:/opt/sonarqube-6.1/lib/jdbc/h2/h2-1.3.176.jar org.sonar.server.app.WebServer /opt/sonarqube-6.1/temp/sq-process3625744255132410453properties
2017.05.04 07:01:25 INFO app[][o.s.p.m.Monitor] Process[es] is stopping
2017.05.04 07:01:26 INFO app[][o.s.p.m.Monitor] Process[es] is stopped
es is ElasticSearch, a component that indexes your data to accelerate searching. Maybe your indexes are corrupted. You can rebuild them by removing contents of ${SONARQUBE_HOME}/data/es/ directory, and retry.

Cannot find any provider supporting AES/CBC/PKCS5Padding

I use IDEA develop my code, and in IDEA environment,the code runs well, but when I use mvn clean install to build the project ,and run the projet with this script
#!/bin/bash
source ~/.bashrc
JAVA_OPTS="$JAVA_OPTS -Drun_dir=$MY_ROOT"
JAVA_OPTS="$JAVA_OPTS -server -Xss256k -Xms1g -Xmx1g"
JAVA_OPTS="$JAVA_OPTS -XX:-OmitStackTraceInFastThrow"
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"
JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:+UseParNewGC"
JAVA_OPTS="$JAVA_OPTS -XX:CMSFullGCsBeforeCompaction=4 -XX:CMSInitiatingOccupancyFraction=80 -XX:MaxTenuringThreshold=15"
JAVA_OPTS="$JAVA_OPTS -Dclient.enczoding.override=UTF-8 -Dfile.encoding=UTF-8 -Duser.language=zh -Duser.region=CN"
JAVA_OPTS="$JAVA_OPTS -Djava.ext.dirs=./lib -Djava.library.path=./lib -cp ./resources"
java $JAVA_OPTS Main
it comes the error
Cannot find any provider supporting AES/CBC/PKCS5Padding
jdk is the same version, anyone can help?
thanks dave_thompson_085 ,
change the script to
source ~/.bashrc
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
for jar in `ls ./lib`
do
CLASSPATH=$CLASSPATH:./lib/$jar;
done
CLASSPATH=$CLASSPATH:./resources
JAVA_OPTS="$JAVA_OPTS -server -Xss256k -Xms1g -Xmx1g"
JAVA_OPTS="$JAVA_OPTS -XX:-OmitStackTraceInFastThrow"
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"
JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:+UseParNewGC"
JAVA_OPTS="$JAVA_OPTS -XX:CMSFullGCsBeforeCompaction=4 -XX:CMSInitiatingOccupancyFraction=80 -XX:MaxTenuringThreshold=15"
JAVA_OPTS="$JAVA_OPTS -Dclient.enczoding.override=UTF-8 -Dfile.encoding=UTF-8"
java $JAVA_OPTS -classpath $CLASSPATH Main

CLion Out of Memory Issues

I ran a simple CLion project with only two directories which each contain a single file. However, I was getting this message “Out of Memory”. I increased the Xmx from 2GB to 4GB. I believe this is more than enough. How can I fix this problem?
This is the settings in the clion64.exe.vmoptions file:
-Xss2m
-Xms256m
-Xmx4000m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=96m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
try there settings:
-Xss2m
-Xms256m
-Xmx2000m
-XX:NewSize=128m
-XX:MaxNewSize=128m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=96m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
refer to this page for more info:
link

Resources