Get a error when I deploy my app into jira server,I used activeobjects

When I was atlass-debug, everything was good. but when I installed my plug-in into the production environment, I got the following error. I don’t know how to deal with it. Please help me find out what’s wrong with it.

java.lang.NullPointerException
	at java.lang.Class.isAssignableFrom(Native Method)
	at net.java.ao.types.TypeManager.getType(TypeManager.java:51)
	at net.java.ao.types.TypeManager.getType(TypeManager.java:45)
	at net.java.ao.Common.getValueFields(Common.java:486)
	at net.java.ao.EntityManager.create(EntityManager.java:376)
	at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.create(EntityManagedActiveObjects.java:89)
	at com.atlassian.activeobjects.osgi.DelegatingActiveObjects.create(DelegatingActiveObjects.java:56)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at com.sun.proxy.$Proxy1701.create(Unknown Source)
	at com.hktx.gears.usagestatistics.services.ServiceUsageLog.recordLogThree(ServiceUsageLog.java:831)
	at com.hktx.gears.usagestatistics.rest.LogResource.recordLogPOST(LogResource.java:90)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

my pom.xml is

    <dependencies>
        <!--<dependency>-->
        <!--&lt;!&ndash; intentionally have this as compile scope &ndash;&gt;-->
        <!--<groupId>com.atlassian.upm</groupId>-->
        <!--<artifactId>licensing-legacy-compatibility-spi</artifactId>-->
        <!--<version>2.2</version>-->
        <!--<scope>compile</scope>-->
        <!--</dependency>-->
        <!--<dependency>-->
        <!--<groupId>com.atlassian.upm</groupId>-->
        <!--<artifactId>licensing-api</artifactId>-->
        <!--<version>2.2</version>-->
        <!--<scope>provided</scope>-->
        <!--</dependency>-->
        <!--<dependency>-->
        <!--<groupId>com.atlassian.upm</groupId>-->
        <!--<artifactId>upm-api</artifactId>-->
        <!--<version>2.2</version>-->
        <!--<scope>provided</scope>-->
        <!--</dependency>-->

        <!--<dependency>-->
        <!--<groupId>com.atlassian.extras</groupId>-->
        <!--<artifactId>atlassian-extras</artifactId>-->
        <!--<version>2.2.2</version>-->
        <!--</dependency>-->

        <!--<dependency>-->
        <!--<groupId>com.atlassian.upm</groupId>-->
        <!--<artifactId>atlassian-universal-plugin-manager-plugin</artifactId>-->
        <!--<version>1.1.35</version>-->
        <!--<scope>provided</scope>-->
        <!--</dependency>-->
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.1.35</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.9</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.9.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.9.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.33</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>2.5.6.SEC02</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
        <!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-plugin</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-common</artifactId>
            <version>1.0.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <version>${ao.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-test</artifactId>
            <version>${ao.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.java.dev.activeobjects</groupId>
            <artifactId>activeobjects-test</artifactId>
            <version>0.9.23</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.templaterenderer</groupId>
            <artifactId>atlassian-template-renderer-api</artifactId>
            <version>${template.renderer.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>

        <!-- WIRED TEST RUNNER DEPENDENCIES -->
        <!--<dependency>-->
        <!--<groupId>com.atlassian.plugins</groupId>-->
        <!--<artifactId>atlassian-plugins-osgi-testrunner</artifactId>-->
        <!--<version>${plugin.testrunner.version}</version>-->
        <!--<scope>test</scope>-->
        <!--</dependency>-->

        <!--<dependency>-->
        <!--<groupId>com.atlassian.plugins</groupId>-->
        <!--<artifactId>atlassian-plugins-osgi-testrunner</artifactId>-->
        <!--<version>${plugin.testrunner.version}</version>-->
        <!--<scope>test</scope>-->
        <!--</dependency>-->

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.3</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.apache.ibatis</groupId>
            <artifactId>ibatis-sqlmap</artifactId>
            <version>2.3.4.726</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>2.5.6.SEC02</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <pluginArtifacts>
                        <!--<pluginArtifact>-->
                        <!--<groupId>com.atlassian.activeobjects</groupId>-->
                        <!--<artifactId>activeobjects-plugin</artifactId>-->
                        <!--<version>${ao.version}</version>-->
                        <!--</pluginArtifact>-->
                        <pluginArtifact>
                            <groupId>com.atlassian.activeobjects</groupId>
                            <artifactId>activeobjects-jira-spi</artifactId>
                            <version>${ao.version}</version>
                        </pluginArtifact>
                    </pluginArtifacts>
                    <productVersion>${jira.version}</productVersion>
                    <productDataVersion>${jira.version}</productDataVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <!--<version>2.5.1</version>-->
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!--<jira.version>5.2.7</jira.version>-->
        <jira.version>6.0.1</jira.version>
        <!--<amps.version>4.2.0</amps.version>-->
        <amps.version>5.0.4</amps.version>
        <ao.version>0.22.1</ao.version>
        <template.renderer.version>1.4.2.2</template.renderer.version>
        <!--<plugin.testrunner.version>1.1</plugin.testrunner.version>-->
    </properties>

altassian-plugins.xml

   <ao key="gears-usagestatistics-ao-module" name="Gears Usagestatistics Active Objects Module">
        <entity>com.hktx.ao.CountLogGroupAO</entity>
        <entity>com.hktx.ao.CountLogUserAO</entity>
        <entity>com.hktx.ao.LogAO</entity>
        <entity>com.hktx.ao.GroupMemberAO</entity>
        <entity>com.hktx.ao.LoginLogAO</entity>
    </ao>

Can you paste the code for your entities?

thank you for you reply.

this is my AO code

public interface UsageCountLogGroupAO extends Entity {
    public static String COLUNM_KEYS =
            " ID,GROUP_NAME,CLICK_NUM"+
                    ",YMD,YEAR_NUM,MONTH_NUM,WEEK_NUM,DAY_YEAR,DAY_MONTH,DAY_WEEK,HOLIDAY";

    public static String COLUNM_KEYS_GROURNAME = "GROUP_NAME";

    @Indexed
    @StringLength(255)
    public void setGroup_name(String group_name);
    public String getGroup_name();


    public void setClick_num(Long click_num);
    public Long getClick_num();

    @StringLength(10)
    @Indexed
    public void setYmd(String ymd);
    public String getYmd();

    @Indexed
    public void setYear_num(int year_num);
    public int getYear_num();

    @Indexed
    public void setMonth_num(int month_num);
    public int getMonth_num();

    @Indexed
    public void setWeek_num(int week_num);
    public int getWeek_num();


    public void setDay_year(int day_year);
    public int getDay_year();


    public void setDay_month(int day_month);
    public int getDay_month();

    @Indexed
    public void setDay_week(int day_week);
    public int getDay_week();

    @Indexed
    public void setHoliday(boolean holiday);
    public boolean isHoliday();
}

this is my Service

 package com.hktx.gears.usagestatistics.services;

import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.crowd.embedded.api.Group;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.plugin.util.collect.Consumer;
import com.hktx.ao.*;
import com.hktx.beans.HolidayEntity;
import com.hktx.beans.LineEntity;
import com.hktx.beans.PageVo;
import com.hktx.entity.UsageCountLogEntity;
import com.hktx.entity.UsageLogEntity;
import com.hktx.utils.DateUtils;
import com.hktx.utils.Utils;
import net.java.ao.EntityStreamCallback;
import net.java.ao.Query;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * Created by seven on 2018/3/17.
 */
@Service("serviceUsageLog")
public class ServiceUsageLog {
    @Autowired
    private ActiveObjects ao;

    public ServiceUsageLog(ActiveObjects ao) {
        this.ao = ao;
    }
    public List<UsageCountLogGroupAO> queryUsageCountLogListByGroup(String begintime, String endtime, String group) {
        final List<UsageCountLogGroupAO> groupAOList = new ArrayList();
        if (StringUtils.isEmpty(group)) {
            return groupAOList;
        }

        StringBuffer sql = new StringBuffer();
        sql.append(" YMD >= ? ");
        sql.append(" AND YMD <= ? ");
        sql.append(" AND GROUP_NAME = ? ");

        Query query = Query.select(UsageCountLogGroupAO.COLUNM_KEYS);
        query.where(sql.toString(), begintime, endtime,group);

        final Consumer consumer = new Consumer<UsageCountLogGroupAO>() {
            @Override
            public void consume(UsageCountLogGroupAO entityAo) {
                groupAOList.add(entityAo);
            }
        };
        ao.stream(UsageCountLogGroupAO.class, query, new EntityStreamCallback<UsageCountLogGroupAO, Long>() {
            @Override
            public void onRowRead(UsageCountLogGroupAO entityAo) {
                consumer.consume(entityAo);
            }
        });

        return groupAOList;
    }
}

this is my atlassian-plugin.xml

<?xml version="1.0" encoding="UTF-8"?>

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

        <!--<param name="atlassian-licensing-enabled">true</param>-->
    </plugin-info>

    <resource type="i18n" name="i18n" location="usagestatistics/templetes/i18n/gearsusagestatistics"/>


    <ao key="gears-usagestatistics-ao-module" name="Gears Usagestatistics Active Objects Module">
        <entity>com.hktx.ao.UsageCountLogGroupAO</entity>
        <entity>com.hktx.ao.UsageCountLogUserAO</entity>
        <entity>com.hktx.ao.UsageLogAO</entity>
        <entity>com.hktx.ao.UsageGroupMemberAO</entity>
        <entity>com.hktx.ao.UsageLoginLogAO</entity>
    </ao>


    <web-section key="gears-usagestatistics-section" location="admin_plugins_menu">
    </web-section>

    <web-section key="gears-usagestatistics-actions" location="gears-usagestatistics-section">
        <label key="usagestatistics.web-section.config.label"
               i18n-name-key="usagestatistics.web-section.config.label"/>
    </web-section>

    <web-item key="gears-usagestatistics-actions-section-webitem-config"
              section="gears-usagestatistics-section/gears-usagestatistics-actions" weight="0">
        <label key="config-all"/>
        <link linkId="gears-usagestatistics-usageConfigAction">/secure/usageConfigAction!mainpage.jspa</link>
    </web-item>


    <web-item key="gears-usagestatistics-actions-section-webitem"
              section="gears-usagestatistics-section/gears-usagestatistics-actions" weight="1">
        <label key="usagestatistics.web-section.config.usageReportAction"
               i18n-name-key="usagestatistics.web-section.config.usageReportAction"/>
        <link linkId="gears-usagestatistics-usageConfigAction">/secure/usageReportAction!mainpage.jspa</link>
    </web-item>


    <webwork1 key="gears-usagestatistics-usageReportAction"
              name="gears-usagestatistics-usageReportAction"
              class="java.lang.Object">
        <actions>
            <action alias="usageReportAction"
                    name="com.hktx.gears.usagestatistics.actions.UsageReportAction">
                <view name="mainpage">
                    /usagestatistics/templetes/actions/main.vm
                </view>
            </action>

            <action alias="usageConfigAction"
                    name="com.hktx.gears.usagestatistics.actions.UsageConfigAction">
                <view name="mainpage">
                    /usagestatistics/templetes/actions/config/main.vm
                </view>
            </action>

        </actions>
    </webwork1>


    <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties"/>
    <component-import key="ao" interface="com.atlassian.activeobjects.external.ActiveObjects"/>
    <component-import key="userManager" interface="com.atlassian.sal.api.user.UserManager"/>
    <component-import key="templateRenderer" interface="com.atlassian.templaterenderer.TemplateRenderer"/>
    <component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher"/>
    <component-import key="userPreferencesManager"
                      interface="com.atlassian.jira.user.preferences.UserPreferencesManager"/>
    <component key="jiraCaptchaService" name="jiraCaptchaService"
               class="com.atlassian.jira.servlet.JiraCaptchaServiceImpl"/>
    <component key="externalLinkUtil" name="externalLinkUtil" class="com.atlassian.jira.web.util.ExternalLinkUtilImpl"/>
    <component key="jiraDurationUtils" name="jiraDurationUtils" class="com.atlassian.jira.util.JiraDurationUtils"/>
    <component-import key="pluginLicenseManager" interface="com.atlassian.upm.api.license.PluginLicenseManager"/>

    <component key="serviceUsageLog" name="serviceUsageLog"
               class="com.hktx.gears.usagestatistics.services.ServiceUsageLog"/>

    <rest key="gearsusagestatistics-rest" path="/usages" version="1.0">
        <description>gears usage statistics</description>
    </rest>

    <component-import key="txTemplate" interface="com.atlassian.sal.api.transaction.TransactionTemplate"/>
    <component-import key="loginUriProvider" interface="com.atlassian.sal.api.auth.LoginUriProvider"/>

    <component-import key="i18nResolver" interface="com.atlassian.sal.api.message.I18nResolver"/>

    <component key="GearsUsageListener"
               class="com.hktx.gears.usagestatistics.jiraext.GearsListener">
        <description>GearsUsageListener</description>
    </component>

</atlassian-plugin>

I run my addons on jira6.0.1. when i use atlass-debug ,everything is ok…
the database is oracle11g!

thank you!

So a couple of suggestions (in order):

  1. Change from int to Integer
  2. The _ in the method names might be causing confusions - go with CamelCasing and let AO do it’s thing
  3. Move the static vars to a different class.

I try to do it .but still the same error.

I find somthings:

    • I will make mistakes when I perform ao.save() operation, and ao.find() is ok.
    • I check the code about net.java.ao.Common(version:0.22.1) ,I cound find the methd the getValueFields(Common.java:486) but it Appeared in error message.
    • I can run my addon throgth atlas-debug, but it is error in production environment;

I think I quoted the wrong version of the package, but I’m not sure what to quote.
my jira version is 6.0.1

this is my result about ao.find()

thank you vary much!!!
The cause of the problem is that My AO entity did not directly inherit net.java.ao.Entity.
change to

public interface UsageLogAO extends net.java.ao.Entity

The problem is solved!

My original code is

public interface Entity extends RawEntity<Long>
{
    @AutoIncrement
    @NotNull
    @PrimaryKey("ID")
    public Long getId();
    public void setId();
}

net.java.ao.Entity is

public interface Entity extends RawEntity<Integer> {

	@AutoIncrement
	@NotNull
	@PrimaryKey("ID")
	public int getID();
}