I tried to discuss this in forums but got no answer. Pasting the contents of my posting here.
I am getting this Error in CustomLongRunningTask which extends ConfluenceAbstractLongRunningTask.
java.lang.ClassCastException: org.springframework.orm.hibernate.HibernateTransactionManager cannot be cast to org.springframework.transaction.PlatformTransactionManager
This exception occurs in my LongRunningClass at tt.setTransactionManager() shown below:-
protected void runInternal() { TransactionTemplate tt = new TransactionTemplate(); tt.setTransactionManager((PlatformTransactionManager)ContainerManager .getInstance() .getContainerContext() .getComponent("transactionManager")); tt.execute(new TransactionCallbackWithoutResult() { ....... }) }
When I change the line
tt.setTransactionManager((PlatformTransactionManager)ContainerManager
.getInstance()
.getContainerContext()
.getComponent("transactionManager"));
to
tt.setTransactionManager((HibernateTransactionManager)ContainerManager
.getInstance()
.getContainerContext()
.getComponent("transactionManager"));
it compiles ok with atlas-mvn compile. But then I get this error at runtime:
Exception in thread "ECMS Export task" java.lang.NoClassDefFoundError: org/springframework/orm/hibernate/HibernateTransactionManager
Then I followed instructions at http://confluence.atlassian.com/display/DEVNET/Setting+OSGi+Manifest+Instructions+in+your+Plugin and updated pom to include <dependency> and <Include-Package>.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-hibernate2</artifactId>
<version>2.0.8</version>
<scope>provided</scope>
</dependency>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-confluence-plugin</artifactId>
<version>3.3.4</version>
<extensions>true</extensions>
<configuration>
<productVersion>${confluence.version}</productVersion>
<productDataVersion>${confluence.data.version}</productDataVersion>
<log4jProperties>src/main/resources/log4j/log4j.properties</log4jProperties>
<instructions>
<Import-Package>*</Import-Package>
</instructions>
</configuration>
</plugin>
I get this error during plugin install:-
[INFO] [talledLocalContainer] Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.cadence.confluence.plugins.ecms [84]: Unable to resolve 84.0: missing requirement [84.0] package; (package=org.springframework.orm.hibernate)
And plugin is not loaded at all. I am stuck.
Community moderators have prevented the ability to post new answers.
You are running into some reasonably nasty classloader issues.
For various technical and compatibility reasons, the plugin system runs its own, independent version of Spring. Because of this, the Spring classes loaded in the plugins classloader are not the same as the Spring classes loaded by the core Confluence application, and the Confluence application does not export any Spring classes to the plugin system.
In the first example when the TransactionManager from Confluence core is passed to your plugin, your plugin has loaded a different PlatformTransactionManager class that can not be reconciled with the one in core's classloader. Then when you changed your plugin to no longer bundle its own version of the transaction manager, your plugin can't find the TransactionManager class because (as mentioned above) it is not exported from Confluence to the plugin system.
In order to export pure Spring services to plugins, we have written bridging code between the two different layers. Instead of using the TransactionManager directly, you're better off taking Stefan's advice and using the SAL TransactionTemplate; a bridging service that allows you to run code in its own transaction without touching Spring directly.
Have you checked your package import for the TransactionTemplate? Make sure you use com.atlassian.sal.api.transaction.TransactionTemplate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Usint TransactionTemplate also isn't working. Currently what I am doing is (sort-of) synchronously executing the long running task. And only after finishing the task I return from Action::execute().
This way the progress bar is not visible. :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.