Azhak Anwar
Azhak Anwar

Reputation: 21

Getting IllegalArgumentException: Could not find class ModuleFactoryBean

I’m currently developing a Jira plugin and familiarizing myself with the platform. Everything seemed to be working fine until I encountered a strange error after using Quick Reload. The issue occurs whenever I execute atlas-mvn package to update the JAR file.

Initially, this error only appeared during the atlas-mvn package step, but now it persists even after deleting the target directory and rebuilding the project from scratch using atlas-run.

I’ve tried everything I could think of, but nothing seems to resolve the issue. It feels like a problem with the SDK itself—while the project compiles successfully, the application fails to run on the server.

Here’s the error log:

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [bundle://3a20f3ef-c74d-403e-ab58-ca9d1f222d58_187.0:0/META-INF/spring/plugin-context.xml]; nested exception is java.lang.IllegalArgumentException: Could not find class [com.atlassian.plugins.osgi.javaconfig.configs.beans.ModuleFactoryBean]

...

2025-01-09 23:35:55,544+0500 ThreadPoolAsyncTaskExecutor::Thread 28 ERROR      [o.e.g.b.e.internal.support.ExtenderConfiguration] Application context refresh failed (NonValidatingOsgiBundleXmlApplicationContext(bundle=com.i2c.jira.timesheet, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [bundle://3a20f3ef-c74d-403e-ab58-ca9d1f222d58_187.0:0/META-INF/spring/plugin-context.xml]; nested exception is java.lang.IllegalArgumentException: Could not find class [com.atlassian.plugins.osgi.javaconfig.configs.beans.ModuleFactoryBean]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:417)

Config Class:

package com.i2c.jira.timesheet.config;
import com.i2c.jira.timesheet.api.MyPluginComponent;
import com.i2c.jira.timesheet.impl.MyPluginComponentImpl;
import com.atlassian.plugins.osgi.javaconfig.configs.beans.ModuleFactoryBean;
import com.atlassian.plugins.osgi.javaconfig.configs.beans.PluginAccessorBean;
import com.atlassian.sal.api.ApplicationProperties;
import org.osgi.framework.ServiceRegistration;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import static com.atlassian.plugins.osgi.javaconfig.OsgiServices.exportOsgiService;
import static com.atlassian.plugins.osgi.javaconfig.OsgiServices.importOsgiService;
@Configuration
@Import({
        ModuleFactoryBean.class,
        PluginAccessorBean.class
})
public class MyPluginJavaConfig {
    @Bean
    public ApplicationProperties applicationProperties() {
        return importOsgiService(ApplicationProperties.class);
    }
    @Bean
    public MyPluginComponent myPluginComponent(ApplicationProperties applicationProperties) {
        return new MyPluginComponentImpl(applicationProperties);
    }
    @SuppressWarnings("rawtypes")
    @Bean
    public FactoryBean<ServiceRegistration> registerMyDelegatingService(
            final MyPluginComponent mypluginComponent) {
        return exportOsgiService(mypluginComponent, null, MyPluginComponent.class);
    }
}

plugin-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
    <context:component-scan base-package="com.i2c.jira.timesheet.config" />
</beans>

Build Information:

I’ve verified the OSGi dependency, and it includes all the imported classes:

<dependency>
    <groupId>com.atlassian.plugins</groupId>
    <artifactId>atlassian-plugins-osgi-javaconfig</artifactId>
    <version>${osgi.javaconfig.version}</version>
    <scope>provided</scope>
</dependency>

Different OSGI Versions that I tried:

I’d greatly appreciate any insights or suggestions for resolving this issue!

Upvotes: 2

Views: 25

Answers (0)

Related Questions