How to use Active Objects with annotation in atlassian sdk
<p>I do Jira plugin and I need to use Active Object. (Jira v7.1.8)
But in official documentation is outdated. It is written using xml, but if I understood correctly, now used Atlassian Spring Scanner (I use v1.2.3)</p>

<p>Following this a manual <a href="https://bitbucket.org/atlassian/atlassian-spring-scanner/src/1.2.x/README.md?at=1.2.x&amp;fileviewer=file-view-default" rel="nofollow">https://bitbucket.org/atlassian/atlassian-spring-scanner/src/1.2.x/README.md?at=1.2.x&amp;fileviewer=file-view-default</a> nothing succeeded.</p>

<p><strong>atlassian-plugin.xml</strong></p>

<pre><code>    &lt;atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"&gt;
    &lt;plugin-info&gt;
        &lt;description&gt;${project.description}&lt;/description&gt;
        &lt;version&gt;${project.version}&lt;/version&gt;
        &lt;vendor name="${project.organization.name}" url="${project.organization.url}" /&gt;
        &lt;param name="plugin-icon"&gt;images/pluginIcon.png&lt;/param&gt;
        &lt;param name="plugin-logo"&gt;images/pluginLogo.png&lt;/param&gt;
    &lt;/plugin-info&gt;

    &lt;!-- add our i18n resource --&gt;
    &lt;resource type="i18n" name="i18n" location="dbplugin"/&gt;

    &lt;web-resource key="my-resources"&gt;
        &lt;dependency&gt;com.atlassian.jira.jira-project-config-plugin:project-config-global&lt;/dependency&gt;
        &lt;context&gt;my-resources&lt;/context&gt;
    &lt;/web-resource&gt;
    &lt;!----------- This is old xml version ------------------
        &lt;component-import key="ao" name="Active Objects service" interface="com.atlassian.activeobjects.external.ActiveObjects"&gt;
            &lt;description&gt;Component to access Active Objects functionality from the plugin&lt;/description&gt;
        &lt;/component-import&gt;

 &lt;component key="dao-factory" class="com.lemon.dbplugin.DAO.DAOFactory"&gt;
            &lt;/component&gt;
    --------------------------------------------------------&gt;
        &lt;ao key="ao-module"&gt;
            &lt;entity&gt;com.lemon.dbplugin.entity.StudentEntity&lt;/entity&gt;
        &lt;/ao&gt;



    &lt;webwork1 key="actions" name="MyActions"&gt;
        &lt;actions&gt;
            &lt;action name="com.lemon.dbplugin.ActionAlpha" alias="action" roles-required="admin"&gt;
                &lt;view name="success"&gt;/templates/success.vm&lt;/view&gt;
            &lt;/action&gt;
        &lt;/actions&gt;
    &lt;/webwork1&gt;
</code></pre>

<p><strong>ActionAlpha</strong></p>

<pre><code>package com.lemon.dbplugin;


import com.atlassian.jira.project.Project;
import com.atlassian.jira.web.action.JiraWebActionSupport;
import com.lemon.dbplugin.DAO.DAOFactory;
import com.lemon.dbplugin.entity.StudentEntity;
import com.lemon.dbplugin.logic.Student;
import com.lemon.dbplugin.logic.StudentImpl;
import org.apache.log4j.Logger;
import webwork.action.ServletActionContext;

public class ActionAlpha extends JiraWebActionSupport {

private static final Logger log = Logger.getLogger(ActionAlpha.class);
private Project project;
private StudentEntity[] students;

@Override
public String execute() throws Exception {
    log.debug("Entered in execute ActionAlpha");
    project = getSelectedProjectObject();
    getHttpRequest().setAttribute("com.atlassian.jira.projectconfig.util.ServletRequestProjectConfigRequestCache:project", project);
    students = DAOFactory.getInstance().getStudentDAO().getStudents();
    log.debug("students :" + students);
    return super.execute();
}
public String doAdd() throws Exception {
    log.debug("Entered in doAdd ActionAlpha");
    String name = getHttpRequest().getParameterValues("name")[0];
    Student student = new StudentImpl(name);
    log.debug("student :" + student);
    DAOFactory.getInstance().getStudentDAO().addStudent(student);
    ServletActionContext.getResponse().sendRedirect("/secure/action.jspa");
    return NONE;
}
</code></pre>

<p>}</p>

<p><strong>DAOFactory</strong></p>

<pre><code>package com.lemon.dbplugin.DAO;


import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.lemon.dbplugin.DAO.Impl.StudentDAOImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class DAOFactory {
    private static StudentDAO studentDAO = null;
    private static DAOFactory instance = null;
@ComponentImport private static ActiveObjects ao;

@Autowired
public DAOFactory(@ComponentImport ActiveObjects ao) {
    DAOFactory.ao = ao;
}
public static synchronized DAOFactory getInstance() {
    if (instance == null) {
        instance = new DAOFactory(ao);
    }
    return instance;
}
public StudentDAO getStudentDAO() {
    if (studentDAO == null) {
        studentDAO = new StudentDAOImpl(ao);
    }
    return studentDAO;
}
</code></pre>

<p>}</p>

<p><strong>StudentDAOImpl</strong></p>

<pre><code>package com.lemon.dbplugin.DAO.Impl;

import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.sal.api.transaction.TransactionCallback;
import com.lemon.dbplugin.DAO.StudentDAO;
import com.lemon.dbplugin.entity.StudentEntity;
import com.lemon.dbplugin.logic.Student;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;


public class StudentDAOImpl implements StudentDAO {


    private final ActiveObjects ao;
    private static final Logger log = Logger.getLogger(StudentDAOImpl.class);


    @Autowired
    public StudentDAOImpl(@ComponentImport ActiveObjects ao) {
        this.ao = ao;
    }

    @Override
    public StudentEntity addStudent(final Student student) throws Exception {
        log.debug("Entered to addStudents");
        log.debug("AO :" + ao);
        return ao.executeInTransaction(new TransactionCallback&lt;StudentEntity&gt;() {
            public StudentEntity doInTransaction() {
                StudentEntity entity = ao.create(StudentEntity.class);
                entity.setName(student.getName());
                entity.setCreated(new Date(System.currentTimeMillis()));
                entity.save();
                return entity;
            }
        });
    }

    public StudentEntity[] getStudents() throws Exception {
        log.debug("Entered to getStudents");
        log.debug("ao: " + ao);

        try {
            return ao.executeInTransaction(new TransactionCallback&lt;StudentEntity[]&gt;() {
                public StudentEntity[] doInTransaction() {
                    StudentEntity[] result = ao.find(StudentEntity.class);
                    if (result != null) {
                        return ao.find(StudentEntity.class);
                    } else {
                        return new StudentEntity[]{};
                    }
                }
            });
        }
        catch(NullPointerException e){
            return new StudentEntity[]{};
        }
    }
}
</code></pre>

<p>Compile and package whithout errors. But if I try open /jira/secure/action.jspa, 
in console I get this:</p>

