Couldn't load the class 'com.atlassian.confluence.themes.BasicTheme

I am new to Confluence. I use Eclipse (neon.3), Confluence 6.1.1, and SDK 6.2.14. Everything is on my laptop.

I am following this simple example to test a theme plugin.

Writing a Confluence Theme
https://developer.atlassian.com/confdev/tutorials/writing-a-confluence-theme

However, when running atlas-run, I keep getting error:


[INFO] [talledLocalContainer] 2017-04-16 16:33:34,619 INFO [AtlassianEvent::CustomizableThreadFactory-1]

[plugins.synchrony.config.DefaultSynchronyConfigurationManager] retrievePublicKey [Collab editing plugin] Could not retrieve public key for real-time collaboration service at http://localhost:10123/jwt-key with exception: Connect to localhost:10123 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
[INFO] [talledLocalContainer] 2017-04-16 16:33:39,075 ERROR [localhost-startStop-1] [atlassian.plugin.manager.DefaultPluginManager] enableConfiguredPluginModule There was an error loading the descriptor 'Simple Theme' of plugin 'com.example.plugins.tutorial.confluence.theme-tutorial'. Disabling.
[INFO] [talledLocalContainer] com.atlassian.plugin.module.ModuleClassNotFoundException: Couldn't load the class 'com.atlassian.confluence.themes.BasicTheme'. This could mean that you misspelled the name of the class (double check) or that you're using a class in your plugin that you haven't provided bundle instructions for. See https://developer.atlassian.com/x/mQAN for more details on how to fix this.
[INFO] [talledLocalContainer]   at com.atlassian.plugin.module.ClassPrefixModuleFactory.getModuleClass(ClassPrefixModuleFactory.java:46)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.module.PrefixDelegatingModuleFactory.guessModuleClass(PrefixDelegatingModuleFactory.java:145)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.descriptors.AbstractModuleDescriptor.loadClass(AbstractModuleDescriptor.java:216)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.descriptors.AbstractModuleDescriptor.enabled(AbstractModuleDescriptor.java:461)
[INFO] [talledLocalContainer]   at com.atlassian.confluence.plugin.descriptor.ThemeModuleDescriptor.enabled(ThemeModuleDescriptor.java:99)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.notifyModuleEnabled(DefaultPluginManager.java:1991)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.enableConfiguredPluginModule(DefaultPluginManager.java:1738)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.enableConfiguredPluginModules(DefaultPluginManager.java:1715)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1227)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.lateStartup(DefaultPluginManager.java:634)
[INFO] [talledLocalContainer]   at com.atlassian.confluence.plugin.ConfluencePluginManager.lateStartup(ConfluencePluginManager.java:147)
[INFO] [talledLocalContainer]   at com.atlassian.confluence.plugin.PluginFrameworkContextListener.contextInitialized(PluginFrameworkContextListener.java:79)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
[INFO] [talledLocalContainer]   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
[INFO] [talledLocalContainer]   at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
[INFO] [talledLocalContainer]   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[INFO] [talledLocalContainer]   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:745)
[INFO] [talledLocalContainer] Caused by: java.lang.ClassNotFoundException: com.atlassian.confluence.themes.BasicTheme not found by com.example.plugins.tutorial.confluence.theme-tutorial [250]
[INFO] [talledLocalContainer]   at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
[INFO] [talledLocalContainer]   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1844)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:937)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.osgi.util.BundleClassLoaderAccessor.loadClass(BundleClassLoaderAccessor.java:45)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.osgi.factory.OsgiPluginInstalledHelper.loadClass(OsgiPluginInstalledHelper.java:56)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.osgi.factory.OsgiPlugin.loadClass(OsgiPlugin.java:207)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.module.ClassPrefixModuleFactory.getModuleClass(ClassPrefixModuleFactory.java:44)
[INFO] [talledLocalContainer]   ... 25 more

I dont know what happened. In the above, you can also see this:


[plugins.synchrony.config.DefaultSynchronyConfigurationManager] retrievePublicKey [Collab editing plugin] Could not retrieve public key for real-time collaboration service at http://localhost:10123/jwt-key with exception: Connect to localhost:10123 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect

How can I fix this issue?

Thanks for your help!

Welcome to confluence, tricky is the way to go! :slight_smile:
In the tutorial the xml states

<theme key="simpletheme" name="Simple Theme" class="com.atlassian.confluence.themes.BasicTheme">
    <description>A simple custom theme</description>
    <param name="includeClassicStyles" value="false"/>
    <resource type="download" name="default-theme.css" location="/includes/css/default-theme.css">
        <param name="source" value="webContext"/>
    </resource>
</theme>

I had the same problem with you and solved it by creating a completely empty class that extends the BasicTheme, nothing else, no constructor.
Way b) (not tested) would be to add the com.atlassian.confluence.themes package in the import of the pom.xml file within the maven-confluence-plugin tag.

Panos, It is working!!! YOU ARE MY HERO!!!

Way b) (not tested) would be to add the com.atlassian.confluence.themes package in the import of the pom.xml file within the maven-confluence-plugin tag.

I was playing with this approach too, but unable to get it work. This is what I have:

            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-confluence-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.data.version}</productDataVersion>
                    <enableQuickReload>true</enableQuickReload>
                    <enableFastdev>false</enableFastdev>

                    <!-- See here for an explanation of default instructions: -->
                    <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

                        <!-- Add package to export here -->
                        <Export-Package>
                            edu.si.nmai.confluence.api,
                        </Export-Package>

                        <!-- Add package import here -->
                        <Import-Package>
                            org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            *
                        </Import-Package>

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>

Could you please show how I should modify the above if you dont have time to work on the approach?

Again, a HUGE thank you to you!!!

Glad it worked :slight_smile:

try changing this part to

<Import-Package>
    org.springframework.osgi.*;resolution:="optional",
    org.eclipse.gemini.blueprint.*;resolution:="optional",
    com.atlassian.confluence.themes;resolution:="optional",
    *
</Import-Package>

Panos, the code you add for the Import-Package is working. Thank you!

<Import-Package>
    org.springframework.osgi.*;resolution:="optional",
    org.eclipse.gemini.blueprint.*;resolution:="optional",
    com.atlassian.confluence.themes;resolution:="optional",
    *
</Import-Package>

Question: how did you find out this solution? I find out that Atlassian/Confluence is so hard to learn. Maybe something wrong with me?

Another question: I would like to contact you in private and I would like to pay for your help in the future. Are you interested? If you are, can you please respond here and then contact me at davidgosoftdev@gmail.com? (mod: I am not sure whether this is against the policy of the website. If it is, please delete this section of information)

Best.