Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveObjects v1.1.5 in jira 7.0.4 error

SALAH Abderraouf September 20, 2023

this is my code 

package io.codeclou.kitchen.duty.rest;

import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.plugins.rest.common.security.AnonymousAllowed;
import com.atlassian.sal.api.transaction.TransactionCallback;
import io.codeclou.kitchen.duty.ao.Week;

import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Named
@Path("/planning")
public class KitchenDutyPlanningResource {

private ActiveObjects activeObjects;

public KitchenDutyPlanningResource(ActiveObjects activeObjects) {
this.activeObjects = activeObjects;
}

public KitchenDutyPlanningResource() {
}


@GET
@Path("/persistTest")
@Produces({MediaType.APPLICATION_JSON})
@AnonymousAllowed
public Response persistTest() {
activeObjects.executeInTransaction(new TransactionCallback<Week>()
{
@Override
public Week doInTransaction()
{
final Week testWeek = activeObjects.create(Week.class);
testWeek.setWeek(42);
testWeek.save();
return testWeek;
}
});
return Response.ok("ok").build();
}

@GET
@Path("/health")
@Produces({MediaType.APPLICATION_JSON})
@AnonymousAllowed
public Response health() {
return Response.ok("ok").build();
}

} and i got this error
 <status-code>500</status-code>
    <stack-trace>java.lang.NullPointerException&#xD;
    at io.codeclou.kitchen.duty.rest.KitchenDutyPlanningResource.persistTest(KitchenDutyPlanningResource.java:34)&#xD;
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&#xD;
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)&#xD;
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&#xD;
    at java.lang.reflect.Method.invoke(Method.java:498)&#xD;
    at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper$ResponseOutInvoker$1.invoke(DispatchProviderHelper.java:234)&#xD;
    at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper$1.intercept(DispatchProviderHelper.java:100)&#xD;
    at com.atlassian.plugins.rest.common.interceptor.impl.DefaultMethodInvocation.invoke(DefaultMethodInvocation.java:61)&#xD;
    at com.atlassian.plugins.rest.common.expand.interceptor.ExpandInterceptor.intercept(ExpandInterceptor.java:38)&#xD;
    at com.atlassian.plugins.rest.common.interceptor.impl.DefaultMethodInvocation.invoke(DefaultMethodInvocation.java:61)&#xD;
    at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper.

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
1.1.5
TAGS
AUG Leaders

Atlassian Community Events