• Post Reply Bookmark Topic Watch Topic
  • New Topic

javax.xml.bind.Marshall Exceptio the object parameter to marshal() is not marshallabl

 
Eric James
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to marshall one of several classes created created by the xjc compiler from .xsd. Not sure why the object can't be marshalled???

<%
ObjectFactory objFactory = new ObjectFactory();
SoftwareType st = objFactory.createSoftwareType();
st.setName("java");
st.setVersion("1.4");
st.setComments("comments here");

JAXBContext jaxbcontext = JAXBContext.newInstance("sourceforge.psi.mzdata");
Marshaller marshaller = jaxbcontext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true));
marshaller.marshal(st,System.out);
%>


Here is the stack trace:
javax.xml.bind.MarshalException: the object parameter to marshal() is not marshallable
com.sun.xml.bind.marshaller.MarshallerImpl.marshal(MarshallerImpl.java:74)
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:66)
org.apache.jsp.displayXML_jsp._jspService(displayXML_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)

Here is the java src soc generated:
@XmlAccessorType(AccessType.FIELD)
@XmlType(name = "softwareType", propOrder = {
"name",
"version",
"comments"
})
public class SoftwareType {

protected String name;
protected String version;
protected String comments;
@XmlAttribute
protected XMLGregorianCalendar completionTime;

public String getName() {
return name;
}
public void setName(String value) {
this.name = value;
}
public String getVersion() {
return version;
}
public void setVersion(String value) {
this.version = value;
}
public String getComments() {
return comments;
}
public void setComments(String value) {
this.comments = value;
}
public XMLGregorianCalendar getCompletionTime() {
return completionTime;
}
public void setCompletionTime(XMLGregorianCalendar value) {
this.completionTime = value;
}

}


Thanks,Eric
 
Manhar Puri
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not very sure of this but try changing the modifier for your variables from protected to private.

Also what happens if you set the completionTime variable.

Let me know if it works.

-Manhar.
[ June 29, 2006: Message edited by: Manhar Puri ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!