Spring Boot App Freezes on Startup
Asked Answered
S

4

10

I have a Spring Boot App using an Oracle Data source that is freezing on startup. The last messages outputted on the console are:

[2017-12-18T15:34:19,425] INFO  org.hibernate.dialect.Dialect HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect 
[2017-12-18T15:34:27,186] INFO  org.hibernate.hql.internal.QueryTranslatorFactoryInitiator HHH000397: Using ASTQueryTranslatorFactory 

After that it just hangs indefinitely. No more debug messages are outputted, and nothing happens. I've let it sit there for hours, but nothing.

The weird thing is that everything was working fine. No changes were made. All of a sudden this started happening, and I have no idea why it's just freezing.

September answered 18/12, 2017 at 20:36 Comment(3)
It is possible that the database you are trying to connect to is not available. See IssuePhilologian
I can connect to the database manually, so it is available.September
I had the same issue. I'm 90% sure that this because of JPA-related bean autowiring but I am still fighting this, maybe some spring guru can give me any hintsJumble
K
6

It's hard to tell what happens out of the information you've provided, I can just propose a couple of things that can shed some light on whats going on:

  1. Try to take thread dump and see what exactly does each thread do. If you will take some thread dumps and will see that thread that looks relevant is stuck somewhere you'll probably be able to better understand the reason from the stacktrace.

  2. Enable logs for DEBUG, you say that no debug messages appear, but in the snippet, you've shown only a couple of INFO messages. You can probably start with setting spring and hibernate logs for DEBUG.

  3. Try to connect to the empty database - maybe it tries to read something during the initialization (stuff like metadata) and it takes too long (although I don't believe it should take hours), but still...

  4. You can try to see which SQLs are being executed during the startup. Just set hibernate's "show sql" property to true and maybe it will help

  5. You can also place a breakpoint in spring to see which bean gets stuck and try to understand out of its code whats going on (I know its a little bit vague, but the point is to find which bean fails to start and just debug it).

Kathaleenkatharevusa answered 18/12, 2017 at 21:3 Comment(3)
Sorry, I should've clarified more. I do have the root logger set to DEBUG, there just are no debug level messages being outputted at this time. The database actually is empty. It's a brand new database. I also have hibernate sql tracing on, but no SQL is being executed. I did try to debug through Spring, but I haven't found any place where it is actually getting "stuck".September
Yeah, nothing suspect came out of it though. HOWEVER, I did just notice that there is something that is swallowing all of the log statements after that last line. And from what I can tell, there is some sort of "infinite" loop going on trying to read the metadata, so something is wonky. I think I'm going to try to nuke the database and start again, even though it's fresh.September
Aha. So after dropping and re-creating the schema again, it worked. Also, my logging output was being swallowed because a transitive dependency all of a sudden decided to include slf4j-nop. I guess that binder was just binding to some packages, because some log output was coming out, just not any of the meaningful stuff.September
S
1

Try updating the following property in yaml or properties file!

spring.jpa.hibernate.ddl-auto=none
Smackdab answered 29/7, 2022 at 12:42 Comment(0)
E
0

I faced the same issue. My code got stuck with the last log as "HHH000397: Using ASTQueryTranslatorFactory".

I extracted the table create query and deleted the table for which the problem occurred from the DB and recreated it(using the query which I saved with no change) and that resolved my issue.

Do give it a try if this problem occurs during development phase.

Emersonemery answered 25/8, 2022 at 14:6 Comment(0)
E
0

I am very late, but below I commented the line by which it starts working as the same issue I was facing

#spring.jpa.generate-ddl=true
Elite answered 22/1 at 10:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.