XML binding(maping) "Castor" problem ...

Hello Dear Sirs !
I am using the the "Castor" project for XML Binding purposes .
It was really good idea to create this stuff .
I tried to use it in my programs and just surprised how your project really tailored to XML programmers needs .
But a some time ago I have encountered with some Parsing problem ....
May be my quastion is to stooped , but i still can not find an answer .
I have to parse From Java Class to XML and Vice Versa next kind of XML :
************************ First Question *****************************************
<Inputs>
< Line LineNumber = '0'
Selected 'yes'
Attribute='Value of Attribute'
IDFormat='Format to Apply'
<Value Name ='Rate'>4.89</Value>
<Value Name ='Subscribtion'>yes</Value>
<Value Name ='EnrolmentDate'>12.12.2002</Value>
<Value Name ='ProviderName'>Somebody</Value>
</Line>
< Line LineNumber = '1'
Selected 'no'
Attribute='Value of Attribute'
IDFormat='Format to Apply'
<Value Name ='Queue'>2Q</Value>
<Value Name ='IVR'>yes</Value>
<Value Name ='EnrolmentDate'>31.12.2002</Value>
</Line>
< Line LineNumber = '3'
Selected 'yes'
Attribute='Value of Attribute'
IDFormat='Format to Apply'
<Value Name ='CustomerName'>NA</Value>
<Value Name ='Vacancy'>yes</Value>
</Line>
</Inputs>
************************ End of First Question ***************************
*********************** Second Question ***************************
<Inputs>
Value< ItemAttribute = 'CurentItemAttribute' ItemProperty =' ItemProperty' >
Value<ItemAttribute = 'CurentItemAttribute' >
Value<ItemProperty =' ItemProperty' >
Value< ItemAttribute = 'CurentItemAttribute' ItemProperty =' ItemProperty' >
Value<ItemAttribute = 'CurentItemAttribute' >
Value< ItemAttribute = 'CurentItemAttribute' ItemProperty =' ItemProperty' >
Value< ItemAttribute = 'CurentItemAttribute' ItemProperty =' ItemProperty' >
</Inputs>
*********************** End of Second Question ***************************
And I dont know How I can MAP these XML formats to Java Classes and vice versa .........
(to my pitty It is not my idea to assemble it in this manner and this is not given to some improvement change .... )
In your examples all things look so simple and understandable ... but I have no idea about my case .....
Please , help me with this ....
Are these kinds of XML can be really somehow binded and work together with "Castor" ?
It it really possible to do these things ?
I will really appreciate your attempt to help me .
Thank you ,
Marat

To create class file for binding in castor, your first step is to create an XML Schema or .xsd file. Then assuming it is installed correctly type: java org.exolab.castor.builder.SourceGenerator -i whatever.xsd -package com.xyz.myxml.castor
This would create the java class file in the package com.zyx.myxml.castor that corresponds to your XML schema

