[
Lists Home |
Date Index |
Thread Index
]
- To: xml-dev@lists.xml.org
- Subject: Re: [xml-dev] Problem using JAXB (from Sun)
- From: Mukul Gandhi <mukul_gandhi@yahoo.com>
- Date: Tue, 16 Aug 2005 00:23:31 -0700 (PDT)
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Ffw2/3knihXPdsleHMREhUSKNP7v6IMOMKcbEn9PN1bWsxog5dvKYGQp++U4OmKhHYZeWoOxpPFzWV7h4wEY6f0X9oGOG9CCqsbJdXhAshIhg1bmR0e/qrrf7amZhGWeNdAoV49kMqYMx1GYOwG9RNaRcfYvT1g6N+uirK/dW4s= ;
- In-reply-to: <20050812131034.54858.qmail@web32914.mail.mud.yahoo.com>
My problem got solved. There was some problem in the
XML Schema.
Regards,
Mukul
--- Mukul Gandhi <mukul_gandhi@yahoo.com> wrote:
> Hello,
> Sorry that this is third mail from me on this
> subject. Also sorry that my description so far was a
> bit vague. I'll try to explain the problem in more
> detail below.
>
> I am using Sun's Java Web Services Developer Pack
> 1.6
> (within that JAXB 2.0 Implementation). Everything
> seems to be working fine.
>
> First I used xjc compiler to generate type
> definitions
> from a XML Schema.
>
> Then I created a Java application to populate a Java
> object(which mirros the XML Schema) with some data.
>
> I am trying to marshal this Java object to a XML
> file.
>
>
> But when I run the Java application, I get XML
> output
> as
> <?xml version="1.0" encoding="UTF-8"
> standalone="yes"?>
>
> (the error is, that there comes no data from the
> Java
> object to this XML)
>
> My XML Schema seems to be all right (I can post it
> along with other files, if someone wishes to debug
> this application). It should be in fact correct I
> feel, because xjc compiler worked fine on the XML
> Schema. All the generated type definitions compiled
> fine along with my main Java application.
>
> The mail application is running fine, except it is
> generating blank XML..
>
> I'll appreciate any help.. (I have to finish this
> application fast).
>
> Regards,
> Mukul
>
> --- Mukul Gandhi <mukul_gandhi@yahoo.com> wrote:
>
> > Instead of implementing java.io.Serializable, I
> had
> > to
> > implement XMLSerializable by the CatalogueEntry
> > class
> > (or for any class for that matter).
> >
> > Now I am not getting error, but the XML output
> > coming
> > is blank i.e just this,
> >
> > <?xml version="1.0" encoding="UTF-8"
> > standalone="yes"?>
> >
> > Can someone please tell what could be the problem?
> >
> > Regards,
> > Mukul
> >
> > --- Mukul Gandhi <mukul_gandhi@yahoo.com> wrote:
> >
> > > I have got a Java object, which I want to
> marshal
> > to
> > > XML file finally.
> > >
> > > Below is the JAXB code I have written so far -
> > >
> > > import javax.xml.bind.JAXBException;
> > > import javax.xml.bind.Marshaller;
> > >
> > > public class CatalogueMain {
> > > public static void main(String[] args)
> > > {
> > > CatalogueCategory catalogue_category =
> > > new CatalogueCategory(
> > > 1,
> > > "Computer Products",
> > > "Computer Product
> > Category",
> > > -1
> > > );
> > >
> > > CatalogueEntry catalogue_entry =
> > > new CatalogueEntry(
> > > 1,
> > > 1,
> > > "Hard Disk",
> > > "Computer Hard Disk",
> > > "Technical vetting",
> > > "Business authorization",
> > > 55,
> > > "GBP",
> > > 1,
> > > "dummy_image_url",
> > > new Date(2005,5,8),
> > > "procure"
> > > );
> > >
> > > //create a Marshaller and marshal to
> standard
> > > output
> > > try
> > > {
> > > JAXBContext jc =
> > > JAXBContext.newInstance("generated");
> > >
> > > Marshaller m = jc.createMarshaller();
> > >
> > m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
> > > Boolean.TRUE);
> > > m.marshal(catalogue_entry, System.out);
> > > }
> > > catch(Exception ex)
> > > {
> > > ex.printStackTrace();
> > > }
> > > }
> > > }
> > >
> > > When I run this program, I am getting following
> > > exception -
> > >
> > > javax.xml.bind.MarshalException: the object
> > > parameter
> > > to marshal() is not marsha
> > > llable
> > > at
> > >
> >
>
generated.impl.runtime.MarshallerImpl.marshal(MarshallerImpl.java:88)
> > >
> > > at
> > >
> >
>
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshal
> > > lerImpl.java:66)
> > > at
> > CatalogueMain.main(CatalogueMain.java:47)
> > >
> > > Can somebody please tell where could be the
> > problem?
> > >
> > > The CatalogueEntry class definition is -
> > > public class CatalogueEntry extends
> > EntryAttributes
> > > implements java.io.Serializable {
> > >
> > > /**
> > > * Constructor for CatalogueEntry
> > > */
> > > public CatalogueEntry() {
> > > }
> > >
> > > /**
> > > Catalogue builds
> > > */
> > > private ArrayList associatedBuilds = null;
> > >
> > > /**
> > > Catalogue products
> > > */
> > > private ArrayList associatedProducts = null;
> > >
> > > /**
> > > Catalogue roles
> > > */
> > > private ArrayList associatedRoles = null;
> > >
> > > /**
> > > Category id
> > > */
> > > private int catalogueCategoryId = 0;
> > >
> > > /**
> > > Category name
> > > */
> > > private String catalogueCategoryName = null;
> > >
> > > /**
> > > * Field partNumber
> > > */
> > > private String partNumber = null;
> > >
> > > /**
> > > Type of the catalogue entry.
> > > 1= Generic Catalogue entry
> > > 2= Service
> > > */
> > > private int catalogueEntryType = 0;
> > >
> > > /**
> > > Constructor used for creating object to be used
> > > while
> > > inserting record
> > >
> > >
> > > * @param catalogueEntryId int
> > > * @param catalogueCategoryId int
> > > * @param name String
> > > * @param description String
> > > * @param techvet String
> > > * @param businessAuthorization String
> > > * @param price double
> > > * @param currency String
> > > * @param currencyID int
> > > * @param imageURL String
> > > * @param lastOrderDate Date
> > > * @param performAction String
> > > */
> > > public CatalogueEntry(
> > > int catalogueEntryId,
> > > int catalogueCategoryId,
> > > String name,
> > > String description,
> > > String techvet,
> > > String businessAuthorization,
> > > double price,
> > > String currency,
> > > int currencyID,
> > > String imageURL,
> > > Date lastOrderDate,
> > > String performAction) {
> > > super(
> > > catalogueEntryId,
> > > name,
> > > description,
> > > techvet,
> > > businessAuthorization,
> > > lastOrderDate,
> > > imageURL,
> > > price,
> > > currency,
> > > currencyID,
> > > performAction);
> > > this.catalogueCategoryId =
> catalogueCategoryId;
> > >
> > > }
> > >
> > >
> > > /**
> > > * Constructor for CatalogueEntry
> > > * @param catalogueEntryId int
> > > * @param catalogueCategoryId int
> > > * @param catalogueCategoryName String
> > > * @param name String
> > > * @param description String
> > > * @param techvet String
> > > * @param businessAuthorization String
> > > * @param price double
> > > * @param currency String
> > > * @param currencyID int
> > > * @param catalogueStatus String
> > > * @param imageURL String
> > > * @param lastOrderDate Date
> > > * @param standardStatus String
> > > * @param catalogueStatusId String
> > > */
> > > public CatalogueEntry(
> > > int catalogueEntryId,
> > > int catalogueCategoryId,
> > > String catalogueCategoryName,
> > > String name,
> > > String description,
> > > String techvet,
> > > String businessAuthorization,
> > > double price,
> > > String currency,
> > > int currencyID,
> > > String catalogueStatus,
> > > String imageURL,
> > > Date lastOrderDate,
> > > String standardStatus,
> > > int catalogueStatusId) {
> > >
> > > super(
> > > catalogueEntryId,
> > > name,
> > > description,
> > > techvet,
> > > businessAuthorization,
> > > catalogueStatus,
> > > catalogueStatusId,
> > > lastOrderDate,
> > > imageURL,
> > > standardStatus,
> > > price,
> > > currency,
> > > currencyID);
> > > this.catalogueCategoryId =
> catalogueCategoryId;
> > > this.catalogueCategoryName =
> > > catalogueCategoryName;
> > >
> > > }
> > >
> > > /**
> > > Access method for the associatedBuilds
> property.
> > >
> > > @return the current value of the
> > associatedBuilds
> > > property
> > > */
> > > public ArrayList getAssociatedBuilds() {
> > > return associatedBuilds;
> > > }
> > >
> > > /**
> > > Sets the value of the associatedBuilds
> property.
> > >
> > > @param aAssociatedBuilds the new value of the
> > > associatedBuilds property
> > > */
> > > public void setAssociatedBuilds(ArrayList
> > > aAssociatedBuilds) {
> > > associatedBuilds = aAssociatedBuilds;
> > > }
> > >
> > > /**
> > > Access method for the associatedProducts
> > property.
> > >
> > > @return the current value of the
> > > associatedProducts
> > > property
> > > */
> > > public ArrayList getAssociatedProducts() {
> > > return associatedProducts;
> > > }
> > >
> > > /**
> > > Sets the value of the associatedProducts
> > property.
> > >
> > > @param aAssociatedProducts the new value of the
> > > associatedProducts property
> > > */
> > > public void setAssociatedProducts(ArrayList
> > > aAssociatedProducts) {
> > > associatedProducts = aAssociatedProducts;
> > > }
> > >
> > > /**
> > > Access method for the associatedRoles property.
> > >
> > > @return the current value of the
> > associatedRoles
> > > property
> > > */
> > > public ArrayList getAssociatedRoles() {
> > > return associatedRoles;
> > > }
> > >
> > > /**
> > > Sets the value of the associatedRoles property.
> > >
> > > @param aAssociatedRoles the new value of the
> > > associatedRoles property
> > > */
> > > public void setAssociatedRoles(ArrayList
> > > aAssociatedRoles) {
> > > associatedRoles = aAssociatedRoles;
> > > }
> > >
> > > /**
> > > Access method for the catalogueEntryType
> > property.
> > >
> > > @return the current value of the
> > > catalogueEntryType
> > > property
> > > */
> > > public int getCatalogueEntryType() {
> > > return catalogueEntryType;
> > > }
> > >
> > > /**
> > > Sets the value of the catalogueEntryType
> > property.
> > >
> > > @param aCatalogueEntryType the new value of the
> > > catalogueEntryType property
> > > */
> > > public void setCatalogueEntryType(int
> > > aCatalogueEntryType) {
> > > catalogueEntryType = aCatalogueEntryType;
> > > }
> > >
> > > /**
> > > @return String
> > > Returns string representation of object
> > >
> > > */
> > > public String toString() {
> > > return null;
> > > }
> > >
> > > /**
> > > * Method getCatalogueCategoryId
> > > * @return int
> > > */
> > > public int getCatalogueCategoryId() {
> > > return catalogueCategoryId;
> > > }
> > >
> > > /**
> > > * Method getCatalogueCategoryName
> > > * @return String
> > > */
> > > public String getCatalogueCategoryName() {
> > > return catalogueCategoryName;
> > > }
> > >
> > > /**
> > > * Method setCatalogueCategoryId
> > > * @param i int
> > > */
> > > public void setCatalogueCategoryId(int i) {
> > > catalogueCategoryId = i;
> > > }
> > >
> > > /**
> > > * Method setCatalogueCategoryName
> > > * @param string String
> > > */
> > > public void setCatalogueCategoryName(String
> > string)
> > > {
> > > catalogueCategoryName = string;
> > > }
> > >
> > > /**
> > > * Method getPartNumber
> > > * @return String
> > > */
> > > public String getPartNumber() {
> > > return partNumber;
> > > }
> > >
> > > /**
> > > * Method setPartNumber
> > > * @param string String
> > > */
> > > public void setPartNumber(String string) {
> > > partNumber = string;
> > > }
> > >
> > > }
> > >
> > > I'll be grateful for any help.
> > >
> > > Regards,
> > > Mukul
> > >
> > >
> > >
> > >
> > >
> > >
> >
> ____________________________________________________
> > > Start your day with Yahoo! - make it your home
> > page
> > > http://www.yahoo.com/r/hs
> > >
> > >
> > >
> >
>
-----------------------------------------------------------------
> > > The xml-dev list is sponsored by XML.org
> > > <http://www.xml.org>, an
> > > initiative of OASIS <http://www.oasis-open.org>
> > >
> > > The list archives are at
> > > http://lists.xml.org/archives/xml-dev/
> > >
> > > To subscribe or unsubscribe from this list use
> the
> > > subscription
> > > manager:
> > > <http://www.oasis-open.org/mlmanage/index.php>
> > >
> > >
> >
> >
> >
> >
> >
> ____________________________________________________
> > Start your day with Yahoo! - make it your home
> page
> > http://www.yahoo.com/r/hs
> >
> >
> >
>
-----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org
> > <http://www.xml.org>, an
> > initiative of OASIS <http://www.oasis-open.org>
> >
> > The list archives are at
> > http://lists.xml.org/archives/xml-dev/
> >
> > To subscribe or unsubscribe from this list use the
> > subscription
> > manager:
> > <http://www.oasis-open.org/mlmanage/index.php>
> >
> >
>
>
>
>
> __________________________________
> Yahoo! Mail for Mobile
> Take Yahoo! Mail with you! Check email on your
> mobile phone.
> http://mobile.yahoo.com/learn/mail
>
>
-----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org
> <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at
> http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the
> subscription
> manager:
> <http://www.oasis-open.org/mlmanage/index.php>
>
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
|