I am getting some difficulties to connect from my scala/slick application from one container to mysql in another container.
Here is how I am running docker containers:
// MySQL
docker container run --publish 3306:3306 --name mysqlDb -e MYSQL_ROOT_PASSWORD=123123 -d mysql
// Scala/slick app
docker container run -v /Users/userHome/Sources/slick-dev-box:/home --expose=3306 -it --link mysqlDb:mysql hseeberger/scala-sbt
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f12b46821f69 hseeberger/scala-sbt "bash" About a minute ago Up About a minute 3306/tcp gracious_engelbart
afcd1902b741 mysql "docker-entrypoint.s…" About an hour ago Up 37 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysqlDb
application.conf
mysql = {
profile = "slick.jdbc.MySQLProfile$"
dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
properties = {
driver = "com.mysql.cj.jdbc.Driver"
url = "jdbc:mysql://172.17.0.2:3360/slick"
user = "root"
password = "123123"
}
}
Error I am getting:
warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Running com.avelimited.slick.demo.Runner
[error] (run-main-0) java.sql.SQLTransientConnectionException: mysql - Connection is not available, request timed out after 30005ms.
[error] java.sql.SQLTransientConnectionException: mysql - Connection is not available, request timed out after 30005ms.
[error] at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:676)
[error] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:190)
[error] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:155)
[error] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100)
[error] at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:14)
[error] at slick.jdbc.JdbcBackend$BaseSession.<init>(JdbcBackend.scala:494)
[error] at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:46)
[error] at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:37)
[error] at slick.basic.BasicBackend$DatabaseDef.acquireSession(BasicBackend.scala:250)
[error] at slick.basic.BasicBackend$DatabaseDef.acquireSession$(BasicBackend.scala:249)
[error] at slick.jdbc.JdbcBackend$DatabaseDef.acquireSession(JdbcBackend.scala:37)
[error] at slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:275)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[error] at java.lang.Thread.run(Thread.java:748)
[error] Caused by: java.lang.NullPointerException
[error] at slick.jdbc.DriverDataSource.getConnection(DriverDataSource.scala:101)
[error] at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369)
[error] at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
[error] at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
[error] at com.zaxxer.hikari.pool.HikariPool.access$100(HikariPool.java:71)
[error] at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:706)
[error] at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:692)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[error] at java.lang.Thread.run(Thread.java:748)
[error] Nonzero exit code: 1
What I've tried so far:
I tried to use different port like 3360 and 33060, but same result.
Networkwise, when I run ping from app container, I am getting response from mysql container and when I run cat /etc/hosts on app container:
root#f12b46821f69:/home# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 mysql afcd1902b741 mysqlDb
172.17.0.3 f12b46821f69
Please let me know if there is something else I could check to fix connection issue.
Well, apparently issue was to do with myql-connector driver,
here is the fix I have to apply:
// Before
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.34"
// After
libraryDependencies += "mysql" % "mysql-connector-java" % "8.0.11"
Related
I'm trying to deploy a docker container to perform some testings with gitlab runners but when I'm doing the docker-compose up command I get the following output:
admin#runners-test:~/runner-test$ sudo docker-compose up -d
Starting gitlab-runner ... error
ERROR: for gitlab-runner Cannot start service gitlab-runner: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: process_linux.go:458: setting cgroup config for procHooks process caused: can't load program: operation not permitted: unknown
ERROR: for gitlab-runner Cannot start service gitlab-runner: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: process_linux.go:458: setting cgroup config for procHooks process caused: can't load program: operation not permitted: unknown
ERROR: Encountered errors while bringing up the project.
Abd this is the output of journalctl:
Sep 23 07:23:24 runners-test dockerd[231]: time="2022-09-23T07:23:24.560275437Z" level=error msg="stream copy error: reading from a closed fifo"
Sep 23 07:23:24 runners-test dockerd[231]: time="2022-09-23T07:23:24.577270402Z" level=error msg="stream copy error: reading from a closed fifo"
Sep 23 07:23:24 runners-test dockerd[231]: time="2022-09-23T07:23:24.675282811Z" level=error msg="0cd3bbb779a947012c9059921f092b569eb088bb2fe0bf99a8ae3266ec43abbd cleanup: failed to delete container from containerd: no such container"
Sep 23 07:23:24 runners-test dockerd[231]: time="2022-09-23T07:23:24.675625496Z" level=error msg="Handler for POST /v1.25/containers/0cd3bbb779a947012c9059921f092b569eb088bb2fe0bf99a8ae3266ec43abbd/start returned error: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: process_linux.go:458: setting cgroup config for procHooks process caused: can't load program: operation not permitted: unknown"
And the docker-compose file:
version: '3'
services:
gitlab-runner:
container_name: gitlab-runner
image: 'gitlab/gitlab-runner:latest'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./config:/etc/gitlab-runner
restart:
unless-stopped
This error occurs with any container I try to lift, even doing a simple docker run hello-world...
I also take a look to this post on proxmox forum but I don't know how to add kernel command line parameters for a lxc container, I'v been trying editing the /etc/default/grub file but update-grub command doesn't work as I want inside the lxc, I get the following output:
admin#runners-test:/$ sudo update-grub
[sudo] password for admin:
/usr/sbin/grub-probe: error: failed to get canonical path of `/dev/mapper/pve-vm--1010118--disk--0'.
I'm really stuck with this, so any kind of help would be welcome :) Thanks!
I referenced many other links when finally discovering doing a (on CentOS) update did the trick. So:
yum update -y
reboot
After the reboot, the system came back online and I proceeded to run my docker container, in this case a docker registry:
[root#server ~]# docker run -d --name registry registry:2
c40941bf42c853709bcca05bad4e8914df1f4932a355607f37b55f7e0ed01e60
[root#server ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
c40941bf42c8 registry:2 "/entrypoint.sh /e..." 3 seconds ago Up 2 seconds 5000/tcp
The docker container booted up fine.
So, also here are reference pages I checked out, and I did not have to change anything in /boot/boot.txt as this one references, but is good info:
https://my-take-on.tech/2021/05/07/fix-docker-cgroup-errors-after-systemd-248-update/
and this one, which after I read it, it had me finally trying to do a yum update for fix:
docker-compose throws errors by starting mariadb for an private nextcloud installation
I am trying to do docker:publishLocal from sbt after performing
eval $(minikube docker-env)
so that it gets build in kubernetes itself but running that cmd it gives:
[warn]
[success] All package validations passed
[info] Sending build context to Docker daemon 185.1MB
[info] Step 1/16 : FROM openjdk:8 as stage0
[error] Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
[error] java.lang.RuntimeException: Nonzero exit value: 1
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:483)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$33(DockerPlugin.scala:187)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$33$adapted(DockerPlugin.scala:185)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error] at sbt.std.Transform$$anon$4.work(System.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] at sbt.Execute.work(Execute.scala:278)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (Docker / publishLocal) Nonzero exit value: 1
[error] Total time: 164 s, completed 5 Mar, 2021 1:56:16 PM
So. I tested :
docker run hello-world
which gave:
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
then I tried restarting followed by:
docker logout
docker login
....
error during connect: Post https://192.168.49.2:2376/v1.24/auth: dial tcp 192.168.49.2:2376: connect: no route to host
Now on
docker run hello-world
docker: error during connect: Post https://192.168.49.2:2376/v1.24/containers/create: dial tcp 192.168.49.2:2376: connect: no route to host.
See 'docker run --help'.
So, How can I do publishLocal into the kubernetes itself or run hello-world if everything is fine after eval $(minikube docker-env) ?
I am running keycloak v8.0.0 using docker compose file. I am persisting the data into a MySQL database which I am running locally.
version: '3'
services:
keycloak:
image: jboss/keycloak:8.0.0
ports:
- "9999:8080"
environment:
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: <ADMIN_PASSWORD>
DB_VENDOR: mysql
DB_ADDR: <HOST>
DB_PORT: <PORT>
DB_USER: <USER>
DB_PASSWORD: <PASSWORD>
JDBC_PARAMS: "useSSL=false"
volumes:
- "./realms:/tmp"
I tried exporting a realm from the running docker container by using following command.
docker exec -it kc /opt/jboss/keycloak/bin/standalone.sh \
-Djboss.socket.binding.port-offset=100 -Dkeycloak.migration.action=export \
-Dkeycloak.migration.provider=singleFile \
-Dkeycloak.migration.realmName=my_realm\
-Dkeycloak.migration.usersExportStrategy=REALM_FILE \
-Dkeycloak.migration.file=/tmp/my_realm-realm.json
Below is the stack trace of the error i am getting when I run the above command. When I am running the above command keycloak is not able to connect to database server i.e. MySQL in this case. How to specify database connection configuration in this scenario?
16:30:04,000 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 65) MSC000001: Failed to start service jboss.deployment.unit."keycloak-server.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.unit."keycloak-server.war".undertow-deployment: java.lang.RuntimeException: RESTEASY003325: Failed to construct public org.keycloak.services.resources.KeycloakApplication()
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public org.keycloak.services.resources.KeycloakApplication()
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:164)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2784)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:364)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:277)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:89)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:119)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:305)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:585)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:556)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:598)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
... 8 more
Caused by: java.lang.RuntimeException: Failed to connect to database
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.getConnection(DefaultJpaConnectionProviderFactory.java:372)
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.lazyInit(LiquibaseDBLockProvider.java:65)
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.lambda$waitForLock$2(LiquibaseDBLockProvider.java:96)
at org.keycloak.keycloak-server-spi-private#8.0.0//org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:682)
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.waitForLock(LiquibaseDBLockProvider.java:94)
at org.keycloak.keycloak-services#8.0.0//org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:178)
at org.keycloak.keycloak-server-spi-private#8.0.0//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:227)
at org.keycloak.keycloak-services#8.0.0//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:171)
at org.keycloak.keycloak-services#8.0.0//org.keycloak.services.resources.KeycloakApplication.init(KeycloakApplication.java:162)
at org.keycloak.keycloak-services#8.0.0//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:143)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)
... 31 more
Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/KeycloakDS
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:159)
at org.jboss.as.connector#18.0.0.Final//org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64)
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.getConnection(DefaultJpaConnectionProviderFactory.java:366)
... 45 more
Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/KeycloakDS
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:690)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:440)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:789)
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:151)
... 47 more
Caused by: javax.resource.ResourceException: IJ031084: Unable to create connection
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1328)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:499)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:632)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:604)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:624)
... 50 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 97 milliseconds ago. The last packet sent successfully to the server was 91 milliseconds ago.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:201)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4912)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1663)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1224)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2190)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
... 57 more
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at java.base/sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:169)
at java.base/sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:98)
at java.base/sun.security.ssl.TransportContext.kickstart(TransportContext.java:216)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:395)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:186)
... 73 more
The first solution did not work for me, so I had to investigate further. In my case, the reason was, that the DB_PORT environment variable was not added to the connection string, so keycloak tried to connect to the postgres DB under the dafault port 5432, as seen in this log:
11:29:10,185 ERROR [stderr] (ServerService Thread Pool -- 68) FINE: Connecting with URL: jdbc:postgresql://156149bb-0045-4086-b11a-1b55458b2a5f.blrv234f085n1l00bhrg.private.databases.appdomain.cloud/ibmclouddb?connectTimeout=30&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory&loggerLevel=DEBUG
[...]
11:29:10,194 ERROR [stderr] (ServerService Thread Pool -- 68) FINE: Trying to establish a protocol version 3 connection to 156149bb-0045-4086-b11a-1b55458b2a5f.blrv234f085n1l00bhrg.private.databases.appdomain.cloud:5432
So I added the Port to the DB_ADDR variable and everything worked fine.
I got the same error today,and found is the JDBC_PARAMS format error;
so you can exec in the container,
docker exec -it kc bash
and modify the JDBC_PARAMS
# Append '?' in the beggining of the string if JDBC_PARAMS value isn't empty
export JDBC_PARAMS=$(echo ${JDBC_PARAMS} | sed '/^$/! s/^/?/')
Or redefine JDBC_PARAMS env
export JDBC_PARAMS='?connectTimeout=30&useSSL=false&allowPublicKeyRetrieval=true&characterEncoding=UTF-8'
the key is prefix ? char
then exec
/opt/jboss/keycloak/bin/standalone.sh \
-Djboss.socket.binding.port-offset=100 -Dkeycloak.migration.action=export \
-Dkeycloak.migration.provider=singleFile \
-Dkeycloak.migration.realmName=my_realm\
-Dkeycloak.migration.usersExportStrategy=REALM_FILE \
-Dkeycloak.migration.file=/tmp/my_realm-realm.json
everything is OK!
I correctly start server:
~/Downloads/neo4j-community-3.2.1/bin $ ./neo4j start Active database:
graph.db Directories in use: home:
/home/user/Downloads/neo4j-community-3.2.1 config:
/home/user/Downloads/neo4j-community-3.2.1/conf logs:
/home/user/Downloads/neo4j-community-3.2.1/logs plugins:
/home/user/Downloads/neo4j-community-3.2.1/plugins import:
/home/user/Downloads/neo4j-community-3.2.1/import data:
/home/user/Downloads/neo4j-community-3.2.1/data certificates:
/home/user/Downloads/neo4j-community-3.2.1/certificates run:
/home/user/Downloads/neo4j-community-3.2.1/run Starting Neo4j.
WARNING: Max 1024 open files allowed, minimum of 40000 recommended.
See the Neo4j manual. Started neo4j (pid 29246). It is available at
http://localhost:7474/ There may be a short delay until the server is
ready. See /home/user/Downloads/neo4j-community-3.2.1/logs/neo4j.log
for current status.
then when I try to launch the neo4j-shell:
~/Downloads/neo4j-community-3.2.1/bin $ ./neo4j-shell -v ERROR (-v for expanded information): Connection
refused java.rmi.ConnectException: Connection refused to host:
localhost; nested exception is: java.net.ConnectException:
Connection refused at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at
sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342) at
sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at
java.rmi.Naming.lookup(Naming.java:101) at
org.neo4j.shell.impl.RmiLocation.getBoundObject(RmiLocation.java:191)
at
org.neo4j.shell.impl.RemoteClient.findRemoteServer(RemoteClient.java:72)
at org.neo4j.shell.impl.RemoteClient.(RemoteClient.java:65) at
org.neo4j.shell.impl.RemoteClient.(RemoteClient.java:46) at
org.neo4j.shell.ShellLobby.newClient(ShellLobby.java:204) at
org.neo4j.shell.StartClient.startRemote(StartClient.java:358) at
org.neo4j.shell.StartClient.start(StartClient.java:229) at
org.neo4j.shell.StartClient.main(StartClient.java:147) Caused by:
java.net.ConnectException: Connection refused at
java.net.PlainSocketImpl.socketConnect(Native Method) at
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at
java.net.Socket.connect(Socket.java:589) at
java.net.Socket.connect(Socket.java:538) at
java.net.Socket.(Socket.java:434) at
java.net.Socket.(Socket.java:211) at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 13 more
-host Domain name or IP of host to connect to (default:
localhost) -port Port of host to connect to (default: 1337)
-name RMI name, i.e. rmi://:/ (default: shell) -pid Process ID to connect to -c Command line to execute. After executing it the shell exits -file File
containing commands to execute, or '-' to read from stdin. After
executing it the shell exits -readonly Connect in readonly mode
(only for connecting with -path) -path Points to a neo4j db path
so that a local server can be started there -config Points to a
config file when starting a local server
Example arguments for remote: -port 1337 -host 192.168.1.234 -port
1337 -name shell -host localhost -readonly ...or no arguments for
default values Example arguments for local: -path /path/to/db -path
/path/to/db -config /path/to/neo4j.config -path /path/to/db -readonly
the server is in its default initial configuration, the only thing I changed is the graph username and password.
neo4j-shell is deprecated since version 3.1, you should use cypher-shell instead.
But you can enable it by adding this configuration : dbms.shell.enabled=true
Cheers.
I have configured a cassandra node on my mac book pro using docker as follows
VBoxManage modifyvm "default" --natpf1 "tcp-port7191,tcp,,7191,,7191"
VBoxManage modifyvm "default" --natpf1 "tcp-port7000,tcp,,7000,,7000"
VBoxManage modifyvm "default" --natpf1 "tcp-port7001,tcp,,7001,,7001"
VBoxManage modifyvm "default" --natpf1 "tcp-port9160,tcp,,7160,,7160"
VBoxManage modifyvm "default" --natpf1 "tcp-port9042,tcp,,9042,,9042"
(restart machine)
docker run --name c1 -v /Users/MyProjects/scripts/:/script -d cassandra:latest -p "7191:7191" -p "7000:7000" -p "7001:7001" -p "9160:9160" -p "9042:9042"
I can easily do
docker exec -it c1 cqlsh
it says
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.1 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
Now I get the IP address of my virtual box vm using
docker-machine env default
I can see the IP address of 192.168.99.100
But when I run my java program to connect to the same cassandra instance using the IP address above. I get an error
00:00:56.611 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Connection - Connection[/192.168.99.100:9042-1, inFlight=0, closed=false] Error connecting to /192.168.99.100:9042 (Connection refused: /192.168.99.100:9042)
00:00:56.615 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Host.STATES - Defuncting Connection[/192.168.99.100:9042-1, inFlight=0, closed=false] because: [/192.168.99.100] Cannot connect
00:00:56.616 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Connection - Connection[/192.168.99.100:9042-1, inFlight=0, closed=true] closing connection
00:00:56.617 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Host.STATES - [/192.168.99.100:9042] preventing new connections for the next 1000 ms
00:00:56.617 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Host.STATES - [/192.168.99.100:9042] Connection[/192.168.99.100:9042-1, inFlight=0, closed=true] failed, remaining = 0
00:00:56.624 [run-main-0] DEBUG c.d.driver.core.ControlConnection - [Control connection] error on /192.168.99.100:9042 connection, no more host to try
com.datastax.driver.core.exceptions.TransportException: [/192.168.99.100] Cannot connect
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:157) ~[cassandra-driver-core-3.0.0.jar:na]
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:140) ~[cassandra-driver-core-3.0.0.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:603) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:563) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:424) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:276) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:292) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at java.lang.Thread.run(Thread.java:745) ~[na:1.7.0_79]
Caused by: java.net.ConnectException: Connection refused: /192.168.99.100:9042
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.7.0_79]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) ~[na:1.7.0_79]
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:289) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
... 6 common frames omitted
00:00:56.625 [run-main-0] DEBUG com.datastax.driver.core.Cluster - Shutting down
[error] (run-main-0) java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at com.abhi.connector.CassandraConnector$class.$init$(CassandraConnector.scala:8)
at com.abhi.models.Movies$.<init>(Movies.scala:25)
at com.abhi.models.Movies$.<clinit>(Movies.scala)
at com.abhi.MovieLensDataPreperation$$anonfun$storeInCassandra$1.apply(MovieLensDataPreperation.scala:55)
at com.abhi.MovieLensDataPreperation$$anonfun$storeInCassandra$1.apply(MovieLensDataPreperation.scala:55)
at scala.collection.immutable.List.foreach(List.scala:381)
at com.abhi.MovieLensDataPreperation$.storeInCassandra(MovieLensDataPreperation.scala:55)
at com.abhi.MovieLensDataPreperation$.main(MovieLensDataPreperation.scala:51)
at com.abhi.MovieLensDataPreperation.main(MovieLensDataPreperation.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.99.100:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.99.100] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:231)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:77)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1414)
at com.datastax.driver.core.Cluster.init(Cluster.java:162)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:333)
at com.datastax.driver.core.Cluster.connect(Cluster.java:283)
at com.abhi.connector.Connector$.<init>(CassandraConnector.scala:22)
at com.abhi.connector.Connector$.<clinit>(CassandraConnector.scala)
at com.abhi.connector.CassandraConnector$class.$init$(CassandraConnector.scala:8)
at com.abhi.models.Movies$.<init>(Movies.scala:25)
at com.abhi.models.Movies$.<clinit>(Movies.scala)
at com.abhi.MovieLensDataPreperation$$anonfun$storeInCassandra$1.apply(MovieLensDataPreperation.scala:55)
at com.abhi.MovieLensDataPreperation$$anonfun$storeInCassandra$1.apply(MovieLensDataPreperation.scala:55)
at scala.collection.immutable.List.foreach(List.scala:381)
at com.abhi.MovieLensDataPreperation$.storeInCassandra(MovieLensDataPreperation.scala:55)
at com.abhi.MovieLensDataPreperation$.main(MovieLensDataPreperation.scala:51)
at com.abhi.MovieLensDataPreperation.main(MovieLensDataPreperation.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
This is my code to configure the java connection
Cluster.builder()
.addContactPoints("192.168.99.100").withPort(9042)
.build()
Edit: I also replaced the above IP address with the IP address of docker guest VM... but that did not resolve the issue.
I was able to solve the problem by using CASSANDRA_BROADCAST_ADDRESS when creating the docker container
This is the command I used
docker run --name c1 -v /Users/MyProjects/scripts/:/script -d -p "7191:7191"
-p "7000:7000" -p "7001:7001" -p "9160:9160" -p "9042:9042" -e
CASSANDRA_BROADCAST_ADDRESS=192.168.99.100 cassandra:latest
After creating the container like this. I am able to connect from my Scala application with this code
val keyspace: KeySpace = new KeySpace("foo")
val cluster =
Cluster.builder()
.addContactPoint("192.168.99.100").withPort(9042)
.build()
cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(100000);
val session: Session = cluster.connect(keyspace.name)