No more love from active objects on confluence and MS SQL server ...

Hi there,

We have a few plugins that run active objects and working with no issues on confluence:

Confluence Version4.3.6, Build Number3397, on-premise

One day we've tried adding a new active objects (AO) entity to a plugin that had no AO entities before and we've been struggling with it since then.

Strangely enough, another plugin that had previous AO entities, does work, and newly added AO entities seem to work as well.

Another interesting bit is that the logs inside confluence-data do print create table and insert statements, but the tables are not present in the databasefor some reason.

We've compared the AO declarations in both pom and atlassian xml files and found no differences that should make you wonder about it, apart of the different entity names or signature, it's was all good.

Here's a config snapshot -

<ao key="ao-module">

<description>The module configuring the Active Objects service used by this plugin</description>

<entity>aaa.templatebindings.entities.StatusTemplate</entity>

<entity>aaa.templatebindings.entities.TemplateSection</entity>

<entity>aaa.templatebindings.newdummy</entity>

</ao>

<component-import key="ao" name="Active Objects service" interface="com.atlassian.activeobjects.external.ActiveObjects">

<description>Component to access Active Objects functionality from the plugin</description>

</component-import>

<component key="tx-processor" name="Transactional Annotation Processor" class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor">

<decription>Processes @Transactional annotations.</decription>

</component>

And from the pom -

<dependency>

<groupId>com.atlassian.activeobjects</groupId>

<artifactId>activeobjects-plugin</artifactId>

<version>0.20</version>

<scope>provided</scope>

</dependency>

<!-- SAL, the Active Objects plugin uses SAL's API for transactions -->

<dependency>

<groupId>com.atlassian.sal</groupId>

<artifactId>sal-api</artifactId>

<version>2.4.1</version>

<scope>provided</scope>

</dependency>

In the code we used this -

private final ActiveObjects ao;

this.ao = ao;

newdummy nd = this.ao.create(newdummy.class);

nd.setTest(String.valueOf(System.currentTimeMillis()));

nd.save();

The logs show -

2013-06-07 14:28:58,187 DEBUG [http-8088-2] [net.java.ao.sql] onSql CREATE TABLE AO_8E131D_NEWDUMMY (

ID INTEGER IDENTITY(1,1) NOT NULL,

TEST VARCHAR(255),

CONSTRAINT pk_AO_8E131D_NEWDUMMY_ID PRIMARY KEY(ID)

)

2013-06-07 14:28:58,193 DEBUG [http-8088-2] [net.java.ao.sql] onSql INSERT INTO AO_8E131D_NEWDUMMY DEFAULT VALUES

2013-06-07 14:28:58,204 DEBUG [http-8088-2] [net.java.ao.sql] onSql UPDATE AO_8E131D_NEWDUMMY SET TEST = ? WHERE ID = ?

2013-06-07 14:28:58,218 DEBUG [http-8088-2] [net.java.ao.sql] onSql SELECT * FROM AO_8E131D_MY_STATUS_TEMPLATE

Here's one of the exceptions in the current confluence log folder -

Caused by: java.sql.SQLException: Invalid object name 'AO_CFF14D_MY_STATUS_TEMPLATE'.

at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)

at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2816)

at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2254)

at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:631)

at net.sourceforge.jtds.jdbc.MSCursorResultSet.processOutput(MSCursorResultSet.java:943)

at net.sourceforge.jtds.jdbc.MSCursorResultSet.cursorCreate(MSCursorResultSet.java:541)

at net.sourceforge.jtds.jdbc.MSCursorResultSet.<init>(MSCursorResultSet.java:154)

at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:424)

at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:777)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)

at net.java.ao.EntityManager.find(EntityManager.java:695)

at net.java.ao.EntityManager.find(EntityManager.java:623)

at net.java.ao.EntityManager.find(EntityManager.java:537)

at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.find(EntityManagedActiveObjects.java:125)

Any help would be appreciated, thanks, mo

1 answer

1 accepted

2 votes
Accepted answer

I'm not sure what the problem is but here are a few things to try:

1. Are both plugins (the one that works and the one that doesn't) deployed in the same Confluence instance? Is there any chance that they could be using different JDBC drivers and/or database URLs? If so, then you could explore the possibility that the driver/url is to blame.

2. Make sure that all of your interaction with AO occurs within a transaction. My preferred approach for that is to inject a com.atlassian.sal.api.transaction.TransactionTemplate into my service class, and do all AO work inside a call to TransactionTemplate#execute.

3. Write a test class to exercise your AO code. That will just help you eliminate potential problems more quickly, rather than having to re-install the plugin over and over. Here's an excerpt from one such class of my own:

@RunWith(ActiveObjectsJUnitRunner.class)
@Jdbc(DynamicJdbcConfiguration.class)
@Data(TicketFixture.class)
public class AoTicketDaoTest {

    private ActiveObjects ao;

    private AoTicketDao dao;

    @SuppressWarnings("UnusedDeclaration")
    private EntityManager entityManager;

    @Before
    public void setUp() {
        assertNotNull(entityManager);
        ao = new TestActiveObjects(entityManager);
        dao = new AoTicketDao(ao);
    }

    @Test
    public void testCreatedTicketHasTicketNumber() {
        assertThat(dao.create(...).getTicketNumber()).isEqualTo("4857");
    }
}

4. Post the definitions of the Java entity interfaces that seem relevant to the problem so that we can check for any problems in there.

This is perfect David, it's working. The funny thing is that all other AO code is working without being wrapped in the transaction block.

Sorry for the late reponse, just came back from overseas...

Thanks again, mo

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in United States

Atlassian Certification

Hello, Today it is about Atlassian Certification. Do you have an interest in taking the exam? If yes share with us so if we have couple people we can start a group study. All the best,   ...

55 views 7 1
View post

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