Spring Boot, OpenShift3 JPA & Logging problem

111 Views Asked by At

I've deployed a simple Spring Boot web app on OpenShift platform.

Things look good and the app is reached on /, but once I introduce my first JPA Entity, I get redirected to the whitelabel error page.

What I did is I implemented a global error handler for all exceptions in hope of catching the error, but it does not catch this one which I assume it messes up the whole app deployment.

Once I remove my Entity, the app is back up, the error handler handles exception I threw for test.

I think connection to the DB is fine, because I found the table associated with my entity created.(postgresql & mysql tests).

The issue is I don't have much to work with, because the logs look clean, with no exceptions whatsoever.

Does anyone knows how to get Spring Boot to put logs on the pod it runs on? I previously mounted a persistent storage to my pod, had Spring redirect logs to a file on that pod. It ends up creating the file with 0kb.

I've got two questions:

  • How to log properly a Spring Boot app deployed on OS3?
  • Ideas about the Entity issue are welcome. I Hope to be able to provide more once I fix the logging.

Github of the app: https://github.com/iaissaoui/boot-app

1

There are 1 best solutions below

0
On

I'm back with a partial answer to this question:

I was able to finally use a JPA Repo and save an entity to my DB. The problem as suggested by many posts online seems to be related to the annotations I used.

This is my project structure:

    +---java
|   \---bootwildfly
|       |   Application.java
|       |
|       \---app
|           |   GlobalExceptionHandler.java
|           |
|           +---controller
|           |       WildFlyController.java
|           |
|           +---model
|           |       AppUser.java
|           |
|           \---repo
|                   AppUserRepo.java
|
+---resources
|       application.properties
|
\---webapp
    \---WEB-INF
            errorpage.jsp
            slash.jsp

I used @ComponentScan & @EnableJpaRepositories in the main Spring Boot App class at first:

@ComponentScan("bootwildfly.app.model")
@EnableJpaRepositories("bootwildfly.app.repo")

I noticed that specifying the exact package was causing the issue, so I switched to simple annotations:

@ComponentScan
@EnableJpaRepositories

In this case, I know it will work because my packages are below the App class. I still don't know however why specifying the package is causing trouble.