Similar Messages

  • Problem testing WebMethod. Throwing javax.xml.bind.JAXBException

    Hi guys,
    Another Newbie.
    Specifications:
    NetBeans5.5
    Sun App Server 9.0_01 (build b02-p01)
    MySQL
    Problem: Not able to test run the Webmethod with webparams.
    I have an entity class with some methods as shown below
    public class Country {
        private Integer countryID;
        private ServerDatabaseInteraction di;
        private String countryName;
        /** Creates a new instance of Country */
        public Country(ServerDatabaseInteraction di) {
            this.di = di;
         * Creates a new instance of Country with the specified values.
         * @param countryID the countryID of the Country
        public Country(Integer countryID) {
            this.countryID = countryID;
         * Creates a new instance of Country with the specified values.
         * @param countryID the countryID of the Country
         * @param countryName the countryName of the Country
        public Country(Integer countryID, String countryName, ServerDatabaseInteraction di) {
            this.di = di;
            this.countryID = countryID;
            this.countryName = countryName;
         * Gets the countryID of this Country.
         * @return the countryID
        public Integer getCountryID() {
            return this.countryID;
         * Sets the countryID of this Country to the specified value.
         * @param countryID the new countryID
        public void setCountryID(Integer countryID) {
            this.countryID = countryID;
         * Gets the countryName of this Country.
         * @return the countryName
        public String getCountryName() {
            return this.countryName;
         * Sets the countryName of this Country to the specified value.
         * @param countryName the new countryName
        public void setCountryName(String countryName) {
            this.countryName = countryName;
        public void insert() throws SQLException {
            di.update("INSERT INTO Country (CountryName) VALUES ('"+getCountryName()+"')");
        public ArrayList list() throws SQLException {
            ArrayList queryAL = new ArrayList();
            ResultSet rs = di.queryToResultSet("SELECT CountryID, CountryName FROM Country");
            while(rs.next()) {
                String temp = rs.getInt(1)+"#"+rs.getString(2);
                queryAL.add(temp);
             return queryAL;
    }    then I created a Web service having two methods as follows
    @WebService
    public class CountryWS {
        ServerDatabaseInteraction di;
        Country country;
        public CountryWS() {
            try {
                di = new ServerDatabaseInteraction();
            } catch (Exception ex) {
                ex.printStackTrace();
            country = new Country(di);
         * Web service operation
        @WebMethod
        public ArrayList listPKobjects() {
            try {
                return country.list();
            } catch (SQLException ex) {
                ex.printStackTrace();
                return null;
         * Web service operation
        @WebMethod
        public String insert(@WebParam(name = "CountryName") String CountryName) {
            // TODO implement operation
            country.setCountryName(CountryName);
            try {
                country.insert();
                return "Inserted";
            } catch (SQLException ex) {
                ex.printStackTrace();
                return "Insert Failed";
    }Now the problem is Im able to test (by right clicking on webservice from IDE) the webmethod listPKObjects but not the insert method. only difference is the second one is having webparms.
    the log shows as follows..
    CountryName is not a valid property on class myhost.fli.ws.jaxws.Insert
    javax.xml.bind.JAXBException: CountryName is not a valid property on class myhost.fli.ws.jaxws.Insert
         at com.sun.xml.ws.encoding.EncoderDecoderBase.getRawAccessor(EncoderDecoderBase.java:128)
         at com.sun.xml.ws.encoding.EncoderDecoderBase.getWrapperChildValue(EncoderDecoderBase.java:81)
         at com.sun.xml.ws.encoding.soap.EncoderDecoder.fillData(EncoderDecoder.java:78)
         at com.sun.xml.ws.encoding.soap.ServerEncoderDecoder.toMessageInfo(ServerEncoderDecoder.java:97)
         at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.toMessageInfo(SOAPMessageDispatcher.java:209)
         at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher$SoapInvoker.invoke(SOAPMessageDispatcher.java:573)
         at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:147)
         at com.sun.xml.ws.server.Tie.handle(Tie.java:90)
         at com.sun.enterprise.webservice.JAXWSServlet.doPost(JAXWSServlet.java:195)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
         at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
         at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
         at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
         at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
         at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
    Caused by: javax.xml.bind.JAXBException: CountryName is not a valid property on class myhost.fli.ws.jaxws.Insert
         at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:816)
         at com.sun.xml.ws.encoding.EncoderDecoderBase.getRawAccessor(EncoderDecoderBase.java:124)
         ... 34 moreCan't find a reason, why one webmethod is working and the other one is not.
    Any help would be much appriciated.

    I'm encountering the same problem, but it's very inconsistent. I've got three web services that I'm deploying. If I clean, rebuild, and redeploy, then different combinations of the three throw this error.
    My specifications:
    NetBeans 6.0
    GlassFish v2
    Oracle 10g
    In browsing around online, I came across the following link which suggested to me that this issue is known and is being addressed.
    https://jax-ws.dev.java.net/issues/show_bug.cgi?id=419
    I discovered that the reason that I was getting this error was because my web services all had the same operation names. When I renamed my operations in each service so that they had different names, this fixed the problem.
    Hope this helps!
    - Erich Musick

  • Problem with JAXB Unmarshall - javax.xml.bind.UnmarshalException

    Hi,
    I'm getting an expection while unmarshalling using JAXB. The error is as follows :
    DefaultValidationEventHandler: [ERROR]: unexpected element (uri:"http://www.etrade.com/ee/systemdomainao/search", local:"Context_Id"). Expected elements are <{}contextId>,<{}predicateInterceptor>,<{}isDefaultsearch>,<{}implicitContextSQL>,<{}contextName>,<{}searchId>,<{}implicitContextText>
    I've generated JAXB classes using xjc command from my schema. The root element is Search object which has a List of Searchcontext and Columlist object. When I'm trying to unmarshall the XML, I'm getting the above exception. What is baffling, if I comment out the <tns:SearchContext> entry from the XML, unmarshall doesn't throw any exception and populates the columnlist properly. Columnlist and Searchcontext have little difference except that columnlist contains more elements.
    Here'e the unmarshall code,
    URL metadataURL = this.getClass().getClassLoader().getResource("metadata/search/PARTICIPANT.xml");
    JAXBContext jc = JAXBContext.newInstance("com.etrade.ee.systemdomainao.search.domain");
    Unmarshaller unmarshaller = jc.createUnmarshaller();
    unmarshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
    Search search = (Search)unmarshaller.unmarshal(metadataURL);
    Any pointers will be highly appreciated.
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    XSD :
    XSD :
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.etrade.com/ee/systemdomainao/search" targetNamespace="http://www.etrade.com/ee/systemdomainao/search" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <!-- Searchcontext type definition -->
         <xs:complexType name="Searchcontext">
              <xs:sequence>
                   <xs:element name="Context_Id" type="xs:int"/>
                   <xs:element name="Search_Id" type="xs:string"/>
                   <xs:element name="Context_Name" type="xs:string"/>
                   <xs:element name="Implicit_Context_SQL" nillable="true">
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:maxLength value="500"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="Implicit_Context_Text" nillable="true">
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:maxLength value="500"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="Is_Defaultsearch" type="xs:boolean" nillable="true"/>
                   <xs:element name="Predicate_Interceptor" type="xs:string" nillable="true"/>
              </xs:sequence>
         </xs:complexType>
         <!-- Searchlist type definition -->
         <xs:complexType name="Columnlist">
              <xs:sequence>
                   <xs:element name="Columnlist_Id" type="xs:int"/>
                   <xs:element name="Search_Id" type="xs:string"/>
                   <xs:element name="Is_Quicksearchable" type="xs:boolean" nillable="true"/>
                   <xs:element name="Is_Advancesearchable" type="xs:boolean" nillable="true"/>
                   <xs:element name="Is_Quicksearchview" type="xs:boolean" nillable="true"/>
                   <xs:element name="Is_Fullview" type="xs:boolean" nillable="true"/>
                   <xs:element name="Is_Sortable" type="xs:boolean" nillable="true"/>
                   <xs:element name="Is_Defaultsort" type="xs:boolean" nillable="true"/>
                   <xs:element name="Default_SortOrder" type="xs:string" nillable="true" minOccurs="0"/>
                   <xs:element name="Display_Order" type="xs:int" nillable="true"/>               
                   <xs:element name="Default_Value" type="xs:string" nillable="true" maxOccurs="6"/>
                   <xs:element name="Default_Operator" type="xs:string" nillable="true"/>
                   <xs:element name="Is_Closedset" type="xs:boolean"/>
                   <xs:element name="Closedset_List_Name" type="xs:string" nillable="true"/>
                   <xs:element name="Is_RelatedMenu" type="xs:boolean" minOccurs="0"/>
                   <xs:element name="Column_Name" type="xs:string"/>
                   <xs:element name="Display_Name" type="xs:string"/>
                   <xs:element name="Is_UDF" type="xs:boolean" nillable="true"/>
                   <xs:element name="Table_Name" type="xs:string"/>
                   <xs:element name="Data_Type" type="xs:string"/>
                   <xs:element name="Column_Size" type="xs:int"/>
              </xs:sequence>
         </xs:complexType>
         <!-- Search declaration -->
         <xs:element name="Search">
              <!--<choice>
         <xs:interface name="java.io.Serializable" />
         </choice>-->
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="Search_Id" type="xs:string"/>
                        <xs:element name="Schema_Set">
                             <xs:simpleType>
                                  <xs:restriction base="xs:string">
                                       <xs:maxLength value="20"/>
                                       <xs:minLength value="1"/>
                                  </xs:restriction>
                             </xs:simpleType>
                        </xs:element>
                        <xs:element name="SearchContext" type="tns:Searchcontext" maxOccurs="unbounded"/>
                        <xs:element name="ColumnList" type="tns:Columnlist" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
              <xs:key name="Search_PrimaryKey_1">
                   <xs:selector xpath="."/>
                   <xs:field xpath="tns:Search_Id"/>
              </xs:key>
              <xs:keyref name="Searchcontext_ForeignKey_1" refer="tns:Search_PrimaryKey_1">
                   <xs:selector xpath=".//tns:SearchContext"/>
                   <xs:field xpath="tns:Search_Id"/>
              </xs:keyref>
              <xs:keyref name="Columnlist_ForeignKey_2" refer="tns:Search_PrimaryKey_1">
                   <xs:selector xpath=".//tns:ColumnList"/>
                   <xs:field xpath="tns:Search_Id"/>
              </xs:keyref>
              <xs:key name="Searchcontext_PrimaryKey_1">
                   <xs:selector xpath=".//tns:SearchContext"/>
                   <xs:field xpath="tns:Context_Id"/>
              </xs:key>
              <xs:key name="Columnlist_PrimaryKey_1">
                   <xs:selector xpath=".//tns:ColumnList"/>
                   <xs:field xpath="tns:Columnlist_Id"/>
              </xs:key>
         </xs:element>
    </xs:schema>

  • How do I marshall a list using javax.xml.bind.annotation?

    Hopefully this is so simple a cave man could do it.
    I had to remove the Duke Stars for the time being. I found another bug in the program that may have resulted in my array being empty.
    I'm trying to marshall a standalone document of my DeckImpl class. It is a deck of cards of course. It contains an array of CardImpl objects that need to be marshalled too. I could not figure out how to marhall the array so I have a marshall(Marshaller m) method that will
    initialize the List (see below) with an ArrayList. I figured the marshaller would do the rest but I just get the declaration and a closed <DECK />tag with the correct attributes (see way below) when I comment out the @XmlElementWrapper, or a DECK root node that simply contains a closed <CARDS /> tag with the line enabled. You can see tha CardImpl class is annotated too.
    I must be missing something obvious. Please help.
    @XmlRootElement(name = "DECK")
    @XmlType(name = "DECK")
    public class DeckImpl implements Comparable<DeckImpl> {
        @XmlAttribute
        public int id;
        @XmlAttribute
        public boolean isShuffled;
        @XmlAttribute
        public boolean isCut;
        public CardImpl[] cards;
        @XmlElementWrapper(name="CARDS")
        @XmlElements(@XmlElement(name="CARD",type=CardImpl.class))
        public List<CardImpl> CARDS;
        private static JAXBContext context;
        private static Marshaller marshaller;
    public DeckImpl(int id, boolean isCut, boolean isShuffled,
                CardImpl[] cards) {
            this.id = id;
            this.isShuffled = isShuffled;
            this.isCut = isCut;
            this.cards = cards;
            try {
                context = JAXBContext.newInstance(DeckImpl.class);
                marshaller = context.createMarshaller();
            } catch (JAXBException ex) {
                Logger.getLogger(CardImpl.class.getName()).log(Level.SEVERE, null, ex);
    //... class code goes here
    /** Generates XML representation of a deck
         * @param writer
         * @throws javax.xml.bind.JAXBException
        public void marshall(Writer writer) throws JAXBException {
            CARDS = new ArrayList<CardImpl>(cards.length);
            for (CardImpl i : cards) {
                CARDS.add(i);
            marshaller.marshal(this, writer);
    @XmlType(name = "CARD")
    public class CardImpl implements Comparable<CardImpl> {
        @XmlElement(name = "NAME")
        public String name;
        @XmlElement(name = "SUIT")
        public String suit;
        @XmlAttribute
        public int value;
        @XmlAttribute
        public int pointValue;
    //... class code
    }The output is:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><DECK isCut="false" isShuffled="true" id="1"/>Regards,
    Bill
    Edited by: bthayer on Jan 24, 2009 7:15 AM
    Edited by: bthayer on Jan 25, 2009 7:02 AM

    There's a bit in here on marshalling.
    http://java.sun.com/webservices/docs/1.4/tutorial/doc/index.html
    Problem with JAXB (and I could be wrong - try posting on the Web Services / XML forum) is that you can only marshal the generated classes. This may mean that you need to create the object, and populate it using the setter / getter methods.
    Castor is much more friendly for this as it can marshall objects using reflections. You may also want to look into XMLBeans (which I have no exp of)

  • Query on XML Beans replacing Castor Java -XML Bindings

    Hello,
    We use Castor XML Framework for today Java - XML bindings and were looking for XML Beans replacement.
    One of the key problems we face in using XML (maybe a flawed design) is we create XSD for our applications and run Castor to generate Java Classes as Libraries (XMLFramework.jar).
    Applications are compiled with these Java libraries and Castor is used to Marshal the Java Object as XML Document when invoking a remote API and at the receiving side it is used to unmarshal back the XML document to Java Object.
    Major issues we have seen is that if any XSD (that defines application ICD) changes, we need to re-generate Castor Java classes (new XMLFramework.jar) and re-compile applications that were using these classes with new JAR files..... Thus for small XSD changes the impact is in lot of applications (where an application is an EAR deployed on WLS)
    Does XMLBeans help here that I can change XSD without changing all the end-points that use Classes generated out of these XSDs (when additing mandatory or optinal elements) ?
    Or there is a flaw in which we have used the Java-XML binding framework like Castor and XMLBeans do not help much ?

    Can someone please suggest on how I can go about
    converting an XML file into word format using Java
    ?How about POI?

  • Java Mapping Using JAXB [Java Arch for XML Binding]

    Hi All,
    Anyone tried using JAXB  [Java Architecture for XML Binding API available with Java WebServices Pack] technique for XML processing in Java Mapping??
    I am facing the following problems..
    1. I am not able to generate namespace while marshalling target XML [In standalone mode and not tried in XI].
    2. What are the jar files we need to import?
       I tried importing the following jar files in XI.
    jaxb-api.jar,jaxb-impl.jar,jaxb-libs.jar,jax-qname.jar,namespace.jar,relaxngDatatype.jar
      and getting some errors while importing these files in XI.
    3. It throws error at runtime [Interface Mapping-Test Tab]
       like Resource not found:javax/xml/bind/Messages_en.properties,javax/xml/bind/Messages_en_US.properties
    4. Even after creating a copy of available file Messages.Properties with name: Messages_en.properties and Messages_en_US.properties.. it is not generating any messages in Target message tab
    Thanks in Advance,
    Ananth Chinnaraj

    Sravya ,
    I have searched wide and far for this, but no success.
    A lot on JAXB XI and Webdynpro, but nothing on JAXB, XI and mappings.
    Could you please post the url here ?
    Thanks and kind regards,
    Jan

  • Best XML binding framework or utility???

    Hi all,
    In my application I am storing all the data into XML file. And I have designed the resource layer entty. Now I want to know which mechanism of object to XML binding is better (like Castor, JAXB etc). So it will be great if some one can suggest me which mapper is better and why.
    Thanks in advance
    Mithun

    Castor and JiBX come out as a good all-round
    performers, while JAXB carries the clout of being one
    of the web service tools included in the Java EE 5
    specification.-1 JAXB. Especially if you use clear case. I don't know if they changed this but the version of I use JAXB produces lines of code that are longer than clear case will accept. This is really annoying as clear case doesn't tell you that, it just gives some vague error about not being able to check in the code.
    Also, I don't really consider JAXB a binding framwork. It;s a code generator. And what it generates basically requires lots of hardcoding in order to use it. It's not a flexible solution. You can probably get away with it for small numbers of simple schemas but if you have lots lf different scehmas to deal with I would avoid it like the plague.

  • How do I install javax.xml.bind...

    Hi,
    I'm kind of a beginner in the java world and I have some serious problems when I'm trying to use JAXB.
    I have downloaded JDK 1.5.0_6, Java WebServices Dev Kit 2.0 and when I try to run a simple example I receive these compiler errors:
    package javax.xml.bind does not exist
    package javax.xml.marshall does not exist......etc.
    What do I do wrong. I've tried for 2 days to get this @#$ example to work, can someone help me out please.
    Thanks

    javax.xml.bind couldn't have been around in 2002, so i'm not sure what is wrong w/ that tutorial.
    What I want to do is to create XML data and read and
    write it from a file. What is the best way to do
    this??You don't need JAXB or binding for this, although it probably can be used for this as well. What you probably need is JAXP, such as SAX or DOM APIs.
    I've read about about JAXP in the past in J2EE 1.4 Tutorial:
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/J2EETutorial.pdf.
    You may want to read up on SAX and DOM there or in another one. I forgot a lot of the stuff, but this should get you started on SAX:
    public static void main(String argv[])
    if (argv.length != 1) {
    System.err.println("Usage: cmd filename");
    System.exit(1);
    // Use an instance of ourselves as the SAX event handler
    DefaultHandler handler = new Echo();
    // Use the default (non-validating) parser
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
    // Set up output stream
    out = new OutputStreamWriter(System.out, "UTF8");
    // Parse the input
    SAXParser saxParser = factory.newSAXParser();
    saxParser.parse( new File(argv[0]), handler );
    } catch (Throwable t) {
    t.printStackTrace();
    System.exit(0);
    }

  • Where to find javax.xml.bind and javax.jdo

    One of my application require import javax.xml.bind and javax.jdo packages. I could not find them. Someone can help to let me know where to download them or they come with some other toll\packages?
    Thanks
    John

    Hi John ,
    I have the same problem: Getting the javax.jdo Packge . . . .(WHERE ?)
    if you found out ow already, please tell me at: [email protected]
    thanks,
    edan

  • XML Binding of a GregorianCalendar

    Im using XMLSpy, and trying to bind a Gregorian Calendar, does any one know of a good way to do this, so I can validate the XML that was created, using the Gregorian Calendar. Where the ????? is what do I put here.
    <xsd:element name="startDate" type="?????" nillable="true"/>

    Tried that but still no match. I had to change the Java Beans used to make the XML file via castor, to have java.util.Date(s) instead of java.util.Calendar(s). It works, but not exactly what I wanted.
    Bill

  • Unable to resolve "javax.xml.bind.InvalidAttributeException"

    Hi all,
    Iam facing a problem with my jaxb
    the compiler is able to identify " javax.xml.bind.Marshaller" but it is not able to identify "javax.xml.bind.MissingContentException ","avax.xml.bind.PredicatedLists ","javax.xml.bind.InvalidContentObjectException ","javax.xml.bind.LocalValidationException "
    Im using "jwsdp-1.5" and have set the classpath , could i please be known as to why im facing this problem. when i unjar and check the jaxb file i can find the "Marshaller" class file but i could not see the remaining which i mentioned above.
    can anyone tell me as to which version of jaxb should i use?
    this is very very urgent, any help in this matter is highly appreciated.
    Thanks in advance.

    Hi John ,
    I have the same problem: Getting the javax.jdo Packge . . . .(WHERE ?)
    if you found out ow already, please tell me at: [email protected]
    thanks,
    edan

  • Compiler can not find javax.xml.bind package classes

    Hi
    I have quite simple (I hope) problem. I'm trying to run some jaxb example but when I try to compile it I get:
    Test.java:20: package javax.xml.bind does not exist
    import javax.xml.bind.JAXBContext;
                          ^
    Test.java:21: package javax.xml.bind does not exist
    import javax.xml.bind.Marshaller;
                          ^
    Test.java:22: package javax.xml.bind does not exist
    import javax.xml.bind.Unmarshaller;
                          ^
    Test.java:23: package javax.xml.bind does not exist
    import javax.xml.bind.Validator;
                          ^I added to my classpath all packages I found to have anything in common with jaxb:
    jaxb-api.jar
    jaxb-xjc.jar
    jaxb-ri.jar
    jaxb.libs.jar
    jaxp-api.jar
    sax.jar
    dom.jar
    xercesImpl.jar
    xalan.jar
    jax-qname.jar
    namespace.jar
    All of those are taken from jwsdp-1.6
    Any ideas?
    ania

    Add the following .jar files to the CLASSPATH variable.
    <JWSDP>/jaxb/lib/jaxb-api.jar
    <JWSDP>/jaxb/lib/jaxb-impl.jar
    <JWSDP>/jaxb/lib/jaxb-libs.jar
    <JWSDP>/jaxb/lib/jaxb-xjc.jar
    <JWSDP>/jwsdp-shared/lib/namespace.jar
    <JWSDP>/jwsdp-shared/lib/jax-qname.jar
    <JWSDP>/jwsdp-shared/lib/relaxngDatatype.jar
    <JWSDP> is the directory in which Java Web Service Developer Pack 1.5 is installed.

  • Javax.xml.bind.UnmarshalException

    I am using JAXB to parse the xml file. The sample of my xml file is given below:
    <rdcData version="1.0" target="NDA-RDC">
    <entity event="D" subtype="String" type="I">
    <header>
    <PI>10408819</PI>
    </header>
    <content>
    <property id="27007">
    <currValue classifier="code"/>
    <validFrom>20050702</validFrom>
    <validTo>20050703</validTo>
    </property>
    </content>
    </entity>
    </rdcData>
    And at runtime I am gettting the following exception.
    javax.xml.bind.UnmarshalException: Unexpected element {}:entity
    Someone please help me to solve this problem.

    HI Smile,
    Thanks for the reply.
    Here is the complete description of the error.
    DefaultValidationEventHandler: [ERROR]: Unexpected element {}:entity
    Location: line 3 of file:/C:/new%20eclispe/workspace/RDCLoader/incr.xml
    javax.xml.bind.UnmarshalException: Unexpected element {}:entity
         at com.reuters.rdcrefdata.impl.runtime.SAXUnmarshallerHandlerImpl.handleEvent(SAXUnmarshallerHandlerImpl.java:577)
         at com.reuters.rdcrefdata.impl.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(AbstractUnmarshallingEventHandlerImpl.java:139)
         at com.reuters.rdcrefdata.impl.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(AbstractUnmarshallingEventHandlerImpl.java:136)
         at com.reuters.rdcrefdata.impl.runtime.AbstractUnmarshallingEventHandlerImpl.unexpectedEnterElement(AbstractUnmarshallingEventHandlerImpl.java:147)
         at com.reuters.rdcrefdata.impl.runtime.AbstractUnmarshallingEventHandlerImpl.enterElement(AbstractUnmarshallingEventHandlerImpl.java:60)
         at com.reuters.rdcrefdata.impl.RdcDataImpl$Unmarshaller.enterElement(RdcDataImpl.java:176)
         at com.reuters.rdcrefdata.impl.runtime.SAXUnmarshallerHandlerImpl.startElement(SAXUnmarshallerHandlerImpl.java:125)
         at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:575)
         at com.sun.xml.bind.unmarshaller.InterningXMLReader.startElement(InterningXMLReader.java:74)
         at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:575)
         at com.reuters.rdcrefdata.load.Splitter.startElement(Splitter.java:190)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:485)
         at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:326)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1563)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:341)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:828)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:758)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1105)
         at com.reuters.rdcrefdata.load.OrganisationRefDataLoader.main(OrganisationRefDataLoader.java:114)
    Exception in thread "main"
    If you see the first line you will notice that the "SAXUnmarshallerHandlerImpl.java" class which is generated by the jaxb and put into the folder "impl.runtime".
    And hence I am sure that the error lies in the classes generated by the jaxb only.
    The xml that I have used here is ,
    <?xml version="1.0" encoding="UTF-8"?>
    <rdcData version="1.0" target="NDA-RDC">
    <entity event="U" subtype="ORD" type="Q">
    <header>
    <PI>5073152</PI>
    </header>
    <content>
    <property id="27207">
    <currValue>BAC 5.020 08/22/06 FRN MTN</currValue>
    <validFrom>20060301</validFrom>
    <validTo>20060306</validTo>
    </property>
    <property id="27207">
    <currValue>BAC 5.400 08/22/06 FRN MTN</currValue>
    <validFrom>20060530</validFrom>
    <validTo>20060530</validTo>
    </property>
    </content>
    </entity>
    </rdcData>
    Hope above information will be sufficient for you to help me.
    Regards

  • XML error "java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext"

    Hi Experts,
    We are developing a WebDynpro for java application in NWDI for XML File Uploading, we have followed the below given process for that
    1) Created one XSD as per the client table structure.
    2) Developed one java webserver for the XSD file using jwsdp1.6
    3) Copied that generated folder in WebDynpro application
    4) Included all the required JAX-B jars as External jar files
    5) Finally Compiles the application
    When running the application it is throwing the below exception
    500 Internal Server Error   Web Dynpro Container/SAP J2EE Engine/6.40     
    Failed to process request. Please contact your system administrator.
    Error Summary 
    While processing the current request, an exception occured which could not be handled by the application or the framework.
    If the information contained on this page doesn't help you to find and correct the cause of the problem, please contact your system administrator. To facilitate analysis of the problem, keep a copy of this error page. Hint: Most browsers allow to select all content, copy it and then paste it into an empty document (e.g. email or simple text file).
    Root Cause    
    The initial exception that caused the request to fail, was:
    java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
    at com.ae.energy.scm.wdp.InternalXMLFileUpload.<init>(InternalXMLFileUpload.java:403)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    We checked entire application to ensure all the required files included, Could you please give us the cause for this exception and please explain us the solution to resolve it.
    We are very thankful for all the people who can give their support in resolving this issue.
    Thanks in advance,
    Sandeep Bonam

    Hi Sandeep,
    If you are following DC developemnt for your project, then adding the required JAR files as External Jars will not suffice.
    As at deployment, these "External Jars" are not considered.
    You will need to create and External Library project, for incorporating the required jars.
    For creation and use of External Library Project kindly follow Valery's blog:
    /people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro
    Hope it Helps.
    Regards,
    Alka.

  • JAXB javax.xml.bind.UnmarshalException: Unexpected end of element

    I'm getting the following UnmarshalException when I try to run Unmarshaller.unmarshal from the command line but not when I run it in WSAD:
    2006-04-20 16:11:54,680 REPOST ERROR [main] (RestrictedListResponseConsumer.java:111) javax.xml.bind.UnmarshalException: Unexpected end of element {}:origin_country
            at com.b.watchdog.jaxb.generated.response.impl.runtime.SAXUnmarshallerHandlerImpl.handleEvent(SAXUnmarshallerHandlerImpl.java:580)
            at com.b.watchdog.jaxb.generated.response.impl.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(AbstractUnmarshallingEventHandlerImpl.java:139)
            at com.b.watchdog.jaxb.generated.response.impl.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(AbstractUnmarshallingEventHandlerImpl.java:136)
            at com.b.watchdog.jaxb.generated.response.impl.runtime.AbstractUnmarshallingEventHandlerImpl.unexpectedLeaveElement(AbstractUnmarshallingEventHandlerImpl.java:153)
            at com.b.watchdog.jaxb.generated.response.impl.runtime.AbstractUnmarshallingEventHandlerImpl.leaveElement(AbstractUnmarshallingEventHandlerImpl.java:63)
            at com.b.watchdog.jaxb.generated.response.impl.MessageHeaderTypeImpl$Unmarshaller.leaveElement(MessageHeaderTypeImpl.java:245)
            at com.b.watchdog.jaxb.generated.response.impl.runtime.SAXUnmarshallerHandlerImpl.endElement(SAXUnmarshallerHandlerImpl.java:141)
            at org.iso_relax.verifier.impl.ForkContentHandler.endElement(ForkContentHandler.java:81)
            at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
            at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
            at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
            at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
            at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
            at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
            at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
            at com.b.watchdog.jaxb.generated.response.impl.runtime.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:140)
            at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:131)
            at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:136)
            at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:145)
            at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:163)
            at com.b.watchdog.RestrictedListResponseConsumer.consumeResponse(RestrictedListResponseConsumer.java:81)
            at com.b.watchdog.RestrictedListResponseConsumer.consumeResponses(RestrictedListResponseConsumer.java:52)
            at com.b.watchdog.RestrictedListInterfaceManager.exchangeData(RestrictedListInterfaceManager.java:307)
            at com.b.watchdog.RestrictedListInterfaceManager.main(RestrictedListInterfaceManager.java:282)My message is:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <list_update_response xsi:schemaLocation="http://www.ab.com list_update_response.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ab.com">
         <response_info>
              <message_header>
                   <origin_country>FR</origin_country>
                   <destination_country>US</destination_country>
                   <message_datetime>2006-04-18T19:02:00.000+00:00</message_datetime>
              </message_header>
         </response_info>
         <success>
              <request_info>
                   <message_header>
                        <origin_country>US</origin_country>
                        <destination_country>FR</destination_country>
                        <message_datetime>2006-04-20T18:40:31.000+00:00</message_datetime>
                   </message_header>
              </request_info>
         </success>
    </list_update_response>My XSDs are:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.ab.com" xmlns="http://www.ab.com">
         <xsd:include schemaLocation="list_update_common.xsd" />
         <xsd:element name="description" type="positive_length_token" />
         <xsd:element name="error">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element minOccurs="0" ref="request_info" />
                        <xsd:element ref="errors" />
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="errors">
              <xsd:complexType>
                   <xsd:choice maxOccurs="unbounded" minOccurs="1">
                        <xsd:element ref="validation_error" />
                        <xsd:element ref="general_logical_error" />
                        <xsd:element ref="item_logical_error" />
                   </xsd:choice>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="general_logical_error">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="description" />
                        <xsd:element minOccurs="0" ref="line_number" />
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="item_logical_error">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="description" />
                        <xsd:element minOccurs="0" ref="line_number" />
                   </xsd:sequence>
                   <xsd:attribute name="item_id" type="item_id" use="required" />
                   <xsd:attribute name="item_creation_country" type="country_code" use="required" />
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="line_number" type="xsd:positiveInteger" />
         <xsd:element name="list_update_response">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="response_info" />
                        <xsd:choice>
                             <xsd:element ref="error" />
                             <xsd:element ref="success" />
                        </xsd:choice>
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="response_info">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="message_header" />
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="success">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="request_info" />
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="validation_error">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="description" />
                        <xsd:element ref="line_number" />
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
    </xsd:schema>
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.ab.com" xmlns="http://www.ab.com">
         <xsd:simpleType name="country_code">
              <xsd:restriction base="xsd:string">
                   <xsd:pattern value="[A-Z]{2}" />
              </xsd:restriction>
         </xsd:simpleType>
         <xsd:element name="destination_country" type="country_code" />
         <xsd:simpleType name="item_id">
              <xsd:restriction base="xsd:string">
                   <xsd:pattern value="[A-Z0-9]{12}" />
              </xsd:restriction>
         </xsd:simpleType>
         <xsd:element name="message_datetime" type="utc_datetime" />
         <xsd:element name="message_header">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="origin_country" />
                        <xsd:element ref="destination_country" />
                        <xsd:element ref="message_datetime" />
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:element name="origin_country" type="country_code" />
         <xsd:simpleType name="positive_length_token">
              <xsd:restriction base="xsd:token">
                   <xsd:minLength value="1" />
              </xsd:restriction>
         </xsd:simpleType>
         <xsd:element name="request_info">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element ref="message_header" />
                   </xsd:sequence>
              </xsd:complexType>
         </xsd:element>
         <xsd:simpleType name="utc_datetime">
              <xsd:restriction base="xsd:dateTime">
                   <xsd:pattern value=".*(\+00\:00|\-00\:00|Z)" />
              </xsd:restriction>
         </xsd:simpleType>
    </xsd:schema>Any thoughts?
    Thanks.
    - Luke

    I fixed the problem.

Maybe you are looking for