Caused by: java.util.MissingResourceException: Can't find bundle for base name cache, locale en_US

Trying to execute SQL in a confluence plugin to a jiraDS datasource define in the confluence configuration file.  Plugin has dependencies for jira-api and jira-core defined with 'provided' as value for <scope>provided</scope>.  The subsequent atlas-compile and atlas-package build and packaging has no errors.  The resulting plugin jar file was too large at 76Mbytes and the limit on the server was defaulted to 67Mbytes.  I proceeded to copy just the class files that i used my code and reduced the file size to about 1Mbyte, which uploaded as an add on plugin with no errors.  When going to a page that has the plugin it then throws this error:

Caused by: java.util.MissingResourceException: Can't find bundle for base name cache, locale en_US

Code used in plugin to attempt to getConnection():

try {

    DefaultOfBizConnectionFactory factory = DefaultOfBizConnectionFactory.getInstance();

    Connection connection = factory.getConnection();

    // do something with connection

} catch (SQLException sqle) {

    String message = sqle.getMessage();

}

Is there another way to reduce the plugin jar file size without piece mealing the classes folder with required classes?  Is there a better way to get a connection object for executing SQL in a plugin without doing straight jdbc?  I'd like to reuse the defined 'jiraDS' datasource in Confluence's configuration file.

2 answers

After trying what seems like 10 different ways to access JIRA data from a Confluence Plugin, i finally found that this worked:

import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource;

private String sqlJNDITest() {
    String res = "NONE";
    DataSource dataSource;
    try {
        InitialContext initalContext = new InitialContext();
        Context context = (Context) initalContext.lookup("java:comp/env");
        dataSource = (DataSource) context.lookup("jdbc/<your_datasource_name>");
        Connection connection = dataSource.getConnection();
        res = connection.getCatalog();
        String query = "select * from jiraissue where id=<your_jiraissue_id>";
        Statement stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next()) {
            String summary = rs.getString("summary");
            res = res + summary;
        }

    } catch (NamingException ex) {
        String message = ex.getMessage();
    } catch (SQLException sqle) {
        String message = sqle.getMessage();
    }
    return res;
}

No need to include any jira-api or jira-core pom.xml dependencies in your confluence plugin and the plugin jar file size was less then 500Kbytes.  The nice thing here is that it uses your confluence server's configured datasource for JIRA instead of you having to code it in the plugin config or JAVA code.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

1,008 views 14 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you