JIRA server functionality fails due to InstanceAlreadyExistsException

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When attempting JIRA operations users may experience the following:

  • JIRA not starting
  • OutOfMemoryErrors 
  • DB SQL exceptions
  • Database driver unable to be found
  • NullPointerExceptions

Any of the following stacktraces may appear in the atlassian-jira.log:

java.lang.NullPointerException
	at org.ofbiz.core.entity.jdbc.SQLProcessor.prepareStatement(SQLProcessor.java:525)
	at org.ofbiz.core.entity.GenericDAO.selectListIteratorByCondition(GenericDAO.java:1040)
	at org.ofbiz.core.entity.GenericDAO.selectByAnd(GenericDAO.java:608)
	at org.ofbiz.core.entity.GenericHelperDAO.findByAnd(GenericHelperDAO.java:131)
	at org.ofbiz.core.entity.GenericDelegator.findByAnd(GenericDelegator.java:788)
....
2013-01-28 23:55:34,944 Timer-6 ERROR anonymous 1405x4x1 1drrz4p 192.168.2.4 /secure/SetupDatabase.jspa [NoModule] Error getting datasource via DBCP: JdbcDatasourceInfo{uri='jdbc:mysql://192.168.0.2:3306/jiradb?useUnicode=true&characterEncoding=UTF8&sessionVariables=storage_engine=InnoDB', driverClassName='com.mysql.jdbc.Driver', username='jira', password='********', isolationLevel='null', connectionProperties=null, connectionPoolInfo=ConnectionPoolInfo{maxSize=20, minSize=20, initialSize=null, maxIdle=20, maxWait=30000, sleepTime=300000, lifeTime=600000, deadLockMaxWait=600000, deadLockRetryWait=10000, validationQuery='select 1', minEvictableTimeMillis=60000, timeBetweenEvictionRunsMillis=300000, poolPreparedStatements=null, testOnBorrow=null, testOnReturn=null, testWhileIdle=true, maxOpenPreparedStatements=null, numTestsPerEvictionRun=null, removeAbandonedTimeout=300, validationQueryTimeout=3, defaultCatalog=null}}
java.lang.RuntimeException: javax.management.InstanceAlreadyExistsException: com.atlassian.jira:name=BasicDataSource
	at org.weakref.jmx.MBeanExporter.export(MBeanExporter.java:45)
	at org.apache.commons.dbcp.ManagedBasicDataSource.exportMBean(ManagedBasicDataSource.java:70)
	at org.apache.commons.dbcp.ManagedBasicDataSource.<init>(ManagedBasicDataSource.java:61)
	at org.apache.commons.dbcp.ManagedBasicDataSourceFactory.createDataSource(ManagedBasicDataSourceFactory.java:278)
	at org.ofbiz.core.entity.transaction.DBCPConnectionFactory.createDataSource(DBCPConnectionFactory.ja
....
Caused by: javax.management.InstanceAlreadyExistsException: com.atlassian.jira:name=BasicDataSource
	at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:467)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1520)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:986)
....
2013-01-28 23:55:35,010 Timer-6 ERROR anonymous 1405x4x1 1drrz4p 192.168.2.4 /secure/SetupDatabase.jspa [atlassian.event.internal.AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event 'com.atlassian.plugin.event.events.PluginModuleDisabledEvent@7865a4' from the invoker 'SingleParameterMethodListenerInvoker{method=public void com.atlassian.jira.plugin.JiraCacheResetter$Delegate.onPluginModuleDisabled(com.atlassian.plugin.event.events.PluginModuleDisabledEvent), listener=com.atlassian.jira.plugin.JiraCacheResetter$Delegate@1a24c62}'.
java.lang.RuntimeException: java.lang.NullPointerException
	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54)
	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:66)
	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:32)
	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:60)
....
Caused by: com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.NullPointerException
	at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:152)
	at com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:115)
	at com.atlassian.util.concurrent.ResettableLazyReference.get(ResettableLazyReference.java:89)

Cause

The known causes for this are as follows:

  1. Multiple context paths and/or UserTransaction have been set up - Tomcat will attempt to provide access to JIRA through both context paths which can lead to problems such as out-of-memory errors and instability.  The location of the two files are typically below:
    • $CATALINA_BASE/conf/server.xml
    • $CATALINA_BASE/conf/Catalina/localhost/jira.xml
    • (info) For standalone JIRA installations, the $CATALINA_BASE is the $JIRA_INSTALL directory.

  1. The database connection is using special characters, for exampleany characters other than .(period) or _ (underscore). This is a bug tracked under  JRA-27796 - Getting issue details... STATUS .

  2. The dbconfig.xml has been incorrectly set up.

  3. The jira.xml is pointing to the incorrect webapp - this can happen if there are multiple webapps from upgrades from previous versions or changes in the Tomcat distribution. For example the below webapps may be present, and the first is being used, however jira.xml is pointing to the second:


    • /apps/apache/tomcat70/apache-tomcat-7.0.34/webapps/atlassian-jira-5.2.4.1.war
    • /apps/jira/atlassian-jira-5.2.4.1-war/dist-generic/atlassian-jira-5.2.4.1.war


  4. If using AWS, a security group settings can prevent JIRA to connect with the RDS database.



Resolution

It is highly recommended to use the standalone installation of JIRA, rather than the EAR/WAR distribution as WAR download distribution will be deprecated in near future as per End of Support Announcements for JIRA. Migrating can be done as per our Migrating JIRA to Another Server documentation.


  1. Verify the context path is correct. The context path and/or UserTransaction resource must be set in either the server.xml or the jira.xml file, but cannot be set in both.  Please see Installing JIRA on Tomcat 6.0 or 7.0 for further details on how to set the context path. For example:

    <Context path="/jira" docBase="/Users/batman/Atlassian/jira/atlassian-jira-5.1.1-war/dist-tomcat/tomcat-6/atlassian-jira-5.1.1.war" debug="0" useHttpOnly="true">
        <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
        factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
        <Manager pathname=""/>
    </Context>
  2. Change the password for the database to something without special characters.
  3. Verify the dbconfig.xml is correct, as in Connecting JIRA to a Database. It's recommend to make changes Using the JIRA Configuration Tool as it will correctly set those values.
    (warning) Please ensure the appropriate documentation version is used, as differences in versions can cause problems.
  4. If using AWS, review the instance security group settings and see if it blocking the connection to the database.
  5. Restart JIRA.

Last modified on Sep 25, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.