Map xsd complex type to existing java class without adding JAXB annotations

Hello
I've got a case where I should map an xsd complex type to an existing Java class without modifying that class, i.e. without adding JAXB annotations to that class.
Is this possible somehow?
As far as I've understood, the <javaType> declaration (adapter, parse/print methods) can only be used for xsd simple types.
Thanks, Tom

It should be possible to implement an XmlAdapter<...,...> which performs the required conversion between the original type and a JAXB-annotated type. Then, at the places where the original type is used, the @XmlJavaTypeAdapter annotation would be used.
The xjc compiler supports this for xsd simple types (xjc:javaType annotation), but not for complex types.
Any idea why this is restricted to simple types?
Would it be possible to implement a xjc plugin which does this for complex types?
Thanks Tom.

Similar Messages

  • How to map XSD complex type nodes

    Hello In my XSD I have complex type like this:
    How to map this node to Target filed, I can not see PostalCode node my graphical editor:
    <xs:element name="InternationalAddress" nillable="true" type="tns:InternationalAddress" />
      <xs:complexType name="CanadianAddress">
        <xs:complexContent mixed="false">
          <xs:extension base="tns:Address">
            <xs:sequence>
              <xs:element minOccurs="0" name="PostalCode" nillable="true" type="xs:string">
              </xs:element>
              <xs:element minOccurs="0" name="Province" nillable="true" type="tns:ProvinceCodes" />
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>

    How to handle this in my graphical mapping:
    <xs:complexType name="Address">
        <xs:complexContent mixed="false">
          <xs:extension base="tns:BusinessObject">
            <xs:sequence>
              <xs:element minOccurs="0" name="City" nillable="true" type="xs:string">
              </xs:element>
              <xs:element minOccurs="0" name="Country" nillable="true" type="xs:string">
              </xs:element>
              <xs:element minOccurs="0" name="Line1" nillable="true" type="xs:string">
              </xs:element>
              <xs:element minOccurs="0" name="Line2" nillable="true" type="xs:string">
              </xs:element>
              <xs:element minOccurs="0" name="Line3" nillable="true" type="xs:string">
              </xs:element>
              <xs:element minOccurs="0" name="Line4" nillable="true" type="xs:string">
              </xs:element>
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:element name="Address" nillable="true" type="tns:Address" />
      <xs:complexType name="InternationalAddress">
        <xs:complexContent mixed="false">
          <xs:extension base="tns:Address">
            <xs:sequence>
              <xs:element minOccurs="0" name="Region" nillable="true" type="xs:string">
              </xs:element>
              <xs:element minOccurs="0" name="PostalCode" nillable="true" type="xs:string">
              </xs:element>
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:element name="InternationalAddress" nillable="true" type="tns:InternationalAddress" />
      <xs:complexType name="CanadianAddress">
        <xs:complexContent mixed="false">
          <xs:extension base="tns:Address">
            <xs:sequence>
              <xs:element minOccurs="0" name="PostalCode" nillable="true" type="xs:string">
              </xs:element>
              <xs:element minOccurs="0" name="Province" nillable="true" type="tns:ProvinceCodes" />
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:element name="CanadianAddress" nillable="true" type="tns:CanadianAddress" />
      <xs:complexType name="AmericanAddress">
        <xs:complexContent mixed="false">
          <xs:extension base="tns:Address">
            <xs:sequence>
              <xs:element minOccurs="0" name="State" nillable="true" type="tns:StateCodes">
              </xs:element>
              <xs:element minOccurs="0" name="ZipCode" nillable="true" type="xs:string">
              </xs:element>
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:element name="AmericanAddress" nillable="true" type="tns:AmericanAddress" />

  • Mapping List Complex Types in BPM (unbounded)

    Hello,
      I need help in how can I map a list of complex types in BPM.
      I have a list of products that brings a web service that I have to map to the process context. Both types have the same elements, but the process context BPM shows me an error because it is different of the web service.
      Please, any documentation or advice.
    Regards
    SU

    Hi,
    For mapping the complex types, you need to follow the below:
    Start by mapping the outermost node first and then mapping the attributes inside the node. Intially it will show the (types do not match) error and when you are done with all the mapping the error would vanish.
    Cheers,
    Arafat

  • How to create a UML diagram from a existing .java/.class file?

    I want to create a UML diagram from a existing .java/.class file automatic in JDeveloper. Can I get it? thanks!

    create a new class diagram and then simply drag the java classes from your project onto the diagram area.

  • How to change the cursor type when a TableView class was added to a Swing application?

    We can resize column width by dragging the column divider in the table header. This is a built-in feature of the TableView class.
    Normally, the cursor will become to east-resize (or west-resize) type with positioning the cursor just to the right of a column header.
    However, I found that the cursor is remaining the default type at the same position if I integrate JavaFX into Swing Application. That is adding the TableView to a Scene, and then adding this Scene to a JFXPanel, finally, adding this JFXPanel to the JFrame.
    The sample codes are listing below:
    public class Run extends JFrame {
        Run() {
            setSize(600, 450);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            initComponents();
        private void initComponents() {
            final JFXPanel fxPanel = new JFXPanel();
            this.getContentPane().add(fxPanel);
            Platform.runLater(new Runnable() {
                @Override
                public void run() {
                    initFX(fxPanel);
        private void initFX(JFXPanel fxPanel) {
            Scene scene = null;
            try {
                scene = FXMLLoader.load(
                    new File("res/fxml_example.fxml").toURI().toURL()
            } catch (Exception ex) {
                ex.printStackTrace();
            fxPanel.setScene(scene);
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    new Run().setVisible(true);
    fxml_example.fxml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.Scene?>
    <?import javafx.scene.control.TableView?>
    <?import javafx.scene.control.TableColumn?>
    <Scene xmlns:fx="http://javafx.com/fxml">
        <TableView fx:id="tableView"
                   editable="true">
            <columns>
                <TableColumn text="COL1">
                </TableColumn>
                <TableColumn text="COL2">
                </TableColumn>
                <TableColumn text="COL3">
                </TableColumn>
                <TableColumn text="COL4">
                </TableColumn>
                <TableColumn text="COL5">
                </TableColumn>
            </columns>
        </TableView>
    </Scene>
    So, are there anyone can advise how to fix these codes; make the cursor can change to east-resize (or west-resize) type when this TableView class was added to a Swing application?

    Thanks for the report. I've just filed a JIRA issue: https://javafx-jira.kenai.com/browse/RT-34009
    //Anton.

  • Returning complex types with arrays (Java / EJB via WSIF)

    Hi all,
    I'm writing some WSIF bindings for existing EJBs, and I've struck a bit of a problem. Basically I've got complex types that contain arrays, and while instances of these types can be passed to the EJBs, return variables typed similarly cause the following fault:
    org.collaxa.thirdparty.apache.wsif.WSIFException: com.collaxa.cube.ws.wsif.providers.ejb.WSIFOperation_EJB@1a372e0 : Could not invoke 'concatString'; nested exception is:
         org.collaxa.thirdparty.apache.wsif.WSIFException: Class 'ejbinterfacetest.StringReturnArray' is not compatible; nested exception is:
         oracle.xml.parser.v2.XMLDOMException: cannot add a node belonging to a different document
         at com.collaxa.cube.ws.wsif.providers.ejb.WSIFOperation_EJB.executeRequestResponseOperation(WSIFOperation_EJB.java:1305)
         at com.collaxa.cube.ws.WSIFInvocationHandler.invoke(WSIFInvocationHandler.java:431)
         at com.collaxa.cube.ws.WSInvocationManager.invoke2(WSInvocationManager.java:416)
    The Java class StringReturnArray is a serializable JavaBean with one property, a String[] called strings. The corresponding complexType (that works when used as a method parameter type) is stringReturnArrayType:
    <complexType name="stringArrayType">
    <sequence>
    <element name="str" type="string" maxOccurs="unbounded" />
    </sequence>
    </complexType>
    <complexType name="stringReturnArrayType">
    <sequence>
    <element name="strings" type="tns:stringArrayType" />
    </sequence>
    </complexType>
    and I've type mapped in the binding with
    <format:typeMap typeName="typens:stringReturnArrayType" formatType="ejbinterfacetest.StringReturnArray" />
    Anyone know why this would be? Is there any way I can get more information out of BPEL or OC4J regarding the fault? (I've already turned the BPEL domain logging to All)
    Cheers,
    Chris.

    Any luck with this? I am running into the same error. Apparently, this is not an issue with Java binding, but when invoking remote EJBs, we run into this. I am running 10.1.3.1 and the error is:
    <fault>
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
    <part name="summary">
    <summary>
    com.collaxa.cube.ws.wsif.providers.ejb.WSIFOperation_EJB@e26dbf : Could not invoke 'getIdentityInfo'; nested exception is:
         org.collaxa.thirdparty.apache.wsif.WSIFException: Class 'ca.bc.gov.pssg.c3.webservices.identitymanagement.Identity' is not compatible; nested exception is:
         oracle.xml.parser.v2.XMLDOMException: cannot add a node belonging to a different document
    </summary>
    </part>
    <part name="detail">
    <detail>
    org.collaxa.thirdparty.apache.wsif.WSIFException: Class 'ca.bc.gov.pssg.c3.webservices.identitymanagement.Identity' is not compatible; nested exception is:
         oracle.xml.parser.v2.XMLDOMException: cannot add a node belonging to a different document
    </detail>
    </part>
    </bindingFault>
    </fault

  • Implementing DOM Interface with existing Java classes

    I had planned on using some tree-like Java classes as a Document Object Model, which would give me access to all sorts of XML and DOM tools like parsers and XSLT transformers. Initially, I thought all that would be neccessary is to implement all the DOM Interfaces in org.w3c.dom and then I would have a set of classes that conformed to DOM Level 1. It was my understanding that interfaces such as DOMImplementation and Document would interface with various XML tools, allowing creation of a class that implements Document and then Document would have its various factory methods that know how to create the various DOM nodes such as Element, Attr, Text, NamedNodeMap, NodeList, etc.
    The problem I'm seeing now is that the JAXP specification (which is what the latest Xerces and Xalan tools conform to) has something called a DocumentBuilder and DocumentBuilderFactory that appear to be necessary to tell the framework what type of class to instantiate that implements the Document DOM interface. Those appear to have a lot of methods that deal with parsing of XML documents and I didn't really want to write or even subclass any existing Parsers in order to get the functionality of traversing and transforming a set of classes that implement the DOM interface.
    Am I missing something here? Is it possible to plug in any (set of classes for) DOMImplementation and get them to work with the various DOM and XML tools out there?
    Is there an easier way to allow parts of an application access to internal data structures but have the more generic tools or APIs, such as XSL transformers, access that same set of classes as a DOM with the generic DOM interface methods?
    Can someone provide me with some guidance here? I'm in the process of finalizing some design on a system and need to know if this is possible or if I need to alter my design.
    Thanks.

    If I understand you correctly, I think I am working on a similar issue. I am unhappy with the methods given by the DOM for retrieving data from the XML file and for building a file. Our software has a bunch of code that uses these classes and it is extremely ugly. My solution was to create a facade on top of the DOM model. Essentially I have some simple classes that store all the pertinent info (for me) about the XML structure. Essentially that is the element or attribute name, its values and in the case of the element, it's children. This makes it easier for me to build and retreive the data. What I then built was a loader class and a builder class. The loader takes an XML file and parses it in using the DOM classes and builds a structure using my classes and returns the root element. The builder takes a root element and creates a DOM object out of it. This frees me of having to code around the DOM classes all over the place and makes it simple to upgrade our XML code if the DOM changes or a better DOM is released. I am using factories to facilitate this and allow me to have loaders for specific types of XML documents so that I can have a class for each which further simplifies the XML related tasks of other developers on my team.

  • Transforming XML into complex type in ADF/Java

    Hi all,
    Maybe a simple question for you all - maybe too simple for some of you - but not for me as a Java newbie. So I'd appreciate any help.
    I have used a WebService Proxy and created a new Pojo in order to create a Data Control. The WS proxy works quite good and I can get this XML response as expected.
    <ns0:kunden xmlns:ns0="http://www.oracle.com/hbv">
    <ns0:kunde>
    <ns0:Kundennummer>0000000047</ns0:Kundennummer>
    <ns0:Name>Laue</ns0:Name>
    <ns0:Vorname>Ingo</ns0:Vorname>
    <ns0:Straße>Kühnehöfe</ns0:Straße>
    <ns0:Hausnr/>
    <ns0:PLZ>22761</ns0:PLZ>
    <ns0:Ort>Hamburg</ns0:Ort>
    <ns0:Telefon>040/89091-456</ns0:Telefon>
    </ns0:kunde>
    <ns0:kunde>
    <ns0:Kundennummer>0000000048</ns0:Kundennummer>
    <ns0:Name>Brüning</ns0:Name>
    <ns0:Vorname>Arne</ns0:Vorname>
    <ns0:Straße>Kühnehöfe</ns0:Straße>
    <ns0:Hausnr/>
    <ns0:PLZ>22761</ns0:PLZ>
    <ns0:Ort>Hamburg</ns0:Ort>
    <ns0:Telefon>040/89091-220</ns0:Telefon>
    </ns0:kunde>
    </ns0:kunden>
    Now I want to transfer the XML into a complex type in Java, for instance
    ArrayList<MyKunde> retKundenliste = new ArrayList<MyKunde>();
    The type MyKunde is defined with all needed attributes and the corresponding getter/setter methods. My object getting the XML response from the WS is kundenliste of type javax.xml.soap.SOAPElement (defined by the WS proxy) . What method do I have to use to get all elements from the XML structure transformed into an array of MyKunde?
    I can imagine that this task is a standard but as I said I'm new in Java programming.
    Many thanks for your help
    Detlef

    I'm not sure but the Wizard should have created accessors for the char_list Adobe in the generated AbcXyzObj.java class. Check this class for the attributes and their getters and setters.
    Timo

  • JAXB - Elements declared as Complex Types becomming static inline classes

    When a complex type is defined in the XSD as a complex type, compiling the scheme creates it as static class within the owning class.
    Is there anyway to change the behavior so that a regular class is created? Or do I need to change the schema to declare the type 'at the top level'?

    When a complex type is defined in the XSD as a complex type, compiling the scheme creates it as static class within the owning class.
    Is there anyway to change the behavior so that a regular class is created? Or do I need to change the schema to declare the type 'at the top level'?

  • Java Mapping Error - Unable to instantiate the Java class

    Hi,
    I am trying out a Java Mapping scenario.
    The code worked fine in eclipse.i could get the desired output.
    but when i tried it out in XI ....i got the following error in moni:
    *Unable to instantiate the Java class*
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Request Message Mapping
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">CANNOT_INSTANCIATE_CLASS</SAP:Code>
      <SAP:P1>JavaMapping</SAP:P1>
      <SAP:P2>http://www.sdsdsd.com/XI/Sales/T~</SAP:P2>
      <SAP:P3>3bd13b30-6300-11dc-b9f1-f0050aa5c91a</SAP:P3>
      <SAP:P4>-1</SAP:P4>
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Unable to instantiate the Java class JavaMapping (http://www.sdsdsd.com/XI/Sales/T~, 3bd13b30-6300-11dc-b9f1-f0050aa5c91a, -1)</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Please help me out with this error.

    Hi Anu,
    Currently I am also facing the same Unable to instantiate the Java class  same java class is working fine in eclipse .
    Could you please confirm Is this because of version mismatch that in Eclipse JAVA and SAP JAVA ?
    Thanks in Advance.
    Best,
    Srinivas

  • Creating data dictionary type using custom java class

    Hi Experts,
    I have a situation involving the TableSorter mechanism as described here:
    In order to do my sorting correctly, I've created my own Java class implementing the Comparable interface. Based on this class, I need to define my own data dictionary type to be used in a context/table.
    However, I cannot se how this could be achieved as standard Data Dictionary elements can only be based on simple built-in types. Any ideas?
    Kind regards,
    Rasmus Røjkjær Ørtoft

    Hi,
    have you tried to use the following steps while creating your attribute
    1) Right click on the context
    2) New->Attribute
    3) Manually-> Provide a name for the attribute
    4) Browse->Select java native type and select your class
    regards
    Ayyapparaj

  • How to compile the Java classes generated in JAXB

    I am using Windows 2000 Operating System. I found a xjc
    batch file on the sun's java forum.
    I used that to generate classes from XML. After generating
    the classes I could not compile
    the classes each depends on other AND THEY REQUIRE BOTH
    CLASS FILES.
    I will attach the schema file and dtd . Can you explaine me the problem.
    #<transactions.dtd>
    <?xml version="1.0" encoding="UTF-8"?>
    <!ELEMENT transactions (cardtocard*)>
    <!ELEMENT cardtocard (tocard, fromcard, fromcardver, amount, transdate, transid)
    >
    <!ELEMENT tocard (#PCDATA)>
    <!ELEMENT fromcard (#PCDATA)>
    <!ELEMENT fromcardver (#PCDATA)>
    <!ELEMENT amount (#PCDATA)>
    <!ELEMENT transdate (#PCDATA)>
    <!ELEMENT transid (#PCDATA)>
    transactions.xjs
    <xml-java-binding-schema>
    <element name="transactions" type="class" root="true"/>
    <element name="cardtocard" type="class"/>
    </xml-java-binding-schema>
    XML file
    ?xml version="1.0" encoding="UTF-8"?>
    <!--Sample XML file generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
    <transactions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="C:\My Documents\Xml\SVTConcord.xsd">
    <cardtocard>
    <tocard>1111222233334444</tocard>
    <fromcard>6666777788889999</fromcard>
    <fromcardver>567</fromcardver>
    <amount>100.00</amount>
    <transdate>2002-06-04 00:00:00.000</transdate>
    <transid>1111222202</transid>
    </cardtocard>
    </transactions>
    the XJC compiler for windows is
    @echo off
    echo JAXB Schema Compiler
    echo --------------------
    if "%JAVA_HOME%" == "" goto errorJVM
    if "%JAXB_HOME%" == "" goto errorJAXB
    set JAXB_LIB=%JAXB_HOME%\lib
    set JAXB_CLASSES=%JAXB_HOME%\classes
    echo %JAVA_HOME%\bin\java.exe -jar %JAXB_LIB%\jaxb-xjc-1.0-ea.jar %1 %2 %3 %4 %5
    %JAVA_HOME%\bin\java.exe -jar %JAXB_LIB%\jaxb-xjc-1.0-ea.jar %1 %2 %3 %4 %5
    goto end
    :errorJVM
    echo ERROR: JAVA_HOME not found in your environment.
    echo Please, set the JAVA_HOME variable in your environment to match the
    echo location of the Java Virtual Machine you want to use.
    echo For example:
    echo set JAVA_HOME=c:\jdk1.4.0_01
    goto end
    :errorJAXB
    echo ERROR: JAXB_HOME not found in your environment.
    echo Please, set the JAXB_HOME variable in your environment to match the
    echo location of the JAXB installation directory.
    echo For example:
    echo set JAXB_HOME=c:\jdk1.4.0_01\jaxb-1.0-ea
    :end

    When you compile the generated classes, be sure to put jaxb-rt-1.0-ea.jar in your classpath!

  • Urgent: How to map existing java classes

    I created an IDL file where I want to use java.sql.ResultSet. The line is:
    module CMS {
    interface Comm {
    ResultSet search(in string searchString);
    The ResultSet has to be the ResultSet as in java.sql.ResultSet. I tried to add the following code:
    module java {
    module sql {
    interface ResultSet {
    but it doesn't work. Who can help me?

    I think that you can try the type "Any"
    Then after the client receive the any object it can be cast to the object you have.

  • Strategy for mapping existing Java classes to db uing toplink

    I have simple POJO, I used the JDev Class Diagram to add relations to the POJO and then tried to map using Toplink to Database. Is this the correct Strategy? or Should I directly use POJOs without the relationsships, to map to DB using TOPLINK?

    Assuming your schema is as follows
    User table has a primary key ID with other columns
    MentorRel table has two columns (e.g. mentor_id and protege_id) that are FKs pointing to the User.ID ( primary key)
    I would suggest that you normalize your schema further by creating a column in User table called MentorID which will be a self referencing FK. This will automatically capture your 1:M relationship between a Mentor and Protege (as a User can be a Mentor or a Protege). You will also get rid of the MentorRel table this way.
    Once you are done, you will be able to map this nicely. Let me know if this does not work.

  • File does not exist: /java/classes message in Apache error log file

    I am getting several of these messages in the Apache error logfile.
    File does not exist: $JAVA_TOP (this is actually my physical patch for $JAVA_TOP)
    Is it normal to see this messages or some configuration is wrong?
    thanks,
    Azodpe

    Please post the details of the application release, database version and OS.
    I am getting several of these messages in the Apache error logfile.
    File does not exist: $JAVA_TOP (this is actually my physical patch for $JAVA_TOP)Is this the complete error message?
    Is it normal to see this messages or some configuration is wrong?If your application is functioning properly with no issues, then you can ignore those errors.
    Thanks,
    Hussein

Maybe you are looking for