<pre><code>[INFO] [talledLocalContainer] 2016-06-30 09:38:15,837 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.OsgiServiceUtilsImpl] Registering service net.java.ao.atlassian.AtlassianTableNameConverter@16856656 with interface net.java.ao.schema.TableNameConverter and properties {com.atlassian.plugin.key=com.lemon.dbplugin.dbplugin}
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,839 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.OsgiServiceUtilsImpl] Registering service com.atlassian.activeobjects.config.internal.DefaultActiveObjectsConfiguration@3cf99a08 with interface com.atlassian.activeobjects.config.ActiveObjectsConfiguration and properties {com.atlassian.plugin.key=com.lemon.dbplugin.dbplugin}
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,845 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] onPluginModuleEnabledEvent storing unattached &lt;ao&gt; configuration module for [com.lemon.dbplugin.dbplugin]
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,875 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] onPluginEnabledEvent attaching unbound &lt;ao&gt; to [com.lemon.dbplugin.dbplugin]
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,876 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] init bundle [com.lemon.dbplugin.dbplugin]
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,876 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.lemon.dbplugin.dbplugin] loading new AO promise for JiraTenantImpl{id='system'}
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,876 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] setAoConfiguration [com.lemon.dbplugin.dbplugin]
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,876 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.lemon.dbplugin.dbplugin] got ActiveObjectsConfiguration
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,877 active-objects-init-JiraTenantImpl{id='system'}-0 DEBUG admin     [c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.lemon.dbplugin.dbplugin] creating ActiveObjects
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,905 active-objects-init-JiraTenantImpl{id='system'}-0 DEBUG admin     [c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.lemon.dbplugin.dbplugin] created ActiveObjects
[INFO] [talledLocalContainer] 2016-06-30 09:38:53,798 http-nio-2990-exec-12 ERROR admin 578x184x1 bnt30i 10.0.0.120 /secure/action.jspa [c.a.j.config.webwork.JiraActionFactory] Error autowiring Action 'com.lemon.dbplugin.ActionAlpha'.
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory$JiraPluginActionFactory.getActionImpl(JiraActionFactory.java:389)
[INFO] [talledLocalContainer]   at webwork.action.factory.PrefixActionFactoryProxy.getActionImpl(PrefixActionFactoryProxy.java:99)
[INFO] [talledLocalContainer]   at webwork.action.factory.JspActionFactoryProxy.getActionImpl(JspActionFactoryProxy.java:59)
[INFO] [talledLocalContainer]   at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.LookupAliasActionFactoryProxy.getActionImpl(LookupAliasActionFactoryProxy.java:61)
[INFO] [talledLocalContainer]   at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60)
[INFO] [talledLocalContainer]   at webwork.action.factory.ContextActionFactoryProxy.getActionImpl(ContextActionFactoryProxy.java:36)
[INFO] [talledLocalContainer]   at webwork.action.factory.PrepareActionFactoryProxy.getActionImpl(PrepareActionFactoryProxy.java:37)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory$SafeParameterSettingActionFactoryProxy.getActionImpl(JiraActionFactory.java:147)
[INFO] [talledLocalContainer]   at webwork.action.factory.ChainingActionFactoryProxy.getActionImpl(ChainingActionFactoryProxy.java:53)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory.getActionImpl(JiraActionFactory.java:301)
[INFO] [talledLocalContainer]   ... 2 filtered
[INFO] [talledLocalContainer]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
[INFO] [talledLocalContainer]   ... 55 filtered
[INFO] [talledLocalContainer]   at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59)
[INFO] [talledLocalContainer]   ... 27 filtered
[INFO] [talledLocalContainer]   at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59)
[INFO] [talledLocalContainer]   ... 38 filtered
[INFO] [talledLocalContainer]   at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
[INFO] [talledLocalContainer]   ... 38 filtered
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.lambda$invokeFilterChain$0(CustomerContextSettingFilter.java:169)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.util.scala.ScalaJavaInterOp$1.apply(ScalaJavaInterOp.java:25)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.utils.context.CustomerContextUtil$.outOfCustomerContext(CustomerContextUtil.scala:48)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.utils.context.CustomerContextUtil.outOfCustomerContext(CustomerContextUtil.scala)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.utils.context.CustomerContextServiceImpl.outOfCustomerContext(CustomerContextServiceImpl.java:24)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.outOfCustomerContext(CustomerContextSettingFilter.java:164)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilterImpl(CustomerContextSettingFilter.java:120)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilter(CustomerContextSettingFilter.java:112)
[INFO] [talledLocalContainer]   ... 55 filtered
[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 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:745)
[INFO] [talledLocalContainer] 2016-06-30 09:38:53,801 http-nio-2990-exec-12 ERROR admin 578x184x1 bnt30i 10.0.0.120 /secure/action.jspa [c.a.j.web.dispatcher.JiraWebworkActionDispatcher] Exception thrown from action 'action', returning 404
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory$JiraPluginActionFactory.getActionImpl(JiraActionFactory.java:389)
[INFO] [talledLocalContainer]   at webwork.action.factory.PrefixActionFactoryProxy.getActionImpl(PrefixActionFactoryProxy.java:99)
[INFO] [talledLocalContainer]   at webwork.action.factory.JspActionFactoryProxy.getActionImpl(JspActionFactoryProxy.java:59)
[INFO] [talledLocalContainer]   at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.LookupAliasActionFactoryProxy.getActionImpl(LookupAliasActionFactoryProxy.java:61)
[INFO] [talledLocalContainer]   at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60)
[INFO] [talledLocalContainer]   at webwork.action.factory.ContextActionFactoryProxy.getActionImpl(ContextActionFactoryProxy.java:36)
[INFO] [talledLocalContainer]   at webwork.action.factory.PrepareActionFactoryProxy.getActionImpl(PrepareActionFactoryProxy.java:37)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory$SafeParameterSettingActionFactoryProxy.getActionImpl(JiraActionFactory.java:147)
[INFO] [talledLocalContainer]   at webwork.action.factory.ChainingActionFactoryProxy.getActionImpl(ChainingActionFactoryProxy.java:53)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory.getActionImpl(JiraActionFactory.java:301)
[INFO] [talledLocalContainer]   ... 2 filtered
[INFO] [talledLocalContainer]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
[INFO] [talledLocalContainer]   ... 55 filtered
[INFO] [talledLocalContainer]   at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59)
[INFO] [talledLocalContainer]   ... 27 filtered
[INFO] [talledLocalContainer]   at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59)
[INFO] [talledLocalContainer]   ... 38 filtered
[INFO] [talledLocalContainer]   at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
[INFO] [talledLocalContainer]   ... 38 filtered
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.lambda$invokeFilterChain$0(CustomerContextSettingFilter.java:169)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.util.scala.ScalaJavaInterOp$1.apply(ScalaJavaInterOp.java:25)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.utils.context.CustomerContextUtil$.outOfCustomerContext(CustomerContextUtil.scala:48)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.utils.context.CustomerContextUtil.outOfCustomerContext(CustomerContextUtil.scala)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.utils.context.CustomerContextServiceImpl.outOfCustomerContext(CustomerContextServiceImpl.java:24)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.outOfCustomerContext(CustomerContextSettingFilter.java:164)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilterImpl(CustomerContextSettingFilter.java:120)
[INFO] [talledLocalContainer]   at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilter(CustomerContextSettingFilter.java:112)
[INFO] [talledLocalContainer]   ... 55 filtered
[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 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:745)
</code></pre>

<p>Sorry for the stupid question, what am I doing wrong?</p>