Hi,

do you validate your XML with an xsd? Have you done any extra
configuration for JAXB? And do you parse very large XML?

My Code looks like this. It hangs when parsing and validating large
XML files. I think the problem may be, that with JAXB too many classes
are created. Here is my code, which I copied from a JAXB tutorial:

                JAXBContext jc = null;
                Unmarshaller unmarsh = null;
                // The xml file
                XMLType xmlType = null;

                try {
                        //org.odx - the java package name that contain schema 
derived
classes
                        jc = JAXBContext.newInstance("*.server.xml.gen");
                        unmarsh = jc.createUnmarshaller();

                        //validate xml:
                        Schema xmlSchema;
                        SchemaFactory sf =
SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );
                        xmlSchema = sf.newSchema(new File("schema/xml.xsd"));
                        unmarsh.setSchema(xmlSchema);
                        ByteArrayInputStream input = new ByteArrayInputStream
(xmlString.getBytes());

                        @SuppressWarnings("unchecked")
                        JAXBElement<XmlType> doc =
(JAXBElement<XmlType>)unmarsh.unmarshal(input);
                        xmlType = doc.getValue();
                } catch (SAXParseException e) {
                        e.printStackTrace();
                } catch (JAXBException e) {
                        e.printStackTrace();
                } catch (Exception e) {
                        e.printStackTrace();
                }

                return xmlType;

On 23 Dez., 18:54, crllvnc <[email protected]> wrote:
> I've been using JAXB for xml file unmarshalling in an upload servlet.
> As far as I remember, the only size limit I have faced is related to
> the 30s timeout.
>
> Here are my imports :
> import javax.xml.bind.JAXBContext;
> import javax.xml.bind.JAXBElement;
> import javax.xml.bind.JAXBException;
> import javax.xml.bind.UnmarshalException;
> import javax.xml.bind.Unmarshaller;
>
> Maybe switching from JAXB2 to JAXB would solve (part of) your
> problems.
> Moreover, JAXB does not require any jar.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to