OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Problem using JAXB (from Sun)

[ 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: Fri, 12 Aug 2005 02:58:26 -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=PxZkObQPRXsGgQtq3fgGw+1uE5YSju6CPQvZsbVx6CpWtnVN4vzmgk9kixZNxHOVSdI4mg7I/D39WcPJiGCNBZRLJpyX5puXegmJWbE+qCo7o239av8vneiG36k6MAo1YYP1Rr699A9A60LEnh8xSVRG6nzkJXNFxNzfwZJZJfo= ;
  • In-reply-to: <20050812054632.99383.qmail@web32902.mail.mud.yahoo.com>

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 
 




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS