Forums

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

JsonMarshallingException when using scripted field on view screen

Stefan Ernst
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 18, 2017

Hello,

we have a scripted field on a view screen that calculates the centralized release version based on the version entered in the issue.

 

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def searchProviderFactory = ComponentAccessor.getComponent(SearchProviderFactory)
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()

def customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField managedRelease = customFieldManager.getCustomFieldObject("customfield_11801");

def builder = JqlQueryBuilder.newBuilder().where().defaultOr()
def clauseBuilder = JqlQueryBuilder.newClauseBuilder().defaultAnd()
clauseBuilder.project(issue.getProjectObject().getId());

if(issue.getFixVersions() == null || issue.getFixVersions().size() < 1)
	return "";

clauseBuilder.fixVersion(issue.getFixVersions().iterator().next().getName());
clauseBuilder.issueType("10402");
builder.addClause(clauseBuilder.buildClause())

def query = builder.buildQuery()
def result = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter());

if(result.getIssues().size() > 0)
	return result.getIssues().get(0).getCustomFieldValue(managedRelease);
else
    return "";

the script works fine, it executes without errors. However when creating a new issue, Jira 7.3.5 (previously 7.1.9 worked fine) throws the following exception

 

com.atlassian.plugins.rest.common.json.JsonMarshallingException: org.codehaus.jackson.map.JsonMappingException: No serializer found for class com.atlassian.jira.issue.customfields.option.LazyLoadedOption and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.atlassian.jira.quickedit.rest.api.field.QuickEditFields["createdIssueDetails"]->com.atlassian.jira.rest.v2.issue.IssueBean["fields"]->java.util.HashMap["customfield_12601"])
 at com.atlassian.plugins.rest.common.json.DefaultJaxbJsonMarshaller.marshal(DefaultJaxbJsonMarshaller.java:57)

 

the mentioned custom field is the ID of the scripted field above.

We have no searcher configured as it is only a display field. Is there any way to avoid the exception?

1 answer

1 vote
Stephen Cheesley [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 22, 2017

Hi Stefan,

I have been looking into your issue, and I have tried your script on Jira version 7.3.5 and it seems to run without porblems. I do have some questions that might help get to the bottom of your issue.

You mentioned "the mentioned custom field is the ID of the scripted field above.", however if I set the custom field ID to that of the scripted field (CustomField managedRelease = customFieldManager.getCustomFieldObject("customfield_11801")), I get a StackOverflow error because essentially the script is retrieving its own value. It works for me when I reference a different (text field) custom value on that line instead. Can you maybe provide me with a screenshots of your custom fields, or confirm which field this ID should be?

Thanks,

Steve

Stefan Ernst
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2017

Hi Stephen,

thank you for checking this out.

My script is looking for an issue of type "Managed Release"

clauseBuilder.issueType("10402");

which carries a custom field called managed release version (11801)

The scripted field 12601 is essentially a script that displays the custom field value in all issue that carry a fixversion that corresponds to the fixversion of the Managed Release issue type.

best regards

Stefan

Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 12, 2017

Hi Stefan,

Try return a string instead, so in your return line 

    return result.getIssues().get(0).getCustomFieldValue(managedRelease)?.toString()

Let us know if this fix the issue.

Jozef Kotlár
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2017

Hi Thanos,

I have stumbled on similar bug and result.toString() solved problem.

Thanks, Jozef

Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2017

Hey Jozef, thanks for letting us know :)

cheers, Thanos

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events