Hi,
Environment:
I am running the latest Netbeans 6.8 and GF V3 (As of 9 Feb 2010).
Problem:
I am trying to marshal a simple jaxb object from within a Stateless Local EJB called/triggered from a timer service. The problem I am trying to resolve is when calling the Marshaller.marshal(config, streamWriter) it gives me an error "class java.io.Writer not loaded" which results in the following JAXBException:
"Caused by: javax.xml.bind.JAXBException: class arms.config.generated.OlarisVariable nor any of its super class is known to this context."
I have tested this in a stand alone project and everything works as expected, which leads me to believe there is a possible problem when running this from within a timer EJB.
What am I after?
I am wondering if any 1 else can replicate this problem or if they can marshal an object from within a timer ejb.
The xsd is:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
targetNamespace="
http://xml.cwr.uwa.edu.au/schema/rms"
xmlns:tns="
http://xml.cwr.uwa.edu.au/schema/rms"
elementFormDefault="qualified">
<xsd:element name="OlarisVariable">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="OlarisVariable">
</xsd:schema>
the class:
import arms.config.generated.*;
import arms.server.exceptions.resources.ParseException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
/**
*
* @author Goodyear
*/
public class ConfigManager {
private static String GENERATED = "arms.config.generated";
public Object getObject(InputStream stream) throws ParseException {
try {
JAXBContext jc = JAXBContext.newInstance(GENERATED);
Unmarshaller u = jc.createUnmarshaller();
return (Object) u.unmarshal(stream);
} catch (JAXBException ex) {
throw new ParseException(ex);
}
}
public void setObject(Object config, File file) throws ParseException {
try {
setObject(config, new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
} catch (FileNotFoundException ex) {
throw new ParseException(ex);
} catch (UnsupportedEncodingException ex) {
throw new ParseException(ex);
}
}
public void setObject(Object config, Writer streamWriter) throws ParseException {
try {
JAXBContext jc = JAXBContext.newInstance(GENERATED);
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
m.marshal(config, streamWriter);
} catch (JAXBException ex) {
throw new ParseException(ex);
}
}
}
[Message sent by forum member 'leegoodyear' (goodyear_at_cwr.uwa.edu.au)]
http://forums.java.net/jive/thread.jspa?messageID=385569