Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Tai Ngo November 2, 2015

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

0 votes
Tai Ngo November 2, 2015

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.

0 votes
Tai Ngo November 2, 2015

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;
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events