1

I am trying generate XSD/schema through eclipse.

I am getting the error below mentioned.

Address.class :

package blog.interfaces;


        public interface Address {

            public String getStreet();

            public void setStreet(String street);

        }

AddressImpl.class

 package blog.interfaces;

    public class AddressImpl implements Address {

        private String street;

        public String getStreet() {
            return street;
        }

        public void setStreet(String street) {
            this.street = street;
        }

    }

PhoneNumber.class

package blog.interfaces;

public interface PhoneNumber {

    String getValue();

    void setValue(String value);

}

PhoneNumberImpl.class

package blog.interfaces;

import javax.xml.bind.annotation.XmlValue;

public class PhoneNumberImpl implements PhoneNumber {

    private String value;

    @XmlValue
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}

Customer.class

package blog.interfaces;

import java.util.List;

public interface Customer {

    Address getAddress();

    void setAddress(Address address);

    List<PhoneNumber> getPhoneNumbers();

    void setPhoneNumbers(List<PhoneNumber> phoneNumbers);

}

CustomerImpl.class:

  package blog.interfaces;

    import java.util.List;

    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name="customer")
    public class CustomerImpl implements Customer {

        private Address address;
        private List<PhoneNumber> phoneNumbers;

        @XmlElement(type=AddressImpl.class)
        public Address getAddress() {
            return address;
        }

        public void setAddress(Address address) {
            this.address = address;
        }

        @XmlElement(type=PhoneNumberImpl.class, name="phone-number")
        public List<PhoneNumber> getPhoneNumbers() {
            return phoneNumbers;
        }

        public void setPhoneNumbers(List<PhoneNumber> phoneNumbers) {
            this.phoneNumbers = phoneNumbers;
        }

    }

ERROR from eclipse JAXB:

!loading...!

!blog.interfaces.PhoneNumberImpl!

!blog.interfaces.Customer!

!blog.interfaces.AddressImpl!

!blog.interfaces.Address!

!blog.interfaces.CustomerImpl!

!blog.interfaces.PhoneNumber!
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
blog.interfaces.Customer is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at blog.interfaces.Customer
blog.interfaces.Address is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at blog.interfaces.Address
        at public abstract blog.interfaces.Address blog.interfaces.Customer.getAddress()
        at blog.interfaces.Customer
blog.interfaces.PhoneNumber is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at blog.interfaces.PhoneNumber
        at public abstract java.util.List blog.interfaces.Customer.getPhoneNumbers()
        at blog.interfaces.Customer

    at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
    at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
    at org.eclipse.jpt.jaxb.core.schemagen.Main.buildJaxbContext(Main.java:99)
    at org.eclipse.jpt.jaxb.core.schemagen.Main.generate(Main.java:78)
    at org.eclipse.jpt.jaxb.core.schemagen.Main.execute(Main.java:64)
    at org.eclipse.jpt.jaxb.core.schemagen.Main.main(Main.java:49)

!
Schema src\main\java\NewXMLSchema.xsd not created!

Please help

raj
  • 107
  • 2
  • 11
  • can somebody reply please – raj Jul 04 '17 at 10:16
  • Did you read this topic?: https://stackoverflow.com/questions/4101718/jaxb-cant-handle-interfaces – Andrey Jul 04 '17 at 12:51
  • Hi Andrey, thanks for your reply.I am trying to generate xsd from eclipse.there how to change bootstrap of JAXBContext(as per the link suggested above). I am not using any java program here to marshal .I am using eclipse PLUGIN to geneate XSD.I Here I am not getting idea . – raj Jul 05 '17 at 16:11
  • can somebody reply please – raj Jul 17 '17 at 15:47
  • can somebody explain hiw to reresent interfaces in XSD.interfaces are not generating in XSD.Do i need to writexjb file that?Please help – raj Jul 18 '17 at 16:40

0 Answers0