JAXB classes generation

Hi all,
I have 4 XMLSchema files and need to generate JAXB classes out of them. But most of the nodes like header parts of request and response of messages are same in structure. If I generate classes in 4 different packages how can I separate out the common node .java classes so that setting / getting repetition is avoided in my application.
Thanks in advance.
JoyBoy

There are some good examples here:
http://java.sun.com/webservices/jaxb/users-guide/jaxb-using.html

Similar Messages

  • Generating JAXB classes from XSD

    I am generating java classes using JAXB binding from XSDs. I organized the classes into 2 packages say package1 and package2
    The XSD to create the package2 is dependent on package1. So I do an include package1.xsd in package2.xsd. With this I am running into an issue with JDeveloper while generating the classes. When I generate classes using package2.xsd, all package1.xsd classes are also generated in the same package. So, I have to manually delete these classes from package1.xsd and add import statements from package1 where required.
    Is there a solutiion/work around available for suppressing duplicate class generation? Any help would be greatly appreciated.

    Try here as well
    https://jaxb.dev.java.net/

  • Cannot Use JaxB classes in ADF application.

    Hi
    I am using JDeveloper 11.1.1.6
    I am trying to call the Oracle Business Rules (OBR) Ruleset from the frontend.
    When I call a simple rule only using Java facts (facts are object references of classes which are used in OBR)  as input, the Rules are verified and executed correctly.
    After that I tried to give XML Facts as input the application is facing ClassNotFoundException.
    To access the XML facts I had to add the XML Fact class known as JAXB_CLASSES into the Libraries and Classpath of Project Properties.
    First I tried to call the OBR rules containing the XML Facts / Jaxb_classes from the page and it throwed ClassNotFoundException while deploying the application.
    Next I tried to invoke the Jaxb_classes from main method and it worked fine.
    My Question is : How can I access JAXB Classes in an ADF View Controller Project/ Application?
    Thanks,
    Nigel.

    I am adding the JAXB_classes into the application in the Backend and the code for intialising is also written in the Backens.
    Still, the application is throwing a exception like
    <RuleSession> <logIt> The symbol 'generated.ParametersType' is undefined.
    at line 7 column 14 in main
    <RuleSession> <logIt> UndefinedException: The symbol 'generated.ParametersType' is undefined.
      at line 7 column 14 in main
    <RuleSession> <logIt> The symbol 'generated.ParametersType' is undefined.
    at line 7 column 14 in main
    <RuleSession> <logIt> UndefinedException: The symbol 'generated.ParametersType' is undefined.
      at line 7 column 14 in main
    oracle.rules.sdk2.exception.SDKException: RUL-05186: error setting up rule session pool for decision point

  • Update Unbounded element using SOAP_CLIENT and JAXB classes

    I am writing a custom worklist application using 10.1.3.3. I am able to successfully kick off my BPEL process from my Java application and I am even able to modify most of the fields defined in my XSD. My problem occurs when I try to update the unbounded elements. They are of complex type and each request can have an unlimited number of these elements.
    I used JDeveloper's tool to generate the JAXB classes I'm using to interact and modify the payload of my task. I know that JAXB does not generate setter methods for unbounded elements. I should be able to get the list of elements and simply add to it. Unfortunately, the new list elements are not being saved when I marshall my payload and update the task with the new payload.
    Any ideas on what I'm doing wrong or if there is another way to do this? I've posted code snippets below.
    Thanks!
    Quote Element from XSD:
    <xsd:element name="Quote" nillable="true" minOccurs="0" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="WorksheetId" type="xsd:int" minOccurs="0"/>
    <xsd:element name="QuoteId" type="xsd:int" minOccurs="0"/>
    <xsd:element name="Description" nillable="true" minOccurs="0">
    <xsd:simpleType>
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="250"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:element>
    <xsd:element name="Quantity" type="xsd:int" nillable="true" minOccurs="0"/>
    <xsd:element name="UnitPrice" type="xsd:float" nillable="true" minOccurs="0"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    AddQuote java code:
    JAXBContext jc = JAXBContext.newInstance("myproject.xml");
    Unmarshaller u = jc.createUnmarshaller();
    Task detailTask = wfSvcClient.getTaskQueryService().getTaskDetailsById(ctx, thisId);
    Element detailPayload = detailTask.getPayloadAsElement();
    ObjectFactory objFactory = new ObjectFactory();
    XMLWorksheet xRequest = objFactory.createWorksheet();
    xRequest = (XMLWorksheet)u.unmarshal(detailPayload.getFirstChild());
    List quotes = xRequest.getQuote();
    quotes.add(quote);
    Marshaller m = jc.createMarshaller();
    m.marshal(xRequest, detailPayload);
    detailTask.setPayloadAsElement(detailPayload);
    taskService.updateTask(ctx, detailTask);

    who actually managed to make the SOAP_CLIENT working ?
    What is the jar list and order you use ?
    Does it work with java 5 ?
    Thanks for the help!

  • Heavy loading of jaxb classes

    Hi,
    We need to use the latest jaxb 2.1 libraries in our application. We are using netweaver 7.1 CE and it seems to ship with jaxb 2.0 libs. (file:/usr/sap/CE7/J00/j2ee/cluster/bin/ext/jaxb20/jaxb-impl.jar)
    We are already using heavy loading for the hibernate classes, and I assumed I could to the same for jaxb. The dump of the heavy loaded classes from telnet is as follows:
       /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/javassist-3.4.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/hibernate-entitymanager-3.3.2.GA.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/asm-1.5.3.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/antlr-2.7.6.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/commons-collections-3.1.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/hibernate-commons-annotations-3.0.0.GA.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/jaxb-xjc-2.1.7.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/hibernate-annotations-3.3.1.GA.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/jaxb-impl-2.1.7.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/log4j-1.2.15.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/asm-attrs-1.5.3.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/jaxb-api-2.1.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/commons-logging-1.0.4.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/cglib-2.1.3.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/ehcache-1.5.0.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/dom4j-1.6.1.jar
        /usr/sap/CE7/J00/j2ee/cluster/apps/sap.com/Manifest/app_libraries_container/lib/hibernate-3.2.6.ga.jar
    The jaxb classes is included, but it does not seem that my jaxb libraries is used by my application. I've added a util method to do o lookup of the classloader of the jaxb class that I get hold of in the app, and it is still the original jaxb2.0
    Is this the correct approach to use a newer JAXB or is there some other way of doing it?
    Regards Jaco

    In the NetWeaver you can make one application dependent on another one using the [application-j2ee-engine.xml|http://help.sap.com/saphelp_nwce10/helpdata/en/45/053c1041f30486e10000000a155369/content.htm] descriptor.
    If you have YourApp.ear, and HibernateJars.ear (the latter one as "Heavy Library"), in the YourApp.ear/META-INF/application-j2ee-engine.xml you could write:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application-j2ee-engine SYSTEM "application-j2ee-engine.dtd">
    <application-j2ee-engine>
         <provider-name>yourcompany.com</provider-name>
         <reference reference-type="hard">
              <reference-target target-type="application" provider-name="yourcompany.com">HibernateJars</reference-target>
         </reference>
    </application-j2ee-engine>
    In such case, the HibernateJars' classloader will not see the jaxb classes loaded by server, and whatever refers to jaxb there - will use the version you want. BUT, YourApp's classloader will use the jaxb version loaded on server.
    I know this may still be confusing... I would recommend you to browse through the classloader viewer on the web console (port 50000):
    SAP NetWeaver Administrator > Problem Management > Classloader viewer > Java Class Loader Viewer
    (find the classloaders of your applications and browse through Children, Parents and Resources tabs -
    this is where I understood the NetWeaver's classloading approach

  • Customize names of generated JAXB classes

    I have a peculiar requirement. We have been using JAXB1.0 in our project to parse XMLs. External binding files were used to provide proper names for the generated JAXB classes. Now, I have an xml that looks something like this:
    //sample xml. Original format is much bigger
    <b>
    <MasterTag>
    <attr id="123">Value1</attr>
    <attr id="736">Value2</attr>
    <attr id="900">value3</attr>
    </MasterTag>
    </b>
    There's a property file which has key value pairs for the attr id
    Eg:
    <b>
    123=CompanyID
    736=CompanyAddress
    900=CompanyPinCode
    </b>
    Is it possible to generate JAXB classes names based on the attr id value? These values finally need to persisted in the db. JAXB is the preferred technology.
    Any other ideas are also welcome. Thanks.

    I might be misunderstanding your question, but if you control the single large schema, it would be simple to define the things that you want to treat specially as either individual elements or complexTypes inside the single schema file. Using psuedo-schema, say you have something like this now:
    <xs:element name='Information'>
      <xs:complexType>
        <xs:sequence>
          <xs:element name='Header'>
              <!-- your definition here -->
          </xs:element>
          <xs:element name='Item' maxOccurs='unbounded'>
              <!-- your definition here -->
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>You can change that to:
    <xs:element name='Information'>
      <xs:complexType>
        <xs:sequence>
          <xs:element ref='Header'/>
          <xs:element name='Item' maxOccurs='unbounded'>
              <!-- your definition here -->
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    <xs:element name='Header'>
      <!-- your definition here -->
    </xs:element>That should produce distinct classes for your Information and Header elements. You similary can break out the Item and Trailer elements.

  • Problem Generating JAXB Classes

    I am using Eclipse (Enterprise Pack) and want to generate JAXB classes from a schema. I right click on the schema, select Generate JAXB classes - fill in package name, next and get the error:
    java.lang.NoClassDefFoundError: com/sun/tools/xjc/XJCFacade
    Caused by: java.lang.ClassNotFoundException: com.sun.tools.xjc.XJCFacade
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
    Exception in thread "main"
    Am I missing a library?
    Steve Watson

    The web service project will add additional server runtime libraries to the classpath thus resolving the jaxb dependencies, in the case of a dynamic web project, you'll have to manage that with the JPA facet and eclipselink, or by adding the Moxy jars seperately. However, if you want to use the target runtime libraries create a user-library and reference the following server libraries: (from Server Install Dir\modules) glassfish.jaxb_"version".jar, glassfish.jaxb.xjc_"version".jar, javax.activation_"version".jar, javax.xml.bind_"version".jar, javax.xml.stream_"version".jar.

  • Generating JAXB classes

    Hi,
    My xml: http://www.javaexperience.com/catalog.xml
    I have an xml for which I want to generate JAXB classes. Unfortunately I don't have access to xsd for this xml.
    Could someone please share steps to generate JAXB classes for a xml. What I have tried is:
    1) Generate the xsd from this xml using XML to XSD Generater Online - xmlGrid.net
    2) Use the Maven JAXB plugin "org.jvnet.jaxb2_commons"
    The problem I faced with my approach was that:
    Since the xml has root element and one of the child element as same name, the JAXB processor fails on reaching the child "Catalog" tag. Even though it had successfully processed the root "Catalog" tag.
    Any pointers would of great help.

    The web service project will add additional server runtime libraries to the classpath thus resolving the jaxb dependencies, in the case of a dynamic web project, you'll have to manage that with the JPA facet and eclipselink, or by adding the Moxy jars seperately. However, if you want to use the target runtime libraries create a user-library and reference the following server libraries: (from Server Install Dir\modules) glassfish.jaxb_"version".jar, glassfish.jaxb.xjc_"version".jar, javax.activation_"version".jar, javax.xml.bind_"version".jar, javax.xml.stream_"version".jar.

  • JAXB class conflict error

    I am new to JAXB.
    I am using external customization file to create JAXB classes.
    I have one XSD file which includes another XSD. Both of them have the same element name and the classes are getting created in the same folder. I have tried each and every option of the options mentioned in the fix collides examples of JAXB sun tutorial without any success.
    Please guide me on this.
    This is the following error:
    compile:
    [echo] Compiling the schema...
    [xjc] C:\Sun\jwsdp-1.6\jaxb\samples\acord-dri\gen-src\primer.po is not found and thus excluded from the dependency
    check
    [xjc] Compiling file:/C:/Sun/jwsdp-1.6/jaxb/samples/acord-dri/Aon_Acord-Repository_v-1-0-1.xsd
    [xjc] [ERROR] Multiple <schemaBindings> are defined for the target namespace "http://www.ACORD.org/Standards/Acord
    MsgSvc/1.1.0"
    [xjc] line 129 of binding.xjb
    [xjc] [ERROR] Another <schemaBindings> is defined here
    [xjc] line 98 of binding.xjb
    [xjc] [ERROR] A class/interface with the same name "primer.po.SenderAonAcord" is already in use. Use a class custo
    mization to resolve this conflict.
    [xjc] line 265 of Acord-Repository_v-1-0-1.xsd
    [xjc] [ERROR] (Relevant to above error) another "SENDERAonAcord" is generated from here.
    [xjc] line 217 of Aon_Acord-Repository_v-1-0-1.xsd
    [xjc] [ERROR] This error is caused because on Windows you cannot have both "SENDERAonAcord.java" and "SenderAonAco
    rd.java" in the same directory.
    [xjc] unknown location
    [xjc] failure in the XJC task. Use the Ant -verbose switch for more details

    This is because of name conflicts in the xsd. If the <xsd:element> name is same as some <xsd:complexType> and that is referenced from the element this happens. If you provide different names, it will solve the problem
    Regards,
    Sushil

  • Generating JAXB classes from an XSD

    Hi All,
    Can anyone please tell me how to generate Jaxb classes for xsd in eclipse , or in ant .
    Thanks and Regards

    Try here as well
    https://jaxb.dev.java.net/

  • How do I unmarshal to only a portion of generated JAXB classes?

    I have an XML schema that is laid out something like this:
    <Information>
    <Header/>
    <Item> (Unbounded)
    <Trailer/>
    </Information>
    I receive files that have thousands of items in them. Because of the size of the files, I must use SAX to parse the file.
    I need to unmarshal each file and store the results in a database after following some conditional logic. It is not practical to unmarshal a 500 MB file.
    What I have been doing is using a SAX DefaultHandler to strip out each <Item> element.
    I had to create a separate schema for just the <Item> element so that I could use JAXB's xjc to generate a set of classes to unmarshal each <Item> element to.
    This works great, but it is a hassle to maintain. You see, I also need to unmarshal the <Header> element. So I have to create a separate schema for that as well. So then I end up with two sets of JAXB classes, with lots of duplication. Plus, if I have any complex types that are referenced in both the <Header> and the <Item>, then I have to include those in each sub schema.
    What I want to know is:
    Is it possible to just generate ONE set of JAXB classes for the main schema, and then unmarshal the stripped out <Item> element to just the corresponding Item in the generated JAXB classes?
    This is a complicated topic, and I hope I've been clear. Basically, I have to create these <Header> and <Item> schemas by hand every time the main schema changes, and I want to get away from that.

    I might be misunderstanding your question, but if you control the single large schema, it would be simple to define the things that you want to treat specially as either individual elements or complexTypes inside the single schema file. Using psuedo-schema, say you have something like this now:
    <xs:element name='Information'>
      <xs:complexType>
        <xs:sequence>
          <xs:element name='Header'>
              <!-- your definition here -->
          </xs:element>
          <xs:element name='Item' maxOccurs='unbounded'>
              <!-- your definition here -->
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>You can change that to:
    <xs:element name='Information'>
      <xs:complexType>
        <xs:sequence>
          <xs:element ref='Header'/>
          <xs:element name='Item' maxOccurs='unbounded'>
              <!-- your definition here -->
          </xs:element>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    <xs:element name='Header'>
      <!-- your definition here -->
    </xs:element>That should produce distinct classes for your Information and Header elements. You similary can break out the Item and Trailer elements.

  • How to unmarshal non-root JAXB class

    How to unmarshal non-root JAXB class? I used work around to marshal an object without *@XmlRootElement*:
    marshaller.marshal( new JAXBElement(
      new QName("uri","local"), MessageType.class, messageType ));Now I need to unmarshal this object.

    what happened when you tried it?

  • JAXB XJC class generation problem

    Hi!, I�m trying to generate the classes for the IMS-LearningDesign schema:
    xjc -d src_temp -p edu.eci.ims.ld IMS_LD_Level_A.xsd
    parsing a schema...
    [ERROR] Attempt to create a property having the same name as the reserved word "Class".
    line 177 of IMS_LD_Level_A.xsd
    The problem is that schema has a 'class' attribute, and that`s a reserved word for JAXB.
    When the schema is modified (add a character to the attribute name - oclass) it works fine, but I need to keep the standard specification (to parse standard XML - LD files). What can I do to solve this problem without modifying the schema?

    I'd suggest you repost this to the JAXB users mailing list at Java.Net. That list is monitored by the JAXB implementation team.
    Check http://jaxb.dev.java.net/

  • Special Characters issue in JAXB Classes generated

    Hi,
    I have generated Java bean classes from an xml schema using JAXB 2.0 Content Model feature in Jdeveloper 11g. I have another class, which has a method testMethod which takes the Java Bean class object as input. I have exposed this method as java webservice. I am just printing the FirstName from the input I have got.
    public String testMethod(TestBean testbean) {
    testBean,getContact().getFirstName();
    When there are some special characters like �, my java bean accepts and displays as �. I printed the value directly in my getter method, but it prints differently.
    How can I set my Java Bean class to use ISO-8859-1 as encoding.

    Sorry but this has nothing to do with ADF. Please try in the right forum here https://forums.oracle.com/forums/category.jspa?categoryID=285

  • Container classes generation for production environment

    You can run the WebLogic EJB compiler on the JAR file before you deploy the beans,
    or you can let WebLogic Server run the compiler for you at deployment time.
    I have to release :
    - an ear, containing 1 ejb and other stuff
    - a client-jar (delegate, remote, home), that will be included in another ear (client
    application of our ejb).
    Both the ear will be deployed on the same wl instance (6.1sp2) (production environment).
    For a production environment, which are the pros and contras ?
    (not considering deploy time differences on wlserver, of course).
    Which is the best practice ? Is it suggested to release the ear with the container
    classes already generated (run ejbc before) or delegate the generation to weblogic
    server ?
    Thanks in advance
    Sergi

    You can run the WebLogic EJB compiler on the JAR file before you deploy the beans,
    or you can let WebLogic Server run the compiler for you at deployment time.
    I have to release :
    - an ear, containing 1 ejb and other stuff
    - a client-jar (delegate, remote, home), that will be included in another ear (client
    application of our ejb).
    Both the ear will be deployed on the same wl instance (6.1sp2) (production environment).
    For a production environment, which are the pros and contras ?
    (not considering deploy time differences on wlserver, of course).
    Which is the best practice ? Is it suggested to release the ear with the container
    classes already generated (run ejbc before) or delegate the generation to weblogic
    server ?
    Thanks in advance
    Sergi

Maybe you are looking for

  • Can somebody tell me the contact details of the BT...

    I have been waiting over 3 weeks for a date for a new installation for a brad new house after being told the phone line and broadband was working on day 1.....amazing as i dont even have a telephone wire from the telephone pole to the house! I have s

  • Custom event log is not working in SharePoint server

    Hi , We are trying to implement event logging in our application. We have created separate event source for our application. When we testing this our local dev machine it is working without any problem. when I try to test the same in higher environme

  • How can I test Workflow for Leaves without using ESS

    Hi Gurus,      Please help me..I need to test my wokflow for leaves but I don't have ESS....How do I do it?     Thanks in advance for all your help.

  • Sub Total Text in an ALV using FACTORY Method

    Hi Gurus, My requirement is simple, but I couldn't find any answers under SDN or any other forums. Some of you may ask me to check for the SCN posts, but I almost checked everything. My requirement is - When I get the Sub-total in my ALV, it should p

  • How to hard code a printer in a report using Crystal 2008

    Up through Crystal 10 you could save the Printer you wanted to use in the report itself.  Since Crystal 11, this feature is no longer working.  At print time, the default printer is being used.  We have a report that prints to a specific printer util