Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6168645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:43:21+00:00 2026-05-23T22:43:21+00:00

I have a bean with CommonsMultipartFile type field like so: public class Placement implements

  • 0

I have a bean with CommonsMultipartFile type field like so:

public class Placement implements Serializable {

private static final long serialVersionUID = 1L;

private long placementId;
private String type;
private String placement;
private transient CommonsMultipartFile fileData;

I have marked CommonsMultipartFile field as transient and trying to serialize to json using jackson library. But getting following error:

org.codehaus.jackson.map.JsonMappingException: No serializer found for class java.io.ByteArrayInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: nextag.travel.dashboard.model.Placement["fileData"]->org.springframework.web.multipart.commons.CommonsMultipartFile["inputStream"])

Any help/ suggestions would be highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:43:22+00:00Added an answer on May 23, 2026 at 10:43 pm

    It’s not clear how Jackson is being used, as no code or description was provided in the original question.

    By default, Jackson skips all transient fields during serialization.

    import java.io.Serializable;
    
    import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
    import org.codehaus.jackson.map.ObjectMapper;
    
    public class Foo
    {
      public static void main(String[] args) throws Exception
      {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
        System.out.println(mapper.writeValueAsString(new Placement()));
        // output:  {"placementId":42,"type":"OK","placement":"left"}
        // transient fields are skipped by default
      }
    }
    
    class Placement implements Serializable
    {
      private static final long serialVersionUID = 1L;
    
      private long placementId = 42;
      private String type = "OK";
      private String placement = "left";
      private transient CommonsMultipartFile fileData = new CommonsMultipartFile();
    }
    
    class CommonsMultipartFile
    {
      private String name = "Fred";
    }
    

    If there is a getter for the transient field, however, then by default Jackson includes it during serialization.

    import java.io.Serializable;
    
    import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
    import org.codehaus.jackson.map.ObjectMapper;
    
    public class Foo
    {
      public static void main(String[] args) throws Exception
      {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
        System.out.println(mapper.writeValueAsString(new Placement()));
        // output: {"placementId":42,"type":"OK","placement":"left","fileData":{"name":"Fred"}}
        // transient fields with getters are not skipped by default
      }
    }
    
    class Placement implements Serializable
    {
      private static final long serialVersionUID = 1L;
    
      private long placementId = 42;
      private String type = "OK";
      private String placement = "left";
      private transient CommonsMultipartFile fileData = new CommonsMultipartFile();
    
      public CommonsMultipartFile getFileData() {return fileData;}
    }
    
    class CommonsMultipartFile
    {
      private String name = "Fred";
    }
    

    One configuration option to skip the getter is to just apply the @JsonIgnore annotation.

    import java.io.Serializable;
    
    import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
    import org.codehaus.jackson.annotate.JsonIgnore;
    import org.codehaus.jackson.map.ObjectMapper;
    
    public class Foo
    {
      public static void main(String[] args) throws Exception
      {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
        System.out.println(mapper.writeValueAsString(new Placement()));
        // output: {"placementId":42,"type":"OK","placement":"left"}
        // getters marked with @JsonIgnore are ignored
      }
    }
    
    class Placement implements Serializable
    {
      private static final long serialVersionUID = 1L;
    
      private long placementId = 42;
      private String type = "OK";
      private String placement = "left";
      private transient CommonsMultipartFile fileData = new CommonsMultipartFile();
    
      @JsonIgnore
      public CommonsMultipartFile getFileData() {return fileData;}
    }
    
    class CommonsMultipartFile
    {
      private String name = "Fred";
    }
    

    If it’s not possible or desirable to edit the original class definition to add the @JsonIgnore annotation, a Mix-In can be used.

    import java.io.Serializable;
    
    import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
    import org.codehaus.jackson.annotate.JsonIgnore;
    import org.codehaus.jackson.map.ObjectMapper;
    
    public class Foo
    {
      public static void main(String[] args) throws Exception
      {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
        mapper.getSerializationConfig().addMixInAnnotations(Placement.class, SkipFileDataMixIn.class);
        System.out.println(mapper.writeValueAsString(new Placement()));
        // output: {"placementId":42,"type":"OK","placement":"left"}
        // getters marked with @JsonIgnore are ignored
      }
    }
    
    abstract class SkipFileDataMixIn
    {
      @JsonIgnore
      public abstract CommonsMultipartFile getFileData();
    }
    
    class Placement implements Serializable
    {
      private static final long serialVersionUID = 1L;
    
      private long placementId = 42;
      private String type = "OK";
      private String placement = "left";
      private transient CommonsMultipartFile fileData = new CommonsMultipartFile();
    
      public CommonsMultipartFile getFileData() {return fileData;}
    }
    
    class CommonsMultipartFile
    {
      private String name = "Fred";
    }
    

    Another approach is to mark the type to be skipped with @JsonIgnoreType.

    import java.io.Serializable;
    
    import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
    import org.codehaus.jackson.annotate.JsonIgnoreType;
    import org.codehaus.jackson.map.ObjectMapper;
    
    public class Foo
    {
      public static void main(String[] args) throws Exception
      {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setVisibilityChecker(mapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY));
        System.out.println(mapper.writeValueAsString(new Placement()));
        // output: {"placementId":42,"type":"OK","placement":"left"}
        // Types marked with @JsonIgnoreType are ignored during serialization.
      }
    }
    
    class Placement implements Serializable
    {
      private static final long serialVersionUID = 1L;
    
      private long placementId = 42;
      private String type = "OK";
      private String placement = "left";
      private transient CommonsMultipartFile fileData = new CommonsMultipartFile();
    
      public CommonsMultipartFile getFileData() {return fileData;}
    }
    
    @JsonIgnoreType
    class CommonsMultipartFile
    {
      private String name = "Fred";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Session scoped bean @SessionScoped public class UserData implements Serializable { private
I have this bean: @ManagedBean(name=langListing) @ViewScoped public class LangListing implements Serializable { private List<SelectItem>
I have a managed bean called: @ManagedBean(name=configBean) @SessionScoped public class configBean implements Serializable {
I have a Bean that looks like this Class Person{ private String name; private
I have one bean like: public class Car{ String color; List<Wheel> wheels; .... }
If I have a bean such as public class SimpleBean { private String name;
Assume I have a bean DialogBox, with properties for height and width: public class
I have a bean with a field fftLength. When I call public void setfftLength(String
I have this bean @XmlRootElement class Test { boolean someValue; List<Field> fields; } I
I have two bean Code: public class ApplContactDtl { ....... And Code: public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.