Cannot instantiate abstract class or interface
症状
Bamboo UI shows this error instead of the deployment projects when the user navigates to the deployments page
Background page refresh cannot contact server. Please ensure Bamboo server is available. The error was:
Internal Server Error
This type of errors appear in the Bamboo server logs:
2013-12-18 09:43:33,239 INFO [http-bio-8085-exec-13] [AccessLogFilter] root GET http://localhost:8085/bamboo/rest/api/latest/deploy/dashboard/?_=1387388613232 114073kb
2013-12-18 09:43:33,277 ERROR [http-bio-8085-exec-13] [FiveOhOh] 500 Exception was thrown.
org.codehaus.jackson.map.JsonMappingException: Cannot instantiate abstract class or interface: com.atlassian.bamboo.deployments.versions.persistence.items.AbstractMutableDeploymentVersionItem; nested exception is net.sf.hibernate.HibernateException: Cannot instantiate abstract class or interface: com.atlassian.bamboo.deployments.versions.persistence.items.AbstractMutableDeploymentVersionItem (through reference chain: com.google.common.collect.TransformingRandomAccessList[0])
at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:218)
at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:197)
at org.codehaus.jackson.map.ser.std.SerializerBase.wrapAndThrow(SerializerBase.java:166)
at org.codehaus.jackson.map.ser.std.StdContainerSerializers$IndexedListSerializer.serializeContents(StdContainerSerializers.java:127)
at org.codehaus.jackson.map.ser.std.StdContainerSerializers$IndexedListSerializer.serializeContents(StdContainerSerializers.java:71)
at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86)
at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1604)
at org.codehaus.jackson.jaxrs.JacksonJsonProvider.writeTo(JacksonJsonProvider.java:558)
at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:306)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1437)
...
Caused by: org.springframework.orm.hibernate.HibernateSystemException: Cannot instantiate abstract class or interface: com.atlassian.bamboo.deployments.versions.persistence.items.AbstractMutableDeploymentVersionItem; nested exception is net.sf.hibernate.HibernateException: Cannot instantiate abstract class or interface: com.atlassian.bamboo.deployments.versions.persistence.items.AbstractMutableDeploymentVersionItem
at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:597)
at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337)
at com.atlassian.bamboo.persistence3.HibernateDaoUtils.execute(HibernateDaoUtils.java:90)
at com.atlassian.bamboo.deployments.results.persistence.DeploymentResultDaoImpl.getLatestKnownDeploymentResultForEnvironment(DeploymentResultDaoImpl.java:221)
at sun.reflect.GeneratedMethodAccessor602.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
...
Caused by: org.springframework.orm.hibernate.HibernateSystemException: Cannot instantiate abstract class or interface: com.atlassian.bamboo.deployments.versions.persistence.items.AbstractMutableDeploymentVersionItem; nested exception is net.sf.hibernate.HibernateException: Cannot instantiate abstract class or interface: com.atlassian.bamboo.deployments.versions.persistence.items.AbstractMutableDeploymentVersionItem
at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:597)
at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337)
at com.atlassian.bamboo.persistence3.HibernateDaoUtils.execute(HibernateDaoUtils.java:90)
at com.atlassian.bamboo.deployments.results.persistence.DeploymentResultDaoImpl.getLatestKnownDeploymentResultForEnvironment(DeploymentResultDaoImpl.java:221)
at sun.reflect.GeneratedMethodAccessor602.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
...
原因
Hibernate stuff: you define _abstract_ class and store it in a table, then each implementation of that class goes to linked table
if the linked table row is missing Hibernate can't load the class because you can't get instance of an abstract class
ソリューション
The resolution of this type of database corruptions can be running SQL queries to delete the records from the database that refer to the fields that shouldn't exist. Please note that each instance of this database corruption could involve different tables.
- Shut down Bamboo
- Backup the Bamboo database
Run the following SELECT queries to find entries to delete
SELECT * FROM deployment_version_item_ba WHERE artifact_id NOT IN (SELECT DISTINCT artifact_id FROM artifact); SELECT * FROM DEPLOYMENT_VERSION_ITEM_BA WHERE VERSION_BAM_ARTIFACT_ITEM_ID NOT IN (SELECT DEPLOYMENT_VERSION_ITEM_ID FROM DEPLOYMENT_VERSION_ITEM); SELECT * FROM DEPLOYMENT_VERSION_ITEM WHERE DEPLOYMENT_VERSION_ID NOT IN (SELECT DEPLOYMENT_VERSION_ID FROM DEPLOYMENT_VERSION); SELECT * FROM DEPLOYMENT_VERSION_ITEM WHERE DEPLOYMENT_VERSION_ITEM_ID NOT IN (SELECT VERSION_BAM_ARTIFACT_ITEM_ID FROM DEPLOYMENT_VERSION_ITEM_BA);
If any of the above return results, run the corresponding DELETE query below:
DELETE FROM deployment_version_item_ba WHERE artifact_id NOT IN (SELECT DISTINCT artifact_id FROM artifact); DELETE FROM DEPLOYMENT_VERSION_ITEM_BA WHERE VERSION_BAM_ARTIFACT_ITEM_ID NOT IN (SELECT DEPLOYMENT_VERSION_ITEM_ID FROM DEPLOYMENT_VERSION_ITEM); DELETE FROM DEPLOYMENT_VERSION_ITEM WHERE DEPLOYMENT_VERSION_ID NOT IN (SELECT DEPLOYMENT_VERSION_ID FROM DEPLOYMENT_VERSION); DELETE FROM DEPLOYMENT_VERSION_ITEM WHERE DEPLOYMENT_VERSION_ITEM_ID NOT IN (SELECT VERSION_BAM_ARTIFACT_ITEM_ID FROM DEPLOYMENT_VERSION_ITEM_BA);