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

DS-3571 Log hibernate validation errors #1772

Conversation

tomdesair
Copy link
Contributor

Problem

This problem was detected in DS-3571.

If there is a problem with the database schema (e.g. because of custom database modifications or a Flyway migration that was not executed due to incorrect config), the DSpace logs only output this:

2017-06-13 10:33:12,067 INFO  org.hibernate.tool.hbm2ddl.TableMetadata @ HHH000261: Table found: public.resourcepolicy
2017-06-13 10:33:12,068 INFO  org.hibernate.tool.hbm2ddl.TableMetadata @ HHH000037: Columns: [end_date, dspace_object, rptype, resource_type_id, policy_id, eperson_id, action_id, epersongroup_id, start_date_bkp, rpdescription, rpname, start_date]
2017-06-13 10:33:12,068 FATAL org.dspace.core.Context @ Cannot obtain the bean which provides a database connection. Check previous entries in the dspace.log to find why the db failed to initialize.

If you run a CLI script, you just see a NullPointerException printed on the console.

Solution

This PR adds information on the validation error:

  • In the logs:
2017-06-13 10:52:13,087 INFO  org.hibernate.tool.hbm2ddl.TableMetadata @ HHH000261: Table found: public.resourcepolicy
2017-06-13 10:52:13,088 INFO  org.hibernate.tool.hbm2ddl.TableMetadata @ HHH000037: Columns: [end_date, dspace_object, rptype, resource_type_id, policy_id, eperson_id, action_id, epersongroup_id, start_date_bkp, rpdescription, rpname, start_date]
2017-06-13 10:52:13,088 FATAL org.dspace.core.Context @ Cannot obtain the bean which provides a database connection. Check previous entries in the dspace.log to find why the db failed to initialize. The schema validator returned: Wrong column type in public.resourcepolicy for column start_date. Found: timestamp, expected: date
  • On the CLI:
INFO: Using dspace provided log configuration (log.init.config)
INFO: Loading: .../dspace6/config/log4j.properties
Exception: The schema validator returned: Wrong column type in public.resourcepolicy for column start_date. Found: timestamp, expected: date
org.dspace.core.exception.DatabaseSchemaValidationException: The schema validator returned: Wrong column type in public.resourcepolicy for column start_date. Found: timestamp, expected: date
	at org.dspace.core.Context.init(Context.java:170)
	at org.dspace.core.Context.<init>(Context.java:138)

Testing

Before starting Tomcat or any other CLI statement, update the DSpace database schema, e.g. alter table resourcepolicy alter column start_date type timestamp;

Then start Tomcat or run a DSpace CLI command. You should see an error describing why the database connection failed to start.

@tdonohue tdonohue added code task Code cleanup task quick win Pull request is small in size & should be easy to review and/or merge labels Jun 13, 2017
@tdonohue tdonohue added this to the 6.1 milestone Jun 13, 2017
Copy link
Member

@hardyoyo hardyoyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in Vagrant-DSpace, it's a nice improvement, however, it doesn't really address DS-3571, though it is helpful in that regard. I like this PR very much, though, and it's the kind of thing we need more of, so I'm approving it as-is.

@hardyoyo
Copy link
Member

If we merge this into 6x, we'll need to port it forward to master.

@terrywbrady terrywbrady self-requested a review June 27, 2017 22:20
Copy link
Contributor

@terrywbrady terrywbrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, verified locally using tomcat restart (rather than CLI)

@terrywbrady
Copy link
Contributor

@tomdesair , thank you for the clear instructions for testing. They were very helpful.

@terrywbrady terrywbrady merged commit fd298ae into DSpace:dspace-6_x Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code task Code cleanup task quick win Pull request is small in size & should be easy to review and/or merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants