Confluence don't start after upgrade from 8.0.4 to 8.1.0
Asked by Pavel K_:

Hello,

After upgrade from 8.0.4 to 8.1.0

I have following errors.

javax.servlet.ServletException: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getHeaderLogo' in class net.getunik.confluence.skin.core.logo.VelocityLogoHelper threw exception org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at /net/getunik/confluence/skin/core/theme/templates/includes/logo.vm\[line 10, column 46\]  
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getHeaderLogo' in class net.getunik.confluence.skin.core.logo.VelocityLogoHelper threw exception org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at /net/getunik/confluence/skin/core/theme/templates/includes/logo.vm\[line 10, column 46\]  
Invocation of method 'getHeaderLogo' in class net.getunik.confluence.skin.core.logo.VelocityLogoHelper threw exception org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at /net/getunik/confluence/skin/core/theme/templates/includes/logo.vm\[line 10, column 46\]

<br />

query did not return a unique result: 2

I understand that I have to delete an extra entry in the table, but in which table exactly?

Need help.


Answers:
author: Pavel K_
body: Hello,

Thank you for your help.

Yes. I use third party theme plugin.

[https://marketplace.atlassian.com/apps/1211252/enterprise-theme-for-confluence?hosting=datacenter\&tab=overview](https://marketplace.atlassian.com/apps/1211252/enterprise-theme-for-confluence?hosting=datacenter&tab=overview)

Enterprise Theme for Confluence.

But if I disable (I was try disable all plugins) it, I have the same error.

Yes, I think too, that plugin trouble, but, I think, I have to remove incorrect record in table. I don't see other way.

comments: author: Radek Dost?l
body: Then you couldn't have disabled it correctly, because if a plugin is disabled, Confluence wouldn't incur any of it's code. Either that, or you got a different error.

Following up on my last comment, the duplicate is somewhere in bandana, this should filter it out

```
SELECT bandanacontext, bandanakey, COUNT(bandanakey) FROM bandana GROUP BY bandanacontext, bandanakey HAVING COUNT(bandanakey) > 1;
```


author: Pavel K_
body: Do not help.

All records have COUNT 1.

I try upgrade to 8.1.3 and get more information:

javax.servlet.ServletException: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getHeaderLogo' in class net.getunik.confluence.skin.core.logo.VelocityLogoHelper threw exception org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at /net/getunik/confluence/skin/core/theme/templates/includes/logo.vm\[line 10, column 46\]

org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getHeaderLogo' in class net.getunik.confluence.skin.core.logo.VelocityLogoHelper threw exception org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at /net/getunik/confluence/skin/core/theme/templates/includes/logo.vm\[line 10, column 46\]

Invocation of method 'getHeaderLogo' in class net.getunik.confluence.skin.core.logo.VelocityLogoHelper threw exception org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at /net/getunik/confluence/skin/core/theme/templates/includes/logo.vm\[line 10, column 46\]

query did not return a unique result: 2

Yes. This is plugin trouble but I can't find duplicate record.


author: Radek Dost?l
body: Hmm, strange. Okay, so I took another look, without the stacktrace it is a guess, but I'm 99% sure this time it's this:

```
SELECT * FROM content WHERE contenttype = 'GLOBALDESCRIPTION';
```

If that 1% of chance is wrong, this really sounds like something to take up with the vendor, but I'm pretty sure this will be it.


author: Pavel K_
body: Hello,

Thank you for your help.

Yes I found 2 records.

contentid \| hibernateversion \| contenttype \| title \| lowertitle \| version \| creator \| creationdate \| lastmodifier \| lastmoddate \|  
-----------+------------------+-------------------+-------+------------+---------+---------+---------------------+--------------+---------------------+--  
1 \| 0 \| GLOBALDESCRIPTION \| \| \| 1 \| \| 2012-05-29 05:29:12 \| \| 2012-05-29 05:29:12 \|  
425986 \| 0 \| GLOBALDESCRIPTION \| \| \| 1 \| \| 2009-09-03 15:15:34 \| \| 2009-09-03 15:15:34 \|

Seems to be wrong with record 425986.

But I can not delete it.

error the same like:

<https://jira.atlassian.com/browse/CONFCLOUD-75221>

DELETE FROM content WHERE contentid = '425986';  
ERROR: update or delete on table "content" violates foreign key constraint "fkwjyn6091q3l1gl7bh143ma2a" on table "content"  
DETAIL: Key (contentid)=(425986) is still referenced from table "content".  


author: Radek Dost?l
body: Well, you can disable foreign key entries so you can delete it, but better to check all of the referenced tables/columns before doing so to avoid breaking something. That error message is a bit funny, sounds to me like it references itself, so maybe if you're lucky you could remove that foreign key, try to delete, then add the foreign key back. Worst case would need to check all the referenced tables and columns to ensure some orphaned row doesn't stay behind. I'm no DBA, but there should be some guides how to do that, or Atlassian KBA.


author: Pavel K_
body: Yes.

You were right.  
I removed the extra line and it worked.  
Thanks for the help.


author: Radek Dost?l
body: ```
net.getunik.confluence*
```

This does not appear to be native package. Do you have any custom Theme related plugin(s)? If so, I'd probably try to start Confluence with the plugins disabled on startup:

# <https://confluence.atlassian.com/confkb/how-to-manually-remove-malfunctioning-add-ons-113705118.html>

Which should be similar to

    $ ./start-confluence.sh --disable-addons=com.atlassian.test.plugin

That said, without knowing which plugin this is, probably my next step would be to list all tables in database and find something resembling themes/logos (which will start with AO_xxx_).

According to <https://jira.atlassian.com/browse/CONFSERVER-53140> the plugin is this: [https://marketplace.atlassian.com/apps/1211252/enterprise-theme-for-confluence?hosting=server\&tab=overview](https://marketplace.atlassian.com/apps/1211252/enterprise-theme-for-confluence?hosting=server&tab=overview)

The plugin's key is 'net.getunik.confluence.skin.core' (to disable on startup)

I'd assume that perhaps you didn't upgrade the plugin before the upgrade (<https://marketplace.atlassian.com/apps/1211252/enterprise-theme-for-confluence/version-history>).

So overall, I'd start up Confluence with the plugin disabled, once booted up, update the plugin in UPM, and probably that should work, without needing to manually delete something in the db. If it still fails and you see the same errors in the log, while trying to update it, then I cannot preach about deleting stuff, officially would reach out to the vendor.

Edit:

Offending line in vm:

```
#set($logo = $enterpriseThemeLogoManager.getHeaderLogo($spaceKeyOrUsername))
```

In java:

```
public Logo getHeaderLogo(String spaceKeyOrUsername) {
    return this.getHeaderLogo(spaceKeyOrUsername, AuthenticatedUserThreadLocal.get());
}
```

next to

```
public Logo getHeaderLogo(String spaceKeyOrUsername, ConfluenceUser currentUser) {
    Logo logo = null;
    ThemeConfigurationMap themeConfiguration = this.themeConfigurationManager.getThemeConfiguration(spaceKeyOrUsername);
    Boolean showSpaceLogo = !themeConfiguration.isTrue("true_false_header_show_global_logo");
    if (showSpaceLogo) {
        logo = this.getSpaceLogo(spaceKeyOrUsername, currentUser);
    }

    if (logo == null) {
        logo = this.getConfluenceLogo();
    }

    return logo;
}
```

(And here I kind of gave up because I'd need the stacktrace to know the steps to follow in here what is the exact offending method).

Long story short this uses <https://docs.atlassian.com/atlassian-bandana/3.1/apidocs/com/atlassian/bandana/BandanaManager.html>

Which is <https://developer.atlassian.com/server/confluence/what-is-bandana-one-form-of-confluence-persistence/>

Delving into <https://developer.atlassian.com/server/confluence/persistence-in-confluence> we come to find that the plugin stores data in 'BANDANA' table.

So would look into BANDANA for anything containing '%net.getunik%' and chances are the duplicate is somewhere in there.

Anyhoo, just first steps I'd try, but again, would talk to the vendor before destroying the db by accident.


Tags: confluence-server

server