Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullpointer at SchemaManagementIntegrator.disintegrate #20111

Closed
leonardowestphal opened this issue Sep 13, 2021 · 15 comments · Fixed by #20173
Closed

Nullpointer at SchemaManagementIntegrator.disintegrate #20111

leonardowestphal opened this issue Sep 13, 2021 · 15 comments · Fixed by #20173
Labels
area/hibernate-orm Hibernate ORM kind/bug Something isn't working
Milestone

Comments

@leonardowestphal
Copy link
Contributor

Describe the bug

I upgraded from version 2.1.2.Final to version 2.2.2.Final and now I got this error on Quarkus startup:

java.lang.NullPointerException
        at java.base/java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1111)
        at java.base/java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1102)
        at io.quarkus.hibernate.orm.runtime.schema.SchemaManagementIntegrator.disintegrate(SchemaManagementIntegrator.java:50)
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:410)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:71)
        at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:67)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:149)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:58)
        at java.base/java.lang.Thread.run(Thread.java:829)

I'm using 2 persistences units with postgres Database. Example:

quarkus.datasource."PU1".db-kind=postgresql
quarkus.datasource."PU1".username=<username>
quarkus.datasource."PU1".password=<password>
quarkus.datasource."PU1".jdbc.url=jdbc:postgresql://<ip>:<port>/<db_name>

# Persistence Unit PU1
quarkus.hibernate-orm."PU1".datasource=PU1
quarkus.hibernate-orm."PU1".database.default-schema=<schema>
quarkus.hibernate-orm."PU1".discriminator.ignore-explicit-for-joined=true
quarkus.hibernate-orm."PU1".dialect=<custom_dialect>
quarkus.hibernate-orm."PU1".fetch.max-depth=1
quarkus.hibernate-orm."PU1".packages=<package>


quarkus.datasource."PU2".db-kind=postgresql
quarkus.datasource."PU2".username=<username>
quarkus.datasource."PU2".password=<password>
quarkus.datasource."PU2".jdbc.url=jdbc:postgresql://<ip>:<port>/<db_name>

# Persistence Unit PU2
quarkus.hibernate-orm."PU2".datasource=PU2
quarkus.hibernate-orm."PU2".database.default-schema=<schema>
quarkus.hibernate-orm."PU2".discriminator.ignore-explicit-for-joined=true
quarkus.hibernate-orm."PU2".dialect=<custom_dialect>
quarkus.hibernate-orm."PU2".fetch.max-depth=1
quarkus.hibernate-orm."PU2".packages=<package>

I'm using cache. Example:

quarkus.hibernate-orm."PU1".cache."<name>".expiration.max-idle=300
quarkus.hibernate-orm."PU1".cache."<name>".memory.object-count=250000
quarkus.hibernate-orm."PU2".cache."<name>".expiration.max-idle=300
quarkus.hibernate-orm."PU2".cache."<name>".memory.object-count=250000

Almost all objects attributes on method 'SchemaManagementIntegrator.disintegrate' are empty or with their default values :

public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
        metadataMap.remove(nameCache.get(sessionFactory));
        nameCache.remove(sessionFactory);
    }

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

openjdk version "11.0.11"

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1

Additional information

No response

@leonardowestphal leonardowestphal added the kind/bug Something isn't working label Sep 13, 2021
@leonardowestphal
Copy link
Contributor Author

@Sanne
Do you have any idea what it might be?

@leonardowestphal
Copy link
Contributor Author

All Stack:

java.lang.NullPointerException
	at java.base/java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1111)
	at java.base/java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1102)
	at io.quarkus.hibernate.orm.runtime.schema.SchemaManagementIntegrator.disintegrate(SchemaManagementIntegrator.java:50)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:410)
	at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:71)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:67)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
	at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:149)
	at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:58)
	at java.base/java.lang.Thread.run(Thread.java:829)
Resulted in: javax.persistence.PersistenceException: [PersistenceUnit: PU1] Unable to build Hibernate SessionFactory
	at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.persistenceException(FastBootEntityManagerFactoryBuilder.java:113)
	at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:73)
	... 6 more
