Wildfly Postgres Connection Failed - postgresql

I've tried to add Postgres as datasource in Wildfly but keep on getting the JDBC connection error as follow :
Failed to create JDBC connection.
An internal error occurred. Details Unexpected HTTP response: 500
Request {
"name" => "PostgresDS",
"enabled" => true,
"jndi-name" => "java:/PostgresDS",
"user-name" => "admin",
"password" => "123",
"pool-name" => "PostgresDS_Pool",
"use-ccm" => false,
"jta" => false,
"connection-url" => "jdbc:postgresql://localhost:5432/postgresdb",
"driver-class" => "org.postgresql.Driver",
"driver-name" => "postgresql-9.4.1208.jar",
"valid-connection-checker-class-name" => "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker",
"background-validation" => true,
"exception-sorter-class-name" => "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter",
"operation" => "add",
"address" => [
("subsystem" => "datasources"),
("data-source" => "PostgresDS")
] }
Response
Internal Server Error {
"outcome" => "failed",
"failure-description" => "WFLYCTL0212: Duplicate resource [
(\"subsystem\" => \"datasources\"),
(\"data-source\" => \"PostgresDS\") ]",
"rolled-back" => true }

Related

Cannot pass parameter to cli script anymore using -D

I use some script for Keycloak configuration purpose.
Until now, I used Keycloak 2.5.5.Final. I just upgraded to Keycloak 4.5.0.Final and I have a problem.
My script was called like that :
E:\...\scripts>keycloak-cli.bat --connect --controller=localhost:9990
-DdeployDir=E:\\...\\config\bin -DmysqlHost=localhost -DmysqlPort=3306
-DmysqlUser=KeycloakSQL -DmysqlPwd=somepwd -DadminPort=9991 -DhttpPort=8081
-DhttpsPort=8444 --file=E:\...\cli\keycloak_wildfly.cli
Keycloak-cli.bat being :
#echo off
REM set NOPAUSe to avoid to block the cmd when a wildfly cli script is executed
set NOPAUSE=true
REM set the java_home environment variable
set JAVA_HOME=E:\...\jdk
call "E:\...\keycloak\bin\jboss-cli.bat" %*
and keycloak_wildfly.cli being :
#batch
#---------------------------------------------------------------------------
# Create db datasource
#---------------------------------------------------------------------------
if (outcome != success) of /subsystem=datasources/jdbc-driver=mariadb:read-resource
/subsystem=datasources/jdbc-driver=mariadb:add(driver-name=mariadb,driver-module-name=org.mariadb,driver-xa-datasource-class-name=org.mariadb.jdbc.Driver)
end-if
if (outcome != success) of /subsystem=security/security-domain=KeycloakDatabaseLogin/:read-resource
/subsystem=security/security-domain=KeycloakDatabaseLogin/:add(cache-type=default)
/subsystem=security/security-domain=KeycloakDatabaseLogin/authentication=classic:add(login-modules=[{"code"=>"SecureIdentity", "flag"=>"required", "module-options"=>[("username"=>"${mysqlUser}"),("password"=>"-123456789")]}])
end-if
# Modify the default datasource (if already exist) to use our mariaDB
if (outcome == success) of /subsystem=datasources/data-source=KeycloakDS:read-resource
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="jta",value="false")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="use-ccm",value="false")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="enabled",value="true")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="jndi-name",value="java:jboss/datasources/KeycloakDS")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="max-pool-size",value="10")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="min-pool-size",value="5")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="driver-name",value="mariadb")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="connection-url",value="jdbc:mysql://${mysqlHost}:${mysqlPort}/KeycloakDB")
/subsystem=datasources/data-source=KeycloakDS:undefine-attribute(name="password")
/subsystem=datasources/data-source=KeycloakDS:undefine-attribute(name="user-name")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="security-domain",value="KeycloakDatabaseLogin")
end-if
# Else create a new datasource if not available
if (outcome != success) of /subsystem=datasources/data- source=KeycloakDS:read-resource
/subsystem=datasources/data-source="KeycloakDS":add(jta="false",use-ccm="false",enabled="true",jndi-name=java:jboss/datasources/KeycloakDS,max-pool-size=10,min-pool-size=5,driver-name=mariadb,connection-url=jdbc:mysql://${mysqlHost}:${mysqlPort}/KeycloakDB,security-domain="KeycloakDatabaseLogin")
end-if
#---------------------------------------------------------------------------
# Change IP settings
#---------------------------------------------------------------------------
#Public interface listen on all IPs
/interface=public:write-attribute(name="inet-address",value="${jboss.bind.address:0.0.0.0}")
# Change http and https ports
/socket-binding-group=standard-sockets/socket-binding="management- http":write-attribute(name="port",value="${adminPort}")
/socket-binding-group=standard-sockets/socket-binding="http":write-attribute(name="port",value="${httpPort}")
/socket-binding-group=standard-sockets/socket-binding="https":write-attribute(name="port",value="${httpsPort}")
It worked perfectly.
With version 4.5.0.Final of Keycloak, I have the follwoing error when running the script :
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "success",
"response-headers" => {
"operation-requires-reload" => true,
"process-state" => "reload-required"
}
}
{
"outcome" => "failed",
"failure-description" => "WFLYCTL0211: Cannot resolve expression '${httpPort}'",
"rolled-back" => true,
"response-headers" => {"process-state" => "reload-required"}
}
It doesn't replace the ${xxx} by the value passed in as -D in the command line.
I don't understand why.
Can anyone help me ?
Thank you,
Seb

Difference between kill and destroy WildFly server

I can see you can stop individual Domain servers in WildFly with:
stop
kill
destroy
While it's obvious "stop" should be a graceful shutdown, what's the difference between kill and destroy? (in particular in terms of forcing session stopping?)
Thanks!
From the read-operation-description operation on the server-groups resource.
{
"operation-name" => "destroy-servers",
"description" => "Destroy the server processes in the server group. In case the server is not in the stopping state, it will attempt to stop the server first.",
"request-properties" => {},
"reply-properties" => {},
"read-only" => false,
"runtime-only" => true
}
{
"operation-name" => "kill-servers",
"description" => "Kill all server processes in the server group. In case the server is not in the stopping state, it will attempt to stop the server first. This operation may not work on all platforms an
d will try to destroy the process if not available.",
"request-properties" => {},
"reply-properties" => {},
"read-only" => false,
"runtime-only" => true
}
{
"operation-name" => "stop-servers",
"description" => "Stops all servers belonging to the server group currently running in the domain.",
"request-properties" => {
"blocking" => {
"type" => BOOLEAN,
"description" => "Wait until the servers are fully stopped before returning from the operation.",
"expressions-allowed" => false,
"required" => false,
"nillable" => true,
"default" => false
},
"timeout" => {
"type" => INT,
"description" => "The graceful shutdown timeout. If this is zero then a graceful shutdown will not be attempted, if this is -1 then the server will wait for a graceful shutdown indefinitely.",
"expressions-allowed" => false,
"required" => false,
"nillable" => true,
"default" => 0,
"unit" => "SECONDS"
}
},
"reply-properties" => {},
"read-only" => false,
"runtime-only" => true
}
For the operations on the individual servers:
{
"operation-name" => "destroy",
"description" => "Destroy the server process. In case the server is not in the stopping state, it will attempt to stop the server first.",
"request-properties" => {},
"reply-properties" => {},
"read-only" => false,
"runtime-only" => true
}
{
"operation-name" => "kill",
"description" => "Kill the server process. In case the server is not in the stopping state, it will attempt to stop the server first. This operation may not work on all platforms and will try to destroy
the process if not available.",
"request-properties" => {},
"reply-properties" => {},
"read-only" => false,
"runtime-only" => true
}
{
"operation-name" => "stop",
"description" => "Stop a currently running server.",
"request-properties" => {
"server" => {
"type" => STRING,
"description" => "The name of the server.",
"expressions-allowed" => false,
"required" => false,
"nillable" => true,
"min-length" => 1L,
"max-length" => 2147483647L,
"deprecated" => {
"since" => "1.0.4",
"reason" => "This parameter is ignored, instead the name comes from the value of the last address element"
}
},
"blocking" => {
"type" => BOOLEAN,
"description" => "Whether the operation should block and wait until the server is stopped.",
"expressions-allowed" => false,
"required" => false,
"nillable" => true
},
"timeout" => {
"type" => INT,
"description" => "If this timeout is set a graceful shutdown will be attempted. If this is zero (the default) then the server will shutdown immediately. A value larger than zero means the server
will wait up to this many seconds for all active requests to finish. A value smaller than zero means that the server will wait indefinitely for all active requests to finish.",
"expressions-allowed" => false,
"required" => false,
"nillable" => true,
"default" => 0,
"unit" => "SECONDS"
}
},
"reply-properties" => {
"type" => STRING,
"description" => "The status of the server following execution of this operation."
},
"read-only" => false,
"runtime-only" => true
}

Connection to mongodb atlas in codeigniter framework getting error

What i am trying to do is to connect mongodb atlas with my codeigniter framework.
I have used this library for mongodb
https://github.com/verkhoumov/codeigniter-mongodb-library
Below is my connection code
$config['mongo_db']['default'] = [
'settings' => [
'auth' => TRUE,
'debug' => TRUE,
'return_as' => 'array',
'auto_reset_query' => TRUE
],
'connection_string' => '',
'connection' => [
'host' => 'host link',
'port' => '27017',
'user_name' => 'username',
'user_password' => 'password',
'db_name' => 'dbname',
'db_options' => []
],
'driver' => []
];
The main problem is mongodb atlas doesnt provide you the port its query string is like mongodb+srv not mongodb:27017
MongoDb Atlas provides a connection string.
You can find it under Clusters -> Connect Your Application -> Copy a connection string.
Make sure to change "test" with your database name.
Then set it in 'connection_string' in your config file. Other parameters keep default.
$config['mongo_db']['default'] = [
'settings' => [
'auth' => TRUE,
'debug' => TRUE,
'return_as' => 'array',
'auto_reset_query' => TRUE
],
'connection_string' => 'mongodb://************#cluster0-shard-00-00-5ehze.gcp.mongodb.net:27017,cluster0-shard-00-01-5ehze.gcp.mongodb.net:27017,cluster0-shard-00-02-5ehze.gcp.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true',
'connection' => [
'host' => '',
'port' => '',
'user_name' => '',
'user_password' => '',
'db_name' => '',
'db_options' => []
],
'driver' => []
];

Setting up mongodb config in Laravel with Compose.io

Its my first time use compose.io as my mongodb hosting.
I was trying to configure compose.io mongodb with Laravel but ended up this error:
ConnectionTimeoutException in Collection.php line 432:
No suitable servers found (`serverSelectionTryOnce` set)
I was using https://github.com/jenssegers/laravel-mongodb package to add mongodb support to Laravel.
My mongodb config:
'mongodb' => [
'driver' => 'mongodb',
'host' => ['aws-us-east-1-portal.25.dblayer.com:20020/admin', 'aws-us-east-1-portal.26.dblayer.com:20020/admin'],
'port' => env('MONGO_DB_PORT', 27017),
'database' => env('MONGO_DB_DATABASE'),
'username' => env('MONGO_DB_USERNAME'),
'password' => env('MONGO_DB_PASSWORD'),
'options' => [
'ssl' => true,
'database' => 'admin', // sets the authentication database required by mongo 3
'replicaSet' => 'set-5939226a8aab5300121d0ef2',
'readPreference' => 'primary',
],
'driver_options' => [
'context' => stream_context_create( [
'ssl' => [
'local_cert' => base_path('mongo.pem'),
'cafile' => base_path('mongo.pem'),
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
'verify_expiry' => false,
'allow_invalid_certificates' => true
]
])
]
]
I am not also sure what is the value for MONGO_REPLICA_SET
Anyone experienced something similar?
Thanks
It works by removing replicaSet option
Final configuration:
'mongodb' => [
'driver' => 'mongodb',
'host' => ['aws-us-east-1-portal.25.dblayer.com', 'aws-us-east-1-portal.26.dblayer.com'],
'port' => env('MONGO_DB_PORT', 27017),
'database' => env('MONGO_DB_DATABASE'),
'username' => env('MONGO_DB_USERNAME'),
'password' => env('MONGO_DB_PASSWORD'),
'options' => [
'ssl' => true,
'database' => env('MONGO_DB_DATABASE'), // sets the authentication database required by mongo 3
],
'driver_options' => [
'context' => stream_context_create( [
'ssl' => [
'cafile' => base_path('mongo.pem'),
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
'verify_expiry' => false,
]
])
]
]

Not able to assign deployed war file to main-server-group in jboss as7

I have jboss in domain mode.
I am not able to assign the deployed war file to the main-server-cgroup.
i am getting following error.
I am able to assign it to other-server-group.
Failed to add Deployment middleware.war
Unexpected HTTP response: 500
Request
{
"operation" => "composite",enter code here
"address" => [],
"steps" => [
{
"address" => [
("server-group" => "main-server-cgroup"),
("deployment" => "middleware.war")
],
"operation" => "add"
},
{
"address" => [
("server-group" => "main-server-cgroup"),
("deployment" => "middleware.war")
],
"operation" => "deploy"
}
]
}
Response
Internal Server Error
{
"outcome" => "failed",
"result" => {
"step-1" => {"outcome" => "success"},
"step-2" => {"outcome" => "success"}
},
"failure-description" => "JBAS010839: Operation failed or was rolled back on all servers.",
"rolled-back" => true,
"server-groups" => {"main-server-cgroup" => {"host" => {"master" => {"server-1" => {"response" => {
"outcome" => "failed",
"result" => {
"step-1" => {
"outcome" => "failed",
"rolled-back" => true
},
"step-2" => {
"outcome" => "failed",
"failure-description" => {
"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./middleware" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./middleware: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
Caused by: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context"},
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => ["jboss.deployment.unit.\"middleware.war\".deploymentCompleteService"],
"Services that may be the cause:" => ["jboss.binding.modcluster"]
}
},
"rolled-back" => true
}
},
"failure-description" => {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {
"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./middleware" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./middleware: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context
Caused by: org.jboss.msc.service.StartException in anonymous service: JBAS018040: Failed to start context"},
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => ["jboss.deployment.unit.\"middleware.war\".deploymentCompleteService"],
"Services that may be the cause:" => ["jboss.binding.modcluster"]
}
}}},
"rolled-back" => true
}}}}}}
}