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 234257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:10:13+00:00 2026-05-11T20:10:13+00:00

How can I keep my using interfaces in classes I want to use JiBX

  • 0

How can I keep my using interfaces in classes I want to use JiBX binding with?

Example:
I have this very simple model in java:

public interface A {
    B getB();
    void setB(B b);
}

public interface B {
    String getData();
    void setData(String data);
}

public class AImpl implements A {
    B b;

    @Override
    public B getB() {
        return b;
    }

    @Override
    public void setB(B b) {
        this.b = b;     
    }
}

public class BImpl implements B {
    private String data;
    @Override
    public String getData() {
        return data;
    }

    @Override
    public void setData(String data) {
        this.data = data;
    }
}

And this binding document:

<binding>
<mapping name="A"
         class="com.test.AImpl">
    <structure name="B" usage="optional" get-method="getB" set-method="setB"/>
</mapping>
<mapping name="B"
         class="com.test.BImpl">
    <value name="data" set-method="setData" get-method="getData" usage="optional"/>
</mapping>
</binding>

When I try to run my code I get this exception:

java.lang.ClassFormatError: Method
in class com/test/B has illegal
modifiers: 0x1001

I’ve tried to use ‘abstract=”true”‘ on both mapping, only to get this exception:

…Caused by:
org.jibx.runtime.JiBXException: Unable
to access binding information for
class com.test.A Make sure the binding
has been compiled…

The only solution I’ve found is to have AImpl hold a BImpl instead of a B, and have the getter return BImpl and the setter recieve BImpl. This is very wrong as it breaks the interface completely.

How can I solve this? I’ve been pulling hairs out, having tantrums (the real issue is much more complex, and JiBX cryptic error messages don’t help) – nothing help.

Is this solvable? Is JiBX really that intrusive (in that it requires me to abandon all interface programming?)

Please don’t answer “use AbstractB” as it’s the same problem, only one level removed.

  • 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-11T20:10:13+00:00Added an answer on May 11, 2026 at 8:10 pm

    In the mapping, you should be able use the “create-type” attribute to specify the concrete class that JiBX should instantiate for bean properties that have an interface type. I use this a lot for collection properties. For example, you can tell JiBX to instantiate a java.util.HashSet for a property of type java.util.Set. But I believe it works just as well for non-collection properties. Your mapping would look something like:

    <mapping class="com.mypackage.AImpl" name="A">
      <structure get-method="getB" set-method="setB" create-type="com.mypackage.BImpl">
        ...
      </structure>
      ...
    </mapping>
    

    JiBX will call the no-arg constructor to create the B object. Alternatively, you could use a factory or a custom serializer/deserializer if you need fancy instantiation logic. See this reference page for details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer WCF provides support for REST-style services since the release of… May 12, 2026 at 12:02 am
  • Editorial Team
    Editorial Team added an answer Well, firstly I would suggest that dynamically adding and removing… May 12, 2026 at 12:02 am
  • Editorial Team
    Editorial Team added an answer Your code snippet works for me, so there's nothing inherently… May 12, 2026 at 12:02 am

Related Questions

The Unity documentation states: if a class that developers instantiate using the Resolve method
I'm trying to optimize the size of my Delphi classes so that they take
Any using nHibernate with a Domain object & DTO object implemented from a common
Following on from my recent question on Large, Complex Objects as a Web Service

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.