kitodo / kitodo-production

Kitodo.Production is a workflow management tool for mass digitization and is part of the Kitodo Digital Library Suite.
http://www.kitodo.org/software/kitodoproduction/
GNU General Public License v3.0
62 stars 63 forks source link

3.0-alpha2: Unhandled exception by hibernate when trying to login #1826

Closed funkyfuture closed 5 years ago

funkyfuture commented 5 years ago

i have a demo setup running as described in the documentation. when i try to login into a running instance, the following is logged by kitodo (the MySQL server doesn't log on that occasion):

[ERROR] 2018-09-19 10:59:23.466 [http-nio-8080-exec-1] HibernateUtil - org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [authority]
[ERROR] 2018-09-19 10:59:23.775 [http-nio-8080-exec-1] HibernateUtil - org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
[ERROR] 2018-09-19 10:59:23.778 [http-nio-8080-exec-1] UsernamePasswordAuthenticationFilter - An internal error occurred while trying to authenticate the user.
org.springframework.security.authentication.InternalAuthenticationServiceException
     at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:126) ~[spring-security-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:144) ~[spring-security-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.kitodo.security.DynamicAuthenticationProvider.authenticate(DynamicAuthenticationProvider.java:69) ~[classes/:3.0.0-alpha.2]
     at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:174) ~[spring-security-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:199) ~[spring-security-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:94) ~[spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE]
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE]
     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE]
     at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) [spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE]
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.34]
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.34]
     at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) [log4j-web-2.6.2.jar:2.6.2]
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.34]
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.34]
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [catalina.jar:8.5.34]
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.34]
     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) [catalina.jar:8.5.34]
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.34]
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.34]
     at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) [catalina.jar:8.5.34]
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.34]
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:8.5.34]
     at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) [tomcat-coyote.jar:8.5.34]
     at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.34]
     at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) [tomcat-coyote.jar:8.5.34]
     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) [tomcat-coyote.jar:8.5.34]
     at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.34]
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171]
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171]
     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.34]
     at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
Caused by: java.lang.NullPointerException
     at org.kitodo.data.database.persistence.HibernateUtil.getSession(HibernateUtil.java:43) ~[kitodo-data-management-3.0.0-alpha.2.jar:?]
     at org.kitodo.data.database.helper.HibernateHelper.getHibernateSession(HibernateHelper.java:66) ~[kitodo-data-management-3.0.0-alpha.2.jar:?]
     at org.kitodo.data.database.persistence.BaseDAO.retrieveObjects(BaseDAO.java:270) ~[kitodo-data-management-3.0.0-alpha.2.jar:?]
     at org.kitodo.data.database.persistence.UserDAO.search(UserDAO.java:78) ~[kitodo-data-management-3.0.0-alpha.2.jar:?]
     at org.kitodo.services.data.UserService.getByQuery(UserService.java:286) ~[classes/:3.0.0-alpha.2]
     at org.kitodo.services.data.UserService.getByLoginQuery(UserService.java:233) ~[classes/:3.0.0-alpha.2]
     at org.kitodo.services.data.UserService.getByLogin(UserService.java:218) ~[classes/:3.0.0-alpha.2]
     at org.kitodo.services.data.UserService.loadUserByUsername(UserService.java:116) ~[classes/:3.0.0-alpha.2]
     at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:114) ~[spring-security-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
     ... 43 more

inspecting the database seems to yield expected results:

MySQL [kitodo]> describe authority;
+-------------------+--------------+------+-----+---------+----------------+
| Field             | Type         | Null | Key | Default | Extra          |
+-------------------+--------------+------+-----+---------+----------------+
| id                | int(11)      | NO   | PRI | NULL    | auto_increment |
| title             | varchar(255) | NO   | UNI | NULL    |                |
| indexAction       | varchar(6)   | YES  |     | NULL    |                |
| globalAssignable  | tinyint(1)   | YES  |     | 1       |                |
| clientAssignable  | tinyint(1)   | YES  |     | 1       |                |
| projectAssignable | tinyint(1)   | YES  |     | 1       |                |
+-------------------+--------------+------+-----+---------+----------------+
6 rows in set (0.11 sec)

MySQL [kitodo]> show grants for kitodo;
+----------------------------------------------------+
| Grants for kitodo@%                                |
+----------------------------------------------------+
| GRANT USAGE ON *.* TO 'kitodo'@'%'                 |
| GRANT ALL PRIVILEGES ON `kitodo`.* TO 'kitodo'@'%' |
+----------------------------------------------------+
2 rows in set (0.08 sec)
beatrycze-volk commented 5 years ago

hi, do you have also correct set up of your mapping in hibernate.cfg.xml?

funkyfuture commented 5 years ago

i don't know what mapping refers to in this context, here's a snippet of webapps/kitodo/WEB-INF/classes/hibernate.cfg.xml w/ the connection setttings.

    <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
    <property name="hibernate.dialect.storage_engine">innodb</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://mysql/?useSSL=false</property>
    <property name="hibernate.connection.username">kitodo</property>
    <property name="hibernate.connection.password">mysql_kitodo_pass</property>
    <property name="hibernate.connection.autoReconnect">true</property>
    <property name="hibernate.connection.autoReconnectForPools">true</property>
    <!-- SSL connection properties -->
    <property name="hibernate.connection.requireSSL">false</property>

yes, the hostname is mysql.

beatrycze-volk commented 5 years ago

Is this part missing?

`

`

funkyfuture commented 5 years ago

following the comment <!-- Die einzelnen Mappings --> there are these elements, additionaly w/ …..UserGroupClientAuthorityRelation and ….UserGroupProjectAuthorityRelation.

beatrycze-volk commented 5 years ago

So there is not missing mapping for Authority table and table is inserted to database? Do you have code from current master or exactly this version: https://github.com/kitodo/kitodo-production/releases/tag/kitodo-production-3.0.0-alpha.2 ?

funkyfuture commented 5 years ago

yep, the tagged release.

funkyfuture commented 5 years ago

i extended my inital answer. sorry for the mistake.

Erikmitk commented 5 years ago

Are you using a pre-configured user account or a new one?

funkyfuture commented 5 years ago

i try to use the preconfigured one. the contributed dump had been loaded to the database and i try to login as testAdmin like described in the installation docs.

Erikmitk commented 5 years ago

We thought about this but cannot yet reproduce your error. The exception hints that the database connection cannot be established. It cannot find the table authority although it's clearly there if you look in the database itself. So Hibernate is looking at the wrong place and returns empty handed.

That means the problem must be within the hibernate.cfg.xml. You said you modified the config with your database connection details. But maybe that's the problem.

Are you deploying the .war-file from the release and then change the hibernate.cfg.xml directly in the webapps folder? Our guess would be that this configuration file will not be used if modified that way since the application is already deployed and those changes are not considered by the server.

Could you try to stop Tomcat, change the config inside the war (or change it in the release source + recompile) and start Tomcat up again? Does this fix your problem?

henning-gerhardt commented 5 years ago

Are you deploying the .war-file from the release and then change the hibernate.cfg.xml directly in the webapps folder? Our guess would be that this configuration file will not be used if modified that way since the application is already deployed and those changes are not considered by the server.

There are only a few configuration files which are only read on Tomcat start and not later again. It should help to restart the Tomcat service after hibernate configuration file is modified.

funkyfuture commented 5 years ago

thanks for your investigation. my mistake was to forget the database's name in the hibernate configuration (see snippet above). i think it would be user-friendly to test that configuration value and the connection to the database at startup with some human-targeted output in case of problems.