keycloak / keycloak

Open Source Identity and Access Management For Modern Applications and Services
https://www.keycloak.org
Apache License 2.0
23.44k stars 6.77k forks source link

Keycloak won't start on Windows environment #23202

Closed gensart-ai closed 1 year ago

gensart-ai commented 1 year ago

Before reporting an issue

Area

core

Describe the bug

When I ran kc.bat start-dev on the Windows environment, it returned the error below. I have searched in completed issues and believe that there are some solutions but I haven't found any clear instructions to solve it. Any help may be appreciated, Thanks.

C:\keycloak-22.0.3\bin>kc.bat start-dev
2023-09-13 16:48:29,987 INFO  [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: Base URL: <unset>, Hostname: <request>, Strict HTTPS: false, Path: <request>, Strict BackChannel: false, Admin URL: <unset>, Admin: <request>, Port: -1, Proxied: false
2023-09-13 16:48:34,085 WARN  [io.quarkus.agroal.runtime.DataSources] (main) Datasource <default> enables XA but transaction recovery is not enabled. Please enable transaction recovery by setting quarkus.transaction-manager.enable-recovery=true, otherwise data may be lost if the application is terminated abruptly
2023-09-13 16:48:37,225 WARN  [org.infinispan.PERSISTENCE] (keycloak-cache-init) ISPN000554: jboss-marshalling is deprecated and planned for removal
2023-09-13 16:48:37,396 WARN  [org.infinispan.CONFIG] (keycloak-cache-init) ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
2023-09-13 16:48:37,542 INFO  [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000556: Starting user marshaller 'org.infinispan.jboss.marshalling.core.JBossUserMarshaller'
2023-09-13 16:48:39,260 WARN  [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator] (JPA Startup Thread) HHH000342: Could not obtain connection to query metadata: java.sql.SQLException: Acquisition timeout while waiting for new connection
        at io.agroal.pool.ConnectionPool.handlerFromSharedCache(ConnectionPool.java:321)
        at io.agroal.pool.ConnectionPool.getConnection(ConnectionPool.java:249)
        at io.agroal.pool.DataSource.getConnection(DataSource.java:86)
        at io.quarkus.hibernate.orm.runtime.customized.QuarkusConnectionProvider.getConnection(QuarkusConnectionProvider.java:23)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:316)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:152)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:34)
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:119)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:239)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:216)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:45)
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:125)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:248)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:216)
        at org.hibernate.boot.internal.SessionFactoryOptionsBuilder.<init>(SessionFactoryOptionsBuilder.java:274)
        at io.quarkus.hibernate.orm.runtime.recording.PrevalidatedQuarkusMetadata.buildSessionFactoryOptionsBuilder(PrevalidatedQuarkusMetadata.java:70)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:81)
        at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:74)
        at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
        at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:156)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:64)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.util.concurrent.TimeoutException
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
        at io.agroal.pool.ConnectionPool.handlerFromSharedCache(ConnectionPool.java:298)
        ... 23 more

2023-09-13 16:48:40,365 INFO  [org.keycloak.connections.infinispan.DefaultInfinispanConnectionProviderFactory] (main) Node name: node_796215, Site name: null
2023-09-13 16:48:40,372 INFO  [org.keycloak.broker.provider.AbstractIdentityProviderMapper] (main) Registering class org.keycloak.broker.provider.mappersync.ConfigSyncEventListener
2023-09-13 16:48:45,445 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (development) mode
2023-09-13 16:48:45,446 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to obtain JDBC connection
2023-09-13 16:48:45,447 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Acquisition timeout while waiting for new connection
2023-09-13 16:48:45,448 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.
C:\keycloak-22.0.3\bin>

Version

22.0.3

Expected behavior

Rans perfectly

Actual behavior

Returns the error I have shown.

How to Reproduce?

Run kc.bat start-dev

Anything else?

No response

gensart-ai commented 1 year ago

Sorry for the inconvenience issue I've made, I don't know which area will match in the selection with my issue.

FYI. I'm using Windows 10 with OpenJDK version "17"

mabartos commented 1 year ago

I was able to start the server on a Windows machine with OpenJDK 17.

Does it happen all the time during the startup? Have you made any changes there?

The execution of the kc.bat --verbose start-dev should reveal more details.

image

sschu commented 1 year ago

@gensart-ai Are you using some kind of VPN? Some people seem to have problems since the VPN adapter is used to connect to the H2 database.

gensart-ai commented 1 year ago

Hi guys, thanks for your attention. I was able to solve it by restarting my Windows, image

I don't know what solves it but after I restart, it works. image

I'm closing the issue.

gensart-ai commented 1 year ago

I know what Keycloak caused a problem in my machine, it was because of the H2 database, it didn't work on mine, so I tried to change the data source to MySQL/MariaDB, and it runs perfectly, yeah just FYI.

For the configuration, I change the configs in: <Keycloak Base Folder>\conf\keycloak.conf to :

# Database

# The database vendor.
db=mariadb

# The username of the database user.
db-username=root

# The password of the database user.
db-password=

# The full database JDBC URL. If not provided, a default URL is set based on the selected database vendor.
db-url=jdbc:mariadb://localhost:3306/keycloak?user=root&password=

I commenting on this maybe Keycloak newcomers in the future have the same problem I've had.

Hexton09 commented 7 months ago

I know what Keycloak caused a problem in my machine, it was because of the H2 database, it didn't work on mine, so I tried to change the data source to MySQL/MariaDB, and it runs perfectly, yeah just FYI.

For the configuration, I change the configs in: <Keycloak Base Folder>\conf\keycloak.conf to :

# Database

# The database vendor.
db=mariadb

# The username of the database user.
db-username=root

# The password of the database user.
db-password=

# The full database JDBC URL. If not provided, a default URL is set based on the selected database vendor.
db-url=jdbc:mariadb://localhost:3306/keycloak?user=root&password=

I commenting on this maybe Keycloak newcomers in the future have the same problem I've had.

hello , I'm also facing the same issue but unable to resolve it after using your method