A database error has occurred, when checking the permissions
Asked by Mo:

Hi,

When we try to check the permissions on the project level or repository level we get the error: A database error has occurred.

Bitbucket Version: Atlassian Bitbucket v8.10.2

GET call:

[https://git.\*\*\*\*\*\*/rest/api/latest/projects/\*\*\*\*\*/repos/bitbucket-scripts/permissions/search?start=0\&limit=25\&avatarSize=48](https://git.******/rest/api/latest/projects/*****/repos/bitbucket-scripts/permissions/search?start=0&limit=25&avatarSize=48)

Return 500

tail -f /bitbucket/application-data/log/atlassian-bitbucket.log:

org.hibernate.InstantiationException: Cannot instantiate abstract class or interface: : com.atlassian.stash.internal.user.InternalApplicationUser  
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:79)  
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:105)  
at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:705)  
at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:5295)  
at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1643)  
at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1627)  
at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.hydrateEntityState(EntityReferenceInitializerImpl.java:25 5)  
at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:80)  
at org.hibernate.loader.plan.exec.internal.EntityLoadQueryDetails$EntityLoaderRowReader.readRow(EntityLoadQueryDetails.java:288)  
at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractRows(ResultSetProcessorImpl.java:157)  
at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:94)  
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:105)  
at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:285)  
at org.hibernate.persister.entity.AbstractEntityPersister.doLoad(AbstractEntityPersister.java:4521)  
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4511)  
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:571)  
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:539)  
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:208)  
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:103)  
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:74)  
at com.atlassian.stash.internal.hibernate.EntityEnrichingLoadListener.onLoad(EntityEnrichingLoadListener.java:83)  
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:118)  
at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1231)  
at org.hibernate.internal.SessionImpl.immediateLoad(SessionImpl.java:1043)  
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:185)  
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:322)  
at com.atlassian.stash.internal.HibernateUtils.unwrap(HibernateUtils.java:197)  
at com.atlassian.stash.internal.HibernateUtils.initialize(HibernateUtils.java:86)  
at com.atlassian.stash.internal.user.InternalPermittedPrincipal.initialize(InternalPermittedPrincipal.java:77)  
at com.atlassian.stash.internal.HibernateUtils.initialize(HibernateUtils.java:88)  
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)  
at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)  
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)  
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)  
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)  
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)  
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)  
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)  
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)  
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)  
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)  
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)  
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)  
at com.atlassian.bitbucket.util.PageImpl.transform(PageImpl.java:147)  
at com.atlassian.bitbucket.util.PageImpl.transform(PageImpl.java:16)  
at com.atlassian.stash.internal.HibernateUtils.initializePage(HibernateUtils.java:122)  
at com.atlassian.stash.internal.user.HibernateProjectPermissionDao.findPrincipalsWithAccess(HibernateProjectPermissionDao.java:134)  
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 jdk.internal.reflect.GeneratedMethodAccessor223.invoke(Unknown Source)  
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at com.atlassian.stash.internal.user.DefaultPermissionAdminService$5.visit(DefaultPermissionAdminService.java:806)  
at com.atlassian.stash.internal.user.DefaultPermissionAdminService$5.visit(DefaultPermissionAdminService.java:801)  
at com.atlassian.bitbucket.dmz.user.PermittedPrincipalProjectSearchRequest.accept(PermittedPrincipalProjectSearchRequest.java:32)  
at com.atlassian.stash.internal.user.DefaultPermissionAdminService.searchPrincipals(DefaultPermissionAdminService.java:801)  
at jdk.internal.reflect.GeneratedMethodAccessor2425.invoke(Unknown Source)  
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at jdk.internal.reflect.GeneratedMethodAccessor223.invoke(Unknown Source)  
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at jdk.internal.reflect.GeneratedMethodAccessor2425.invoke(Unknown Source)  
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)  
at jdk.internal.reflect.GeneratedMethodAccessor2425.invoke(Unknown Source)  
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)  
at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)  
at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)  
at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)  
at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)  
at com.atlassian.stash.internal.rest.user.ProjectPermissionResource.searchPermissions(ProjectPermissionResource.java:533)  
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 com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
at com.atlassian.analytics.client.filter.UniversalAnalyticsFilter.doFilter(UniversalAnalyticsFilter.java:75)  
at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:33)  
at com.atlassian.bitbucket.internal.xcode.web.XcodeUserAgentFilter.doFilter(XcodeUserAgentFilter.java:36)  
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterM oduleContainerFilter.java:42)  
at com.atlassian.bitbucket.internal.ratelimit.servlet.filter.RateLimitFilter.doFilter(RateLimitFilter.java:75)  
at com.atlassian.plugin.connect.plugin.auth.scope.ApiScopingFilter.doFilter(ApiScopingFilter.java:81)  
at com.atlassian.plugins.slack.analytics.SlackAnalyticsFilter.doFilter(SlackAnalyticsFilter.java:35)  
at com.atlassian.troubleshooting.thready.filter.AbstractThreadNamingFilter.doFilter(AbstractThreadNamingFilter.java:46)  
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterM oduleContainerFilter.java:42)  
at com.atlassian.stash.internal.web.auth.AuthorizationFailureInterceptor.doFilterInternal(AuthorizationFailureInterceptor.java:39)  
at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:85)  
at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationF ilter.java:112)  
at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75)  
at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)  
at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)  
at com.atlassian.oauth2.provider.core.web.AccessTokenFilter.doFilter(AccessTokenFilter.java:81)  
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterM oduleContainerFilter.java:42)  
at com.atlassian.plugin.connect.plugin.auth.oauth2.DefaultSalAuthenticationFilter.doFilter(DefaultSalAuthenticationFilter.java:69)  
at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:109)  
at com.atlassian.plugins.authentication.basicauth.filter.DisableBasicAuthFilter.doFilter(DisableBasicAuthFilter.java:70)  
at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:37)  
at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:26)  
at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:33)  
at com.atlassian.troubleshooting.thready.filter.AbstractThreadNamingFilter.doFilter(AbstractThreadNamingFilter.java:46)  
at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterM oduleContainerFilter.java:42)  
at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFi lter.java:90)  
at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73)  
at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:84)  
at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38)  
at java.base/java.lang.Thread.run(Thread.java:829)  
... 334 frames trimmed


Answers:
author: Mario Siegenthaler
body: A user seems to be missing an entry in sta_normal_user or sta_service_user, so bitbucket cannot see what type it is.

Find out which one by executing

select \* from stash_user u where not exists (select 1 from sta_service_user s where s.user_id = u.id) and not exists (select 1 from sta_normal_user s where s.user_id = u.id);

Then just fix it by inserting a row in sta_normal_user:

insert into sta_normal_user values(2, 'xxx@mycorp.local', 'xxx@mycorp.local');


Tags: bitbucket-server

server