Resulted in: java.lang.RuntimeException: javax.persistence.PersistenceException: [PersistenceUnit: PU1] Unable to build Hibernate SessionFactory
	at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:72)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll$$superforward1(JPAConfig_Subclass.zig:296)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass$$function$$6.apply(JPAConfig_Subclass$$function$$6.zig:24)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at io.quarkus.hibernate.orm.runtime.JPAConfig_Subclass.startAll(JPAConfig_Subclass.zig:794)
	at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:96)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits1868654632.deploy_0(HibernateOrmProcessor$startPersistenceUnits1868654632.zig:74)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits1868654632.deploy(HibernateOrmProcessor$startPersistenceUnits1868654632.zig:40)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:963)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:101)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:98)
	... 1 more
Resulted in: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:1100)
	... 12 more
Resulted in: java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:51)
	at io.quarkus.runner.bootstrap.StartupActionImpl.runMainClass(StartupActionImpl.java:109)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.restartApp(IsolatedDevModeMain.java:227)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.restartCallback(IsolatedDevModeMain.java:208)
	at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:499)
	at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:399)
	at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$4.handle(VertxHttpHotReplacementSetup.java:151)
	at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$4.handle(VertxHttpHotReplacementSetup.java:139)
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	... 1 more	

@Sanne
Copy link
Member

Sanne commented Sep 13, 2021

hi @leonardowestphal , thanks for the report! yes I can see a simple mistake :)

will fix it soon.

@leonardowestphal
Copy link
Contributor Author

@Sanne
Thanks!

@Sanne
Copy link
Member

Sanne commented Sep 13, 2021

actually while I can see how that could theoretically produce an NPE, I'm not able to reproduce this.

Do you think you could contribute an integration test please?

@Sanne
Copy link
Member

Sanne commented Sep 13, 2021

Maybe I just need more details from your configuration. Is your SessionFactory named in some way?

@quarkus-bot
Copy link

quarkus-bot bot commented Sep 13, 2021

/cc @Sanne, @gsmet, @yrodiere

@Sanne
Copy link
Member

Sanne commented Sep 13, 2021

I've pushed a sketch here : - https://github.com/quarkusio/quarkus/compare/main...Sanne:SchemaManagementIntegration?expand=1

Would rally like to be able to reproduce it before sending a PR though. Going to sleep, let's look at it with a fresh mind tomorrow :)

@leonardowestphal
Copy link
Contributor Author

leonardowestphal commented Sep 14, 2021

Maybe I just need more details from your configuration. Is your SessionFactory named in some way?

It's not named. The datasource and hibernate configurations in my application.properties are the same as in the example of this issue.

Other Settings I have in Dev mode:

quarkus.http.port=8083
quarkus.hibernate-orm.statistics=true
quarkus.index-dependency.<name>.group-id=
quarkus.index-dependency.<name>.artifact-id=
quarkus.index-dependency.<name>.classifier=
quarkus.swagger-ui.doc-expansion=none
quarkus.swagger-ui.theme=original
quarkus.swagger-ui.always-include=true
quarkus.datasource.health.enabled=false

@leonardowestphal
Copy link
Contributor Author

I've pushed a sketch here : - https://github.com/quarkusio/quarkus/compare/main...Sanne:SchemaManagementIntegration?expand=1

Would rally like to be able to reproduce it before sending a PR though. Going to sleep, let's look at it with a fresh mind tomorrow :)

I didn't understand why it goes into this method. Maybe if you give me more details I can help you to reproduce it. I didn't have time to investigate, sorry...

@Sanne
Copy link
Member

Sanne commented Sep 14, 2021

No worries, I understand. I'll try to tinker a bit more with this, worse case we merge my little patch as it makes sense either way, and hopefully you'll be able to let me know it solved the problem after the next release.

@Sanne
Copy link
Member

Sanne commented Sep 15, 2021

@leonardowestphal does it happen only in "dev mode"?

@leonardowestphal
Copy link
Contributor Author

Hi @Sanne
I've tested it now and it only occurs in dev mode. Running the 'quarkus-run.jar' it works.

@Sanne
Copy link
Member

Sanne commented Sep 15, 2021

I still can't reproduce, I'll send my fix without a test. Thanks!

@leonardowestphal
Copy link
Contributor Author

Thanks!

@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Sep 15, 2021
@gsmet gsmet modified the milestones: 2.3.0.CR1, 2.2.4.Final Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants