Array to string conversion in Route - arrays

I'm imploding the Socialite driver from config\auth but getting the error called Array to string conversion
This is the route:
Route::get('redirect/{driver}', 'Auth\LoginController#redirectToProvider')
->name('login.provider')
->where('driver', implode('|', config('auth.socialite.drivers')));
These are the drivers on config.auth.socialite
'socialite' => [
'drivers' => [
'github' => [
'client_id' => env('GITHUB_KEY'),
'client_secret' => env('GITHUB_SECRET'),
'redirect' => env('GITHUB_REDIRECT_URI')
],
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect' => env('GOOGLE_CALLBACK_URL'),
],
],
],```

You only want the keys listed under drivers, so try something like:
Route::get('redirect/{driver}', 'Auth\LoginController#redirectToProvider')
->name('login.provider')
->where('driver', implode('|', array_keys(config('auth.socialite.drivers'))));

Related

Build a custom array in Laravel

I am looping the database to get a list of countries with continents.
array: [
0 => array: [
"country" => "BE"
"continent" => "EU"
1 => array: [
"country" => "BG"
"continent" => "EU"
]
...
]
From that result, I want to create an array that shows all the continents with the countries inside.
array:[
0 => array: [
"continent" => "EU"
"countries" => [
"country" => "BE"
"country" => "BG"
]
]
Suppose this is your array
$arr = [
[
"country" => "BE",
"continent" => "EU",
],
[
"country" => "BG",
"continent" => "EU",
]
];
Then this returns what you expected.
collect($arr)->groupBy('continent')->mapWithKeys(function ($group, $continent) {
return [
'continent' => $continent,
'countries' => $group->pluck('country')->toArray()
];
});
If you need just to group countries by continent, simple way to achieve this by mapToGroups() method for collections
$input = [
['country' => 'BE', 'continent' => 'EU'],
['country' => 'BG', 'continent' => 'EU'],
['country' => 'BU', 'continent' => 'AF'],
['country' => 'BY', 'continent' => 'EU'],
];
$grouped = collect($input)
->mapToGroups(fn ($country) => [$country['continent'] => $country['country']])
->toArray(); // if you need array at the end
This will be resulted in
You will need to some how group your results by the continent. One way to do that is to loop over the initial collection and build a new array keyed by the continent.
However, seeing that you are using Laravel just group the collection by the continent.
$countries = [
['country' => 'A', 'continent' => 'aa'],
['country' => 'B', 'continent' => 'bb'],
['country' => 'C', 'continent' => 'aa'],
['country' => 'D', 'continent' => 'aa'],
['country' => 'E', 'continent' => 'aa'],
['country' => 'F', 'continent' => 'bb'],
];
// Because my data is an array I just turn that into a collection.
// But an Eloquent query builder ->get would already return a collection.
$continents = collect($countries)->groupBy('continent');
foreach ($continents as $continent => $items) {
echo "Countries for " . $continent . "\n";
foreach ($items as $country) {
echo $country['country'] . "\n";
}
}
/**
Output:
Countries for aa
A
C
D
E
Countries for bb
B
F
**/

Why does I see the following error when I am try to create docker container of Keycloak instalation by using SQL external database?

I am trying to install the Keycloak with SQL databse server by using docker-compose file. IT run but keycloak stop with following error.
"ssl-context" => "applicationSSC",
"proxy-address-forwarding" => expression "${env.PROXY_ADDRESS_FORWARDING:false}",
"enable-http2" => true
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("server" => "default-server"),
("host" => "default-host")
],
"alias" => ["localhost"]
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("server" => "default-server"),
("host" => "default-host"),
("location" => "/")
],
"handler" => "welcome-content"
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("server" => "default-server"),
("host" => "default-host"),
("setting" => "http-invoker")
],
"http-authentication-factory" => "application-http-authentication"
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("servlet-container" => "default")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("servlet-container" => "default"),
("setting" => "jsp")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("servlet-container" => "default"),
("setting" => "websockets")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("configuration" => "handler"),
("file" => "welcome-content")
],
"path" => expression "${jboss.home.dir}/welcome-content"
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("application-security-domain" => "other")
],
"security-domain" => "ApplicationDomain"
}, {
"operation" => "add",
"address" => [("subsystem" => "weld")]
}, {
"operation" => "boottime-controller-initializer-step",
"address" => []
}, {
"operation" => "add-deployer-chains",
"address" => []
}]: java.util.concurrent.RejectedExecutionException
at org.jboss.threads#2.4.0.Final//org.jboss.threads.RejectingExecutor.execute(RejectingExecutor.java:37)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.rejectShutdown(EnhancedQueueExecutor.java:2029)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.execute(EnhancedQueueExecutor.java:757)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.notification.NotificationSupports$NonBlockingNotificationSupport.emit(NotificationSupports.java:95)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.OperationContextImpl.notifyModificationsComplete(OperationContextImpl.java:517)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.OperationContextImpl.releaseStepLocks(OperationContextImpl.java:1245)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext$Step.finalizeInternal(AbstractOperationContext.java:1534)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext$Step.finalizeStep(AbstractOperationContext.java:1492)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext$Step.access$400(AbstractOperationContext.java:1356)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext.executeResultHandlerPhase(AbstractOperationContext.java:910)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:790)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:466)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1427)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:559)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:572)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:534)
at org.jboss.as.server#18.1.0.Final//org.jboss.as.server.ServerService.boot(ServerService.java:470)
at org.jboss.as.server#18.1.0.Final//org.jboss.as.server.ServerService.boot(ServerService.java:414)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:473)
at java.base/java.lang.Thread.run(Thread.java:829)
Suppressed: java.util.concurrent.RejectedExecutionException: Executor is being shut down
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.rejectShutdown(EnhancedQueueExecutor.java:2031)
... 18 more
rUser with username 'admin' already added to '/opt/jboss/keycloak/standalone/configuration/keycloak-add-user.json'
I have search other tickets but no able to fix this issue. Username is not an issue I have delete all and try again, not able to run.
My Docker compose file is following
version: "3.2"
services:
mssql:
image: mcr.microsoft.com/mssql/server
ports:
- "1433:1433"
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=Password!23
- MSSQL_PID=Developer
mssqlscripts:
image: mcr.microsoft.com/mssql-tools
depends_on:
- mssql
command: /bin/bash -c 'until /opt/mssql-tools/bin/sqlcmd -S mssql -U sa -P "Password!23" -Q "create database Keycloak"; do sleep 5; done'
keycloak:
image: quay.io/keycloak/keycloak:legacy
depends_on:
- mssql
- mssqlscripts
ports:
- "8443:8080"
environment:
- KEYCLOAK_USER=admin
- KEYCLOAK_PASSWORD=admin
- DB_VENDOR=mssql
- DB_USER=sa
- DB_PASSWORD=Password!23
- DB_ADDR=mssql
- DB_DATABASE=Keycloak
When I try to comment the user name and Pass
"socket-binding" => "https",
"ssl-context" => "applicationSSC",
"proxy-address-forwarding" => expression "${env.PROXY_ADDRESS_FORWARDING:false}",
"enable-http2" => true
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("server" => "default-server"),
("host" => "default-host")
],
"alias" => ["localhost"]
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("server" => "default-server"),
("host" => "default-host"),
("location" => "/")
],
"handler" => "welcome-content"
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("server" => "default-server"),
("host" => "default-host"),
("setting" => "http-invoker")
],
"http-authentication-factory" => "application-http-authentication"
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("servlet-container" => "default")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("servlet-container" => "default"),
("setting" => "jsp")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("servlet-container" => "default"),
("setting" => "websockets")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("configuration" => "handler"),
("file" => "welcome-content")
],
"path" => expression "${jboss.home.dir}/welcome-content"
}, {
"operation" => "add",
"address" => [
("subsystem" => "undertow"),
("application-security-domain" => "other")
],
"security-domain" => "ApplicationDomain"
}, {
"operation" => "add",
"address" => [("subsystem" => "weld")]
}, {
"operation" => "boottime-controller-initializer-step",
"address" => []
}, {
"operation" => "add-deployer-chains",
"address" => []
}]: java.util.concurrent.RejectedExecutionException
at org.jboss.threads#2.4.0.Final//org.jboss.threads.RejectingExecutor.execute(RejectingExecutor.java:37)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.rejectShutdown(EnhancedQueueExecutor.java:2029)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.execute(EnhancedQueueExecutor.java:757)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.notification.NotificationSupports$NonBlockingNotificationSupport.emit(NotificationSupports.java:95)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.OperationContextImpl.notifyModificationsComplete(OperationContextImpl.java:517)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.OperationContextImpl.releaseStepLocks(OperationContextImpl.java:1245)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext$Step.finalizeInternal(AbstractOperationContext.java:1534)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext$Step.finalizeStep(AbstractOperationContext.java:1492)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext$Step.access$400(AbstractOperationContext.java:1356)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext.executeResultHandlerPhase(AbstractOperationContext.java:910)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:790)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:466)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1427)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:559)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:572)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:534)
at org.jboss.as.server#18.1.0.Final//org.jboss.as.server.ServerService.boot(ServerService.java:470)
at org.jboss.as.server#18.1.0.Final//org.jboss.as.server.ServerService.boot(ServerService.java:414)
at org.jboss.as.controller#18.1.0.Final//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:473)
at java.base/java.lang.Thread.run(Thread.java:829)
Suppressed: java.util.concurrent.RejectedExecutionException: Executor is being shut down
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.rejectShutdown(EnhancedQueueExecutor.java:2031)
... 18 more

Unable to connect to SQL server wuth JBoss docker image for KeyCloak

So I have started SQL Server docker image:
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Test#123" \
-p 1433:1433 --name sql1 -h sql1 -d mcr.microsoft.com/mssql/server:2019-latest
And using Microsoft SQL Management Studio I can connect to localhost,1433. I have created a database named keycloak and sa is the owner of the database.
Now running Keycloak image as below fails to connect to the database:
docker run --rm --name keycloak -p 8080:8080 -e DB_VENDOR=mssql -e DB_USER=sa \
-e DB_PASSWORD=Test#123 -e DB_ADDR=localhost -e DB_PORT=1433 -e DB_DATABASE=keycloak \
-e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin jboss/keycloak
It fails with this error:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed.
Error: "Connection refused (Connection refused).
Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port.
Make sure that TCP connections to the port are not blocked by a firewall.".
Searching through the logs the above error happens first but then there is this error all over the place, which may be the side effect of the previous error but at least it tells me that the correct JDBC url is being used:
ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 20) WFLYCTL0403: Unexpected failure during execution of the following operation(s): [{
"operation" => "add",
"address" => [("subsystem" => "security")]
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "other")
],
"cache-type" => "default"
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "other"),
("authentication" => "classic")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "other"),
("authentication" => "classic"),
("login-module" => "Remoting")
],
"code" => "Remoting",
"flag" => "optional",
"module-options" => {"password-stacking" => "useFirstPass"}
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "other"),
("authentication" => "classic"),
("login-module" => "RealmDirect")
],
"code" => "RealmDirect",
"flag" => "required",
"module-options" => {"password-stacking" => "useFirstPass"}
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jboss-web-policy")
],
"cache-type" => "default"
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jboss-web-policy"),
("authorization" => "classic")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jboss-web-policy"),
("authorization" => "classic"),
("policy-module" => "Delegating")
],
"code" => "Delegating",
"flag" => "required"
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jaspitest")
],
"cache-type" => "default"
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jaspitest"),
("authentication" => "jaspi")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jaspitest"),
("authentication" => "jaspi"),
("login-module-stack" => "dummy")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jaspitest"),
("authentication" => "jaspi"),
("login-module-stack" => "dummy"),
("login-module" => "Dummy")
],
"code" => "Dummy",
"flag" => "optional"
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jaspitest"),
("authentication" => "jaspi"),
("auth-module" => "Dummy")
],
"code" => "Dummy"
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jboss-ejb-policy")
],
"cache-type" => "default"
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jboss-ejb-policy"),
("authorization" => "classic")
]
}, {
"operation" => "add",
"address" => [
("subsystem" => "security"),
("security-domain" => "jboss-ejb-policy"),
("authorization" => "classic"),
("policy-module" => "Delegating")
],
"code" => "Delegating",
"flag" => "required"
}]: java.lang.RuntimeException: WFLYCTL0195: Interrupted awaiting transaction commit or rollback
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTransactionControl.operationPrepared(ParallelBootOperationStepHandler.java:458)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.ModelController$OperationTransactionControl.operationPrepared(ModelController.java:131)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.AbstractOperationContext.executeDoneStage(AbstractOperationContext.java:874)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:805)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:468)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:384)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
[0m[31m06:20:09,064 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 18) WFLYCTL0403: Unexpected failure during execution of the following operation(s): [{
"operation" => "add",
"address" => [("subsystem" => "datasources")]
}, {
"operation" => "add",
"jndi-name" => "java:jboss/datasources/ExampleDS",
"enabled" => true,
"use-java-context" => true,
"statistics-enabled" => expression "${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}",
"address" => [
("subsystem" => "datasources"),
("data-source" => "ExampleDS")
],
"connection-url" => "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE",
"driver-name" => "h2",
"user-name" => "sa",
"password" => "sa"
}, {
"operation" => "add",
"jndi-name" => "java:jboss/datasources/KeycloakDS",
"enabled" => true,
"use-java-context" => true,
"use-ccm" => true,
"address" => [
("subsystem" => "datasources"),
("data-source" => "KeycloakDS")
],
"connection-url" => expression "jdbc:sqlserver://${env.DB_ADDR:mssql}:${env.DB_PORT:1433};databaseName=${env.DB_DATABASE:keycloak};sendStringParametersAsUnicode=false;${env.JDBC_PARAMS:}",
"driver-name" => "sqlserver",
"flush-strategy" => "IdleConnections",
"user-name" => expression "${env.DB_USER:keycloak}",
"password" => expression "${env.DB_PASSWORD:password}",
"check-valid-connection-sql" => "SELECT 1",
"background-validation" => true,
"background-validation-millis" => 60000L
}, {
"operation" => "add",
"driver-name" => "h2",
"driver-major-version" => undefined,
"driver-minor-version" => undefined,
"driver-module-name" => "com.h2database.h2",
"address" => [
("subsystem" => "datasources"),
("jdbc-driver" => "h2")
],
"driver-xa-datasource-class-name" => "org.h2.jdbcx.JdbcDataSource"
}, {
"operation" => "add",
"driver-name" => "sqlserver",
"driver-major-version" => undefined,
"driver-minor-version" => undefined,
"driver-module-name" => "com.microsoft.sqlserver.jdbc",
"address" => [
("subsystem" => "datasources"),
("jdbc-driver" => "sqlserver")
],
"driver-xa-datasource-class-name" => "com.microsoft.sqlserver.jdbc.SQLServerXADataSource"
}]: java.lang.RuntimeException: WFLYCTL0195: Interrupted awaiting transaction commit or rollback
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTransactionControl.operationPrepared(ParallelBootOperationStepHandler.java:458)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.ModelController$OperationTransactionControl.operationPrepared(ModelController.java:131)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.AbstractOperationContext.executeDoneStage(AbstractOperationContext.java:874)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:805)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:468)
at org.jboss.as.controller#15.0.1.Final//org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:384)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads#2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
I searched for the error and I don't have any issue in regards to firewall or TCP port not being set properly, according to Microsoft the first command will set TCP port to 1433.
Has anyone had similar experience, please help me on this.
Does anyone know
Your MSSQL is not running on the localhost in the Keycloak container - so DB_ADDR=localhost it not correct. It is running on the localhost on your host machine. Use host network --network host for Keycloak container, then localhost for DB_ADDR will be valid. Keep in mind localhost in the container is not a localhost of host system by default (unless you are using host network).
Recommended doc (there are also other options how to sort it without host network): https://docs.docker.com/network/

I'm getting a 404 error using Laminas Framework. Can anyone assist?

The error is:
A 404 error occurred
Page not found.
The requested URL could not be matched by routing.
No Exception available
I've registered my module and namespace with Composer and then ran Composer dump-autoload. My code is as follows:
module\Album\config\module.config.php
<?php
declare(strict_types=1);
namespace Album;
use Laminas\Router\Http\Segment;
use Laminas\ServiceManager\Factory\InvokableFactory;
return [
'router' => [
'routes' => [
'album' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\AlbumController::class,
'action' => 'index',
],
],
],
],
],
'controllers' => [
'factories' => [
Controller\AlbumController::class => InvokableFactory::class,
],
],
'view_manager' => [
'template_map' => [
'album/index' => __DIR__ . '/../view/album/album/index.phtml',
],
'template_path_stack' => [
'album' => __DIR__ . '/../view',
],
],
];
module\Album\src\Module.php
<?php
declare(strict_types=1);
namespace Album;
class Module
{
public function getConfig() : array
{
return include __DIR__ . '/../config/module.config.php';
}
}
module\Album\src\Controller\AlbumController.php
<?php
declare(strict_types=1);
namespace Album\Controller;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
class AlbumController extends AbstractActionController
{
public function indexAction()
{
return new ViewModel();
}
}
module\Album\view\album\album\index.phtml
Index page displays here...
As you specified the root as
'route' => '/album[/:action[/:id]]',
The url should look like http://laminas.com/album which will route to the indexAction as you have defined that action as the default, but http://laminas.com/album/index would have the same effect.

Cakephp model virtualFields not working

I already have some virtual fields working on my application, but this one is busting my mind.
So I have the entity SubactivitySlots, with the following code:
protected $_virtual = [
'slots_text',
];
and
protected function _getSlotsText(){
return "test";
}
When I run the query:
debug($this->SubactivitySlots->find('all')->first());
It returns me the following structure (tried with both first and toArray()
object(App\Model\Entity\SubactivitySlot) {
'id' => (int) 1,
'name' => 'MAIN',
'description' => '-',
'activity_id' => (int) 1,
'subactivity_min' => (int) 1,
'subactivity_max' => (int) 1,
'position' => (int) 1,
'institution_id' => (int) 1,
'deleted' => (int) 0,
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [
(int) 0 => 'slots_text'
],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'SubactivitySlots'
}
Any clue of what might be wrong? I'm spent a lot of time trying to discover and can't find out. The strangest thing is that i'm using virtual fields on another entities and it's working.
Thanks
If I'm not wrong cake does not debug virtual fields until 3.5.13.
In cake 3.4 the $_virtual property is used when "converting entities to arrays or JSON" (from here) but not in debug mode.
So even if you don't see them when you debug you should see them when uou convert the entity in JSON
Anyway this should have changed in 3.5.13 (see the blog here) so if you can upgrade the issue will be solved

Resources