Problem Creating a "custom field type" (JIRA Tutorial)

##I’m stuck in a Tutorial

I was following the Creating a custom field type tutorial very closely and have made only one alteration in my code, I did not put in the

<component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties"/>

because I’m developing for JIRA 7.2.2.


When I “Deploy” with atlas-run the PlugIn gets displayed but the custom field doesn’t show up at “Add custom field”.

I have tried a bunch of different stuff but I can’t get it to work, maybe someone here can help me.

1 Like

Did you take a look at the log file? There must be something in it that can give you a hint as to why it’s not appearing.

Hey Felix,

Since V 7.x.x I had to use annotations to be able to import components properly.

like so…

@Scanned
public class MyCustomField extends TextAreaCFType {

    private PluginSettingsFactory pluginSettingsFactory;

    protected MyCustomField (@ComponentImport PluginSettingsFactory pluginSettingsFactory){
        this.pluginSettingsFactory= pluginSettingsFactory;
    }

or

@Scanned
public class MyCustomField extends TextAreaCFType {

    @ComponentImport 
    private final PluginSettingsFactory pluginSettingsFactory;

    @Inject
    protected MyCustomField (PluginSettingsFactory pluginSettingsFactory){
        this.pluginSettingsFactory= pluginSettingsFactory;
    }

Be sure you have the right dependencies in your pom for these annotations

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-runtime</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>runtime</scope>
        </dependency>

Hope this helps

2 Likes

You’re the man Diego.

That totally solved my problem, thank you so much.