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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:32:41+00:00 2026-06-09T05:32:41+00:00

I am trying to map the below interface using Moxy’s XML Metadata extension. But

  • 0

I am trying to map the below interface using Moxy’s XML Metadata extension. But when I try to load it, I am getting the below error. I can’t add a public constructor to the AddressType as it is an enum.

My question is: Why is Moxy impl looking at AddressType even though I didn’t specify in the xml metadata?

public interface TokenizedUnitedStatesAddress
{
    class AddressType extends Enum
    {
        public static final AddressType STREET = new AddressType("street");    
        public static final AddressType PO_BOX = new AddressType("poBox");    
        public static final AddressType RURAL_ROUTE = new AddressType("ruralRoute");

        public static AddressType getEnum(final String type)
        {
            return (AddressType) getEnum(AddressType.class, type);
        }

        protected AddressType(final String name)
        {
            super(name);
        }
    }

    String getApartmentNumber();

    //removed other getters for brevity
}

<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/oxm http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_4.xsd"
   version="2.4" package-name="com.abc.ic.domain.country.us">
   <java-types>
      <java-type name="TokenizedUnitedStatesAddress">
         <xml-root-element />
         <xml-type
            prop-order="StreetPreDirection StreetNumber StreetName StreetType StreetPostDirection UnitDesignator UnitNumber AddressLine1 AddressLine2 City State PostalCode CarrierRoute LengthAtAddress OwnershipStatus" />
         <java-attributes>
            <xml-element name="StreetPreDirection" java-attribute="preDirectional" />
            <xml-element name="StreetNumber" java-attribute="houseNumber" />
            <xml-element name="StreetName" java-attribute="streetName" />
            <xml-element name="StreetType" java-attribute="streetType" />
            <xml-element name="StreetPostDirection" java-attribute="postDirection" />
            <xml-element name="UnitNumber" java-attribute="apartmentNumber" />
            <xml-element name="AddressLine1" java-attribute="primaryAddress" />
            <xml-element name="AddressLine2" java-attribute="secondaryAddress" />
            <xml-element name="City" java-attribute="cityName" />
            <xml-element name="State" java-attribute="stateAbbreviation" />
            <xml-element name="PostalCode" java-attribute="zipCode" />
         </java-attributes>
      </java-type>
   </java-types>
</xml-bindings>

javax.xml.bind.JAXBException: 
Exception Description: The class com.abc.ic.domain.country.us.TokenizedUnitedStatesAddress$AddressType requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.
 - with linked exception:
[Exception [EclipseLink-50001] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The class com.abc.ic.domain.country.us.TokenizedUnitedStatesAddress$AddressType requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.]
    at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:908)
    at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:157)
    at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:170)
    at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:157)
    at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:117)
    at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:107)
  • 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-06-09T05:32:44+00:00Added an answer on June 9, 2026 at 5:32 am

    I am a developer on the EclipseLink MOXy team, and I’ve been looking at this issue. You are correct as to why the AddressType class was introspected, and I see that you have a workaround.

    Another solution would be to create an XmlAdapter that can convert between Apache Enum classes and their XML (string) representation, as follows:

    import javax.xml.bind.annotation.adapters.XmlAdapter;
    
    import org.apache.commons.lang.enums.Enum;
    
    import enumbindings.TokenizedUnitedStatesAddress.AddressType;
    
    public class ApacheEnumAdapter extends XmlAdapter<String, Enum> {
    
        public ApacheEnumAdapter() {
        }
    
        @Override
        public Enum unmarshal(String s) throws Exception {
            return AddressType.getEnum(s);
        }
    
        @Override
        public String marshal(Enum e) throws Exception {
            if (null == e) {
                return null;
            }
            return e.getName();
        }
    
    }
    

    And then hook up the adapter in your bindings file like this:

    ...
    <xml-element name="StreetType" java-attribute="streetType">
        <xml-java-type-adapter value="enumbindings.ApacheEnumAdapter" />
    </xml-element>
    ...
    

    As far as the bug you entered, EclipseLink is actually behaving correctly in this situation, we do not do any special handling of Apache Commons classes and so a default no-arg constructor (or some other handling mechanism) is still required. However I will update your bug and change it to an enhancement request to support Apache Enums out of the box, and we will evaluate it.

    Thanks,

    Rick

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

Sidebar

Related Questions

I've been trying to map an object to a database using SQLAlchemy but have
I am trying to deserialize/map the below JSON to List<Bill > java object using
I am trying to load google map on the anchor click. Below are the
I'm trying to move a unordered_map of unique_ptr's into another map, but getting the
I am trying to map the ReferralContract.AssessmentId property to Referral.Assessment.Id The below code works
Trying to map the following schema using the Entity Framework. A Customer can have
I am trying to load a file into a Map with a method as
I am trying to get the below code snippet to compile. But it fails
I'm getting this error trying to implement the sample WCF Dependency Injection with Unity.
I'm trying to access a custom Java generic stored in a map as below.

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.