JAXB Unmarshaller/Marshaller operation differences.

I am using jaxb-ra-2.1.8 and am trying to write a simple program to read xml marshall it to a file then immediately read it back in using the following:
import java.io.File;
import java.io.IOException;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import org.xml.sax.SAXException;
import com.namespace.test.base.Root;
import com.namespace.test.extension.Extension;
public class XmlJaxStuffWeb implements ValidationEventHandler{
     public static void main(String[] args) throws JAXBException, ParserConfigurationException, SAXException, IOException{
          JAXBContext jaxbContext = JAXBContext.newInstance("com.namespace.test.abstracttype:com.namespace.test.base");
          StreamSource[] streams = new StreamSource[3];
          streams[0] = new StreamSource(new File("C:/development/libraries/jaxb-ri-2.1.8/bin/abstract/Extension.xsd"));
          streams[1] = new StreamSource(new File("C:/development/libraries/jaxb-ri-2.1.8/bin/abstract/Base.xsd"));
          streams[2] = new StreamSource(new File("C:/development/libraries/jaxb-ri-2.1.8/bin/abstract/AbstractType.xsd"));
          Schema s = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(streams);
          //javax.xml.validation.Validator v = s.newValidator();
          writeXml(jaxbContext, s);
          readXml(jaxbContext, s);
          //System.out.println
          //System.out.println(jaxbContext.toString());
          //jaxbContext.createValidator();
     public static void readXml(JAXBContext jaxbContext, Schema s) throws JAXBException, SAXException, IOException{
          Unmarshaller un = jaxbContext.createUnmarshaller();
          un.setSchema(s);
          un.setEventHandler(new XmlJaxStuffWeb());
          //un.setValidating(true);
          Object obj = un.unmarshal(new File("c:/test.xml"));
          System.out.println(obj.getClass());
     public static void writeXml(JAXBContext jaxbContext, Schema s) throws JAXBException, SAXException, IOException{
          Root r = new Root();
          r.setHolder("Holder");
          Extension e = new Extension();
          e.setExtendedString("BLAH");
          e.setText("blah");
          com.namespace.test.extension.ObjectFactory f = new com.namespace.test.extension.ObjectFactory();
          r.setAbstractElement(f.createExtension(e));
          //StringWriter b = new StringWriter();
          Marshaller marshaller = jaxbContext.createMarshaller();
          marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
          marshaller.setSchema(s);
          marshaller.setEventHandler(new XmlJaxStuff());
          marshaller.marshal( r, new File("c:/test.xml") );
          //System.out.println(b);
     /* (non-Javadoc)
      * @see javax.xml.bind.ValidationEventHandler#handleEvent(javax.xml.bind.ValidationEvent)
     public boolean handleEvent(ValidationEvent arg0) {
          System.out.println(arg0.getMessage());
          //ValidationEventLocator l = arg0.getLocator();
          return false;
}The write is performed without issue, but the read bombs saying an expected element is missing, which makes no sense since I do validation before marshalling and unmarshalling. It looks like the Unmarshaller is searching the JAXBContext (i.e. not reading the @XmlSeeAlso annotation) differently than the Marshaller because if I put the other package in the JAXBContext it works fine for both reads and writes. Is this expected or is there a bug that exists that causes this behavior?
It may also be worth noting that I do not get an error if I don't specify a custom eventhandler.
Edited by: JaM2003 on Oct 14, 2008 2:00 PM

Hi Jason,
Below is the sample.....You can use this..
JAXBElement<Task> root = null;
          try {
               ByteArrayInputStream input = new ByteArrayInputStream(
                         xmlStr.getBytes());
               JAXBContext jc = JAXBContext.newInstance(Task.class);
               Unmarshaller u = jc.createUnmarshaller();
               StreamSource sc = new StreamSource(new StringReader(
                         xmlStr.toString()));
               root = u.unmarshal(new StreamSource(input), Task.class);
          } catch (Exception e) {
               e.printStackTrace();
          }

Similar Messages

  • JAXB using marshaller.setProperty to specify xalan

    Hi All,
    I'm developing an application using JAXB 1.0.4. I'm able to successfully generate xml from the JAXB compiled classes. My root element should look like
    <EzAp:Invoice xmlns:EzAp="http://siemens.com/einvoice" xmlns:xalan="http://xml.apache.org/xslt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://siemens.com/einvoice file:///C:/einvoice/xml/EzAp.xsd">.
    I'm not being able to specify the xalan namespace. Please let me know if I can do that through the marshaller.setProperty or any other work around.
    Thanks for the help
    Mahesh

    hai,
    i seen u r post.i am having problem with unmarshalling program.with your post i know u can definately solve my problem.because i am having problem in generating xml docemnt from the unmarshall program.pleae help me in thi regard.
    i wrote a sample xml file .and it's xml schema.i used this xml schma to jaxb compiler to generate the classes.it has generated the classes.
    then i wrote unmarshall program as follows
    public class indextestUnmarshal {
    public static void main(String args[]){
    try
         System.out.println("starting........");
         javax.xml.bind.JAXBContext jc= JAXBContext.newInstance("com.search");
         System.out.println("JAXB Instance.....");
         Unmarshaller unmarshaller = jc.createUnmarshaller();     
         System.out.println("calling unmarshal method.....");
         Searchblox coll = (Searchblox)unmarshaller.unmarshal(new File("search.xml"));
         System.out.println("searchblox...........");
    catch(JAXBException e)
         e.printStackTrace();
    program is unable to print the 4th stmt i.e searchblox.it's giving error as follows
    starting........
    JAXB Instance.....
    calling unmarshal method.....
    javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"searchblox"). Expected elements are (unknown)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:523)
         at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:199)
         at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:194)
         at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:71)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:920)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:364)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:345)
         at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:117)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:200)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:142)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:151)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:169)
         at indextestUnmarshal.main(indextestUnmarshal.java:39)
    please help me in this regard as soosn as possible
    Thanks in Advance
    -Rregards
    Rama

  • JAXB unmarshaller error in JAX-WS web service

    Hi,
    We have a JAX-WS web service deployed to WLS 10.3.3.0 as an EAR file. The EAR file deploys without any problems, but the first time we attempt to call an operation we get a classloading problem when we run the following code snippet (I've put a comment after the failed line of code):
              Object jaxbObject = null;
              Unmarshaller unmarshaller = null;          
              try {
                   unmarshaller = JAXB_CTX.createUnmarshaller(); // JAXB_CTX is an instance of JAXBContext
                   jaxbObject = unmarshaller.unmarshal(new ByteArrayInputStream(xmlString.getBytes())); // this line fails
              } catch (JAXBException e) {
    If we update the EAR file or delete and re-install the EAR file in the WLS console then the problem doesn't go away, but if we restart the WL server that hosts the EAR file then the problem is resolved. The problem is consistently repeatable.
    The stacktrace for the error is:
    java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration
         at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
         at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
         at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
         at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
         at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.createDocument(SAX2DOM.java:326)
         at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.<init>(SAX2DOM.java:85)
         at com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler(TransletOutputHandlerFactory.java:187)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:392)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.setResult(TransformerHandlerImpl.java:137)
         at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader$State.<init>(DomLoader.java:74)
         at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader.startElement(DomLoader.java:113)
         at com.sun.xml.bind.v2.runtime.unmarshaller.ProxyLoader.startElement(ProxyLoader.java:56)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:456)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:433)
         at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:138)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184)
         at com.northernrock.applicationdataservice.interaction.util.ServiceSoapPortUtil.generateJAXBObjectFromXML(ServiceSoapPortUtil.java:184)
         at com.northernrock.applicationdataservice.interaction.util.DataMapper.mapFullApplication(DataMapper.java:130)
         at com.northernrock.applicationdataservice.interaction.ServiceSoapPort.retrieveFullApplicationData(ServiceSoapPort.java:148)
         at com.northernrock.applicationdataservice.interaction.ServiceSoapPortImpl.retrieveFullApplicationData(ServiceSoapPortImpl.java:69)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
         at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
         at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
         at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:265)
         at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:604)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:563)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:548)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:445)
         at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:373)
         at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:524)
         at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:255)
         at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:141)
         at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:210)
         at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:311)
         at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:223)
         at weblogic.wsee.jaxws.JAXWSServlet.doPost(JAXWSServlet.java:124)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
         at weblogic.wsee.jaxws.JAXWSServlet.service(JAXWSServlet.java:79)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3686)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    There seems to be something strange going on with the classloading, such that re-deploying the application causes the wrong Xerces parser classes to be loaded until the WL server is restarted. Once the restart is done then there is no problem until the next re-deployment.
    Does anyone know a fix for this issue?
    Any help is appreciated.
    Thanks,
    Jason

    Hi Jason,
    Below is the sample.....You can use this..
    JAXBElement<Task> root = null;
              try {
                   ByteArrayInputStream input = new ByteArrayInputStream(
                             xmlStr.getBytes());
                   JAXBContext jc = JAXBContext.newInstance(Task.class);
                   Unmarshaller u = jc.createUnmarshaller();
                   StreamSource sc = new StreamSource(new StringReader(
                             xmlStr.toString()));
                   root = u.unmarshal(new StreamSource(input), Task.class);
              } catch (Exception e) {
                   e.printStackTrace();
              }

  • JAXB Unmarshaller and errors to system.out

    Hi!
    I'm using JAXB in a complex XML binding project. The question is: is there a way to prevent javax.xml.bind.Unmarshaller to send to system.out the warnings/errors messages as DefaultValidationEventHandler: [ERROR]: bla bla bla
    which are sent immediately before to throw an UnmarshalException??
    Thanks so much!!

    Have you tried using System.setErr() and System.setOut() ? With these calls at the start of your application, you should be able to redirect the error to a file or whatever you want.

  • Problem with JAXB Unmarshaller

    This exception ocurred in production environment. Notice that always it happens in SAXUnmarshallerHandlerImpl.getCurrentHandler method but not always in the same package and sometimes it occurs and sometimes doesn�t. In test environment it never happens. Could it be a memory problem? I write some examples:
    java.lang.ArrayIndexOutOfBoundsException: -1
    at es.indra.bizlogic.jaxb.air.output.impl.runtime.SAXUnmarshallerHandlerImpl.getCurrentHandler(Unknown Source)
    at es.indra.bizlogic.jaxb.air.output.impl.runtime.SAXUnmarshallerHandlerImpl.endElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    java.lang.ArrayIndexOutOfBoundsException: -1
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.SAXUnmarshallerHandlerImpl.getCurrentHandler(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.SAXUnmarshallerHandlerImpl.popContentHandler(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.AbstractUnmarshallingEventHandlerImpl.revertToParentFromEnterElement(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.EDATEImpl$Unmarshaller.enterElement(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.SAXUnmarshallerHandlerImpl.startElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    java.lang.ArrayIndexOutOfBoundsException: -1
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.SAXUnmarshallerHandlerImpl.getCurrentHandler(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.SAXUnmarshallerHandlerImpl.endElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    java.lang.ArrayIndexOutOfBoundsException: -1
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.SAXUnmarshallerHandlerImpl.getCurrentHandler(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.SAXUnmarshallerHandlerImpl.popContentHandler(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.AbstractUnmarshallingEventHandlerImpl.revertToParentFromEnterElement(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.CODEImpl$Unmarshaller.enterElement(Unknown Source)
    at es.indra.bizlogic.jaxb.fare.output.impl.runtime.SAXUnmarshallerHandlerImpl.startElement(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    Message was edited by:
    Ana_Indra_Madrid

    I had the same problem! The answer is to include '.' in your CLASSPATH. A dot like this means the current directory. The compiler won't find all the package files in the current directory unless its path is explicitly set in CLASSPATH. Seems strange as you might expect a compiler at least to try looking for files wherever you currently are, but it's not the case. So, my CLASSPATH declaration is as follows, starting with '.;' and then continuing with all the required jar files:
    .;c:\jwsdp-1.3\jaxb\lib\jaxb-api.jar;c:\jwsdp-1.3\jaxb\lib\jaxb-xjc.jar;c:\jwsdp-1.3\jaxb\lib\jaxb-impl.jar;c:\jwsdp-1.3\jaxb\lib\jaxb-libs.jar;c:\jwsdp-1.3\jaxp\lib\jaxp-api.jar;c:\jwsdp-1.3\jaxp\lib\endorsed\sax.jar;c:\jwsdp-1.3\jaxp\lib\endorsed\dom.jar;c:\jwsdp-1.3\jaxp\lib\endorsed\xercesImpl.jar;c:\jwsdp-1.3\jaxp\lib\endorsed\xalan.jar;c:\jwsdp-1.3\jwsdp-shared\lib\jax-qname.jar;c:\jwsdp-1.3\jwsdp-shared\lib\namespace.jar;c:\jwsdp-1.3\jwsdp-shared\lib\xsdlib.jar;c:\jwsdp-1.3\jwsdp-shared\lib\relaxngDatatype.jar

  • JAXB Flags an Error in XML Doc Related to a Choice of Elements

    With a fairly complex DTD, an error results when JAXB unmarshalls a valid XML document. Here is the relevant DTD fragment:
    <!ELEMENT Declaration (Variable+, (typeList | Drelation))>
    The elements Variable and Drelation are complex, and contain other elements. Element typeList contains only #PCDATA. If Varaible is followed by Drelation, everything is fine, but if Variable is follwed by typeList, then unmarshall reports the following error:
    Exception in thread "main" javax.xml.bind.UnrecognizedElementNameException: typeList
    I know there is not a real error, because I have validated the XML document against the DTD using Xeena, from IBM's Alphaworks.

    By way of additional information, I tried to circumvent the problem with the following change.
    <!ELEMENT Declaration (Variable+, DecType)>
    <!ATTLIST Declaration dpower (PowerSet) #IMPLIED>
    <!ELEMENT DecType (typeList | Drelation)>
    Now, each element is either a sequence or a choice, but not both. The result was the same problem. The unmarshall reports the same error when it gets to the DecType element, saying the typeList element is unexpected. Again, IBM's Xeena tool reports that the XML document is valid for the DTD.
    Here is the relevant XML fragment.
    <Declaration dpower="PowerSet">
    <Variable> members </Variable>
    <DecType> <typeList> Person </typeList> </DecType>
    </Declaration>
    Is this a JAXB error?

  • JAXB XML Unmarshalling validation problem

    Hello,
    I'm using toplink JAXB to map XML document to an object hierarchy. The set of objects was built using Toplink workbench from the corresponding XSD file. The XSD file is specified in <toplink:resource> element using an absolute path. If I use unmarshaller validation (Unmarshaller u = jc.createUnmarshaller(); u.setValidating(true)) it works fine in embedded oc4j, but fails withan UnmarshalException "An internal error condition occurred" for Line N 1.
    It looks like the cause of the exception is that toplink cannot find the XSD file. I've tried to put the XSD file into META-INF and into classes directly, and specify the relative path, but it has failed event locally in the embedded oc4j.
    Everything works if I do not turn the validation on.
    Has anybody gotten the same issue? What could be a solution if we have to perform the validation?
    Thanks
    Kate

    Hello Kate,
    One possible work around would be use the TopLink OXM specific APIs for this unmarshal. For the most part they mirror the JAXB APIs so there usage is pretty straight forward.
    XMLContext xmlContext = new XMLContext(YOUR_JAXB_CONTEXT_PATH);
    xmlUnmarshaller = xmlContext.createUnmarshaller();One API that we offer that is not part of the standard JAXB Unmarshaller is the ability to specify an EntityResolver. This class allows you to override where the XML Schema is loaded from.
    EntityResolver entityResolver = new YourEntityResolver();
    xmlUmarshaller.setEntityResolver(entityResolver);YourEntityResolver must implement org.xml.sax.EntityResolver. There is one method on this interface that returns an InputSource representing the XML Schema. You can implement this method to load the Schema from a ClassLoader.
    -Blaise

  • JAXB marshalling complexType elements

    Does anyone know why JAXB always marshalls complexType elements with a seperate start and end tag, even if the element has no content?
    i.e.
    Given the schema element declaration:
    <xs:element name="foo" type="fooType"/>
    <xs:complexType name="fooType">
    <xs:attribute name="value" type="xs:string" use="required"/>
    </xs:complexType>
    Why do I get:
    <foo value="bar"></foo>
    Instead of:
    <foo value="bar"/>
    Is their a setting / property to control this behaviour?
    If not then I certainly think there should be because this will bloat the 5Mb XML files I am currently dealing with by quite a lot.
    Cheers,
    Simon

    I have exactly the same trouble here. Did you find a solution? If so, please contact me. I am so afraid of increase the amount space used to store all XML files.
    Thanks in advance
    Julio Garc�a
    [email protected]

  • JAXB unmarshalling error

    We are getting a JAXB unmarshalling error:
    while processing the following <condition> tag which is of type xsd:string
    <condition> x < 100 </condition>
    The error is probably happening due to "<" token as a part of string type.
    xml.bind.JAXBException: Unexpected error in Unmarshalling
    at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
    Any ideas how to resolve this issue?
    Note
    <condition> x >100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
    Thanks

    Hi,
    Did you tried to put & lt; (without space) instead of < ?
    Best Regards,
    Paweł

  • JAXB unmarshalling error for " " token as part of xsd:string type element

    JAXB unmarshalling error for "<" token as part of xsd:string type element
    We are getting a JAXB unmarshalling error:
    while processing the following <condition> tag which is of type xsd:string
    <condition> x < 100 </condition>
    The error is probably happening due to "<" token as a part of string type.
    xml.bind.JAXBException: Unexpected error in Unmarshalling
    at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
    Any ideas how to resolve this issue?
    Note
    <condition> x > 100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
    Thanks

    Hi,
    Did you tried to put & lt; (without space) instead of < ?
    Best Regards,
    Paweł

  • Different Terminal operation methods

    I'm writing a report on my blog on some Terminal operations I performed recently to rescue a drive that was locked and with corrupt ACL. I want to get some things straight in my mind before I spread errouneous info.
    When using a command like:
    sudo cd /Volumes/Media
    sudo find . -flags uchg -exec chflags nouchg {} \;
    Which as I understand it will find all locked files on /Volumes/Media and unlock them
    or using a command like:
    sudo chflags -R nouchg /Volumes/Media
    Which as I understand it will unlock ALL files recursively from the given directory, which effectively does the same thing as above.
    What is the functional or operational difference between those two methods? Is there a safer or more preferable method?
    Also, what is the difference between find . and find /
    The Apple Discussions have been greatly helpful the past few weeks as I've learned more and more about how to get things done in Terminal. Thanks to all who share their knowledge here. I want to make sure I understand things fully before I make incorrect assumptions.
    cheers
    Adam

    As as been explained above the
    sudo cd ...
    command is useless.  Frank Caggiano has explained why the sudo cd does not work as you think, but if you do not understand what he said, you need to come back and ask, as the concept of what happens iin a subprocess stays in a subprocess.  Things like your current working directory and shell variable and environment variable changes in a subprocess do not affect the originating shell (namely the one issuing the command prompt).  If you do not understant this, you will get tripped up again and again in the shell.
    I'm assuming you have access to /Volume/Media, you cd without the sudo.  If for some reason you cannot cd to /Volume/Media, then you will need to take a totally different approach.
    etresoft has mentioned that the 'find' approach will only modify the files that are locked, where as the chflags -R approach will blindly modify every file.  On the surface this may not appear to affect the end result, but the chflags -R approach will also change the ctime (Change Time) of every file, where as the 'find' approach will only change the ctime for the files that need changing.
    The change to ctime may cause an incremental backup utility to backup every file in /Volume/Media instead of just the few files that have had their flags changed.
    Also, what is the difference between find . and find /
    . in Unix file systems is the current directory.  .. is the parent directory ../../ is the grandparent directory, etc...
    / is the top level of the boot file system.  From here every other file accessible via the operating system is somewhere under /
    As has been explained, both . and / can be dangerous.  . is dangerous if you are not where you think you are, such as the case of using sudo cd no actually placing you where you think are going.  / is dangerous as depending on what you are doing with the 'find' command you can make some non-reversable file system modifications.
    When playing with 'find' you might want to NOT include -exec until you absolutely know that the 'find' command you are creating spits out exactly what files you need to modify.  Or if you want to test with -exec, then use echo first
    find . -flags uchg -exec echo chflags nouchg {} \;
    where the echo command will display the chflags command that you plan to exeucte, but will not actually change anything.  You can then verify that the commands look good and the files being changed are what you expect.  You can later either remove the 'echo' or just pipe the command into sh
    cd /Volumes/Media
    find . -flags uchg -exec echo chflags nouchg {} \; | sudo sh

  • JAXB UnmarshalException - Filename w/ # or ? or %

    I have a requirement to allow file names with a set of non alpha numeric characters (except /). All of them seem to do fine except for filenames with the characters # or ? or % when it comes time to unmarshal the xml file. The error displayed below is for a file with the name: 2#2.txt.xml
    I have traced through my code and the file path and full name remain intact and the file is verified as being on the system. When I get to the call below in the code, the application throws the JAXB Exception shown below:      
    // Unmarshall the data in the file
         object = getUnmarshalledObject( unmarshaller.unmarshal( file ) );
    I am using JAXB 2.0
    Is there a way to get the JAXB Unmarshaller to recognize these special characters?
    I receive the JAXB Exception:
    javax.xml.bind.UnmarshalException
    - with linked exception:
    [java.io.FileNotFoundException: \var\data\EMU1.EMUApplication\.metadata\2 (The system cannot find the file specified.)]
         at javax.xml.bind.UnmarshalException.<init>(UnmarshalException.java:56)
    Complete Method:
         JAXBContext jaxbContext;
         Unmarshaller unmarshaller;
         Object object;
         // Make sure the file exists, is a file and is readable
         if ( ! file.exists() ) throw new OnsConfigException("Missing document file " + file.getAbsolutePath() );
         if ( ! file.canRead() ) throw new OnsConfigException("Non readable document file " + file.getAbsolutePath() );
         if ( file.isDirectory() ) throw new OnsConfigException("Cannot unmarshall directory " + file.getAbsolutePath() );
         try {
         // Create the context
         jaxbContext = JAXBContext.newInstance( packageName );
         // Create the unmarshaller
         unmarshaller = jaxbContext.createUnmarshaller();
         // Enable/disable validation
         unmarshaller.setSchema( schema );
         // Unmarshall the data in the file
         object = getUnmarshalledObject( unmarshaller.unmarshal( file ) );
         } catch (JAXBException jaxbExc) {
         // Rethrow as ONS exception
         jaxbExc.printStackTrace();
         throw new OnsConfigException( "XML Parse File Error", jaxbExc );
         } catch (Throwable e) {
         // Rethrow as ONS exception
         e.printStackTrace();
         throw new OnsConfigException( "XML Unmarshal File System Error", e );      
         }Thank you for your assistance.
    Edited by: Barbara5 on May 7, 2009 11:10 PM

    I suspect that something, somewhere, is treating those file names as if they were components of a URL. I say that because the characters you named in your post title all have special meanings in a URL.
    So you might have to URL-escape your file name, or there might be some other special thing you have to do. I don't know anything specifically about JAXB or about your application, but that's what I would investigate.

  • Running JAXB2 in a 10g Database

    Hi All,
    We have some java business logic which uses JAXB2. We now would like to be able to call / store this java code inside the database. It's a 10g database, which I understand has the 1.4 JVM, so I've retrotranslated the code (and the JAXB2 dependencies) and created a compatible jar. The loadjava command^1^ completes successfully, however when I try and execute the code which unmarshals the XML, I get the following error: Caused by: java.lang.RuntimeException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory not found
    The ContextFactory is definitely in the jar file. Looking through the generated DB trace file I see the following:
    creating : class com/sun/xml/bind/v2/ContextFactory with resolver ((* london) (* PUBLIC) (org/apache/* -) (jp/gr/xml/relax/* -) (com/bea/* -) (javax/management/* -) (com/thoughtworks/xstream/* -) (org/jvnet/* -) (com/sun/xml/fastinfoset/* -) (sun/misc/* -))
    but then, instead of resolving the class:
    skipping : class com/sun/xml/bind/v2/ContextFactory
    Why would the ContextFactory be skipped? Is there any way I can force the loadjava command to resolve it?
    1. The server-side loadJava command I use is: call sys.dbms_java.loadjava( '-force -verbose -resolve /scripts/p3/db_sql/cta23001.jar','((* london) (* PUBLIC) (org/apache/* -) (jp/gr/xml/relax/* -) (com/bea/* -) (javax/management/* -) (com/thoughtworks/xstream/* -) (org/jvnet/* -) (com/sun/xml/fastinfoset/* -) (sun/misc/* -))' );

    Hi:
    You can find Jaxb related classes implemented by Oracle into ${ORACLE_HOME}/lib/xml.jar but not all classes should be installed, please look at Ant task named unpack-jaxb-classes at:
    [http://dbprism.cvs.sourceforge.net/viewvc/dbprism/cms-2.1/tasks/cms.xml?revision=1.19&view=markup]
    this Ant task extract all Jaxb required classes which can be installed into an Oracle 10g/11g database, see the Task pre-install which install this jar into SYS's schema.
    To see how to use Jaxb marshall/unmarshall operation please take a look at the method processRequestAction, inside the code you can see how to instantiate the marshaller and unmarshaller:
    [http://dbprism.cvs.sourceforge.net/viewvc/dbprism/cms-2.1/src/com/prism/cms/action/Controller.java?revision=1.8&view=markup]
    Best regards, Marcelo.

  • Regarding RFC Communication from SAP R/3 to SAP J2EE Engine 6.40

    Hello,
         We have an application deployed in SAP J2EE engine 6.20. From SAP R3 (SAP R/3 version is 6.4C), We are communicating to the application deployed in SAP J2EE Engine 6.20 using RFC protocol. EJB module (Deployed in SAP J2EE Engine 6.20) which is being invoked from a Function Module using RFC protocol has the same name as the Function Module name. We were able to communicate to SAP J2EE Engine 6.20 this way.
         Currently, I have deployed the same application in SAP J2EE Engine 6.40.  I have followed the same procedure which i have used while depolying and working with SAP J2EE Engine 6.20. But, it is not working, and i was not able to communicate to SAP J2EE 6.40, the same way i did in SAP J2EE Engine 6.20. 
       Please let me know whether the procedure for communicating to SAP J2EE Engine 6.40 has changed in comparison with SAP J2EE Engine 6.20.
    Also,Any pointers regarding RFC and JCO implementation in SAP J2EE Engine 6.40 willl be helpful.
    Thank you.
    Regards,
    -Shabir Rahim.

    Hello ,
          The Connection in sm59 is established successfully> there were no Error thorwn in SAP when testing the connnection. But when i am making background call using a Function Module in SAP R3, the calls reaches Application deployed in SAP J2EE Engine 6.40, But it is failing with the error as,
    #1.5#005056A24413003C000000240000126000042853BD899290#1170240034258#/System/Server##com.sap.engine.services.dsr####sstra902_IPC_2629150#Guest#6813e650a93f11dba9f5005056a24413#Thread[JCO.ServerThread-1,10,SAPEngine_System_Thread[impl:5]_Group]##0#0#Error#1#/System/Server#Plain####
    #1.5#005056A244130042000000000000126000042853CFDB80F8#1170240341655#/System/Server##com.sap.engine.services.dsr#Guest#2####322aaa71b11811db85e1005056a24413#SAPEngine_Application_Thread[impl:3]_36##0#0#Error#1#com.sap.engine.services.dsr#Java#DSR_36#com.sap.engine.services.dsr.res.DSRResourceBundle#Error while taking over external passport null#1#null#
    #1.5#005056A244130042000000030000126000042853CFDB86BD#1170240341671#/System/Server##com.sap.engine.services.jndi#Guest#2####322aaa71b11811db85e1005056a24413#SAPEngine_Application_Thread[impl:3]_36##0#0#Info#1#com.sap.engine.services.jndi#Plain###Incorrect name parameter rfcaccessejb//DCEUR/Z_AIS_IPC_CFG_PRICE in naming operation.#
    #1.5#005056A244130042000000040000126000042853CFDB8745#1170240341671#/System/Server##com.sap.engine.services.jndi#Guest#2####322aaa71b11811db85e1005056a24413#SAPEngine_Application_Thread[impl:3]_36##0#0#Info#1#com.sap.engine.services.jndi#Plain###Incorrect name parameter java:rfcaccessejb//DCEUR/Z_AIS_IPC_CFG_PRICE in naming operation.#
    #1.5#005056A24413003C000000280000126000042853CFDBC4AA#1170240341686#/System/Server##com.sap.engine.services.dsr####sstra902_IPC_2629150#Guest#6813e650a93f11dba9f5005056a24413#Thread[JCO.ServerThread-1,10,SAPEngine_System_Thread[impl:5]_Group]##0#0#Error#1#/System/Server#Plain####
    Here, //DCEUR/Z_AIS_IPC_CFG_PRICE is the Funcrtion module name in SAP R/3 6.4C.
    Also Please let me know whether is there any Operating Differences between WAS 6.20 and WAS 6.40, for JCO/RFC based Communication( ie Comunicating with WAS 6.40 from SAP r/3 using RFC Protocol). Any materials and Information on how to work on SAP J2EE Engine 6.4 will also be very helpful.
    Thank you.

  • Exported Raw Conversion Image Resolution and Assigning a Color Profile, etc

    In Aperture 1.1, although I set the exported Raw conversion image resolution to 300 dpi in the preferences, it continues to come out at 72 dpi which is something of an inconvenience. Also, is it possible to assign a color profile to the "exported version" so that it is congruent to my PS CS2 color workspace (if that is what its called). Is this program capable of carrying out a conversion as a background operation? Finally, can the layout windows be configured so that they remember how they have been used in the past? Thanks.

    Iatrogenic huh! Cool!
    Anyway, I'm not real clear on what it is you are trying to accomplish. Despite your obvious vocabulary skills, there seems to be some disconnect relative to what you are trying to accomplish. You are right that "exporting a version" in Aperture is roughly equivalent to what happens in ACR when you "Open" a RAW image into Photoshop. In both cases you have, hopefully, already done the adjusting of parameters you want prior to "exporting", or "opening". When you "open" or "export" you wind up with an "image" composed of pixels, whereas in the RAW adjustment phase you are just working with a temporary thumbnail and a set of mathematical instructions. Big difference, I suppose is that when you "open" and image from ACR into CS2, the resulting image is truly just pixels and has not had a "file type" applied to the file yet, until you "save" it, while in Aperture, if you "export" a file to CS2, or to the desktop, you end up with the file type already applied. Presuming you "export" a 16 bit TIFF or PSD, there is no operational difference.
    I could be wrong, but with the new Bayer Demosaicing algorithms in Aperture 1.1, and the Camera RAW adjustments, you should be able to come up with an adjusted image that is VERY close if not identical to one done in ACR, with the possible exception of lens abberation adjustment. I was very critical of the RAW adjustments in 1.0.1, but I am very happy with the capabilites in 1.1. That said, I think there is still some room for improvement in user friendliness of some of the adjustments such as Levels.

Maybe you are looking for

  • Budget consumption figures BAPI or Function Module

    Hi FM experts, I'm looking for a BAPI or a Function Module that will return the available and consumed budget if I provide it with a fund center and a commitment item. Any one knows of such a BAPI? Thanks. Ed.

  • Lost iphone 6 : text stating "Your iPhone has been located."

    So I lost my phone 6+ a couple days ago, and immediately turned on find my iPhone and put it in lost mode with my roommates contact number. I received a few notifications via email that a location had been identified. There were 2 different locations

  • Bug Adobe Air 3.5 Beta with method "drawViewPortToBitmapData"

    Hello, I noticed there is a bug with the lastest build of Air 3.5 beta with the method "drawViewPortToBitmapData". It resizes the viewport that we want to draw smaller that the original size. Can you correct this bug before the release ? Thanks, Loïc

  • Raw and vista  loading problem

    I have loaded the trial version of cs 2 on my laaptop with vista ultimate, downloded all the latest updates for cs2, bridge, and raw place the raw plugin in the program/commonfiles/adobe/plugins/cs2/fileformats and sti;ll I cannot see any raw images

  • Giving input to running EXE & getting output from it

    Hi there, I want to invoke an EXE file using runtime.exec() & also want to give some input to it when it's in running state & also want to trace the output of that EXE. I tried it using PipedStream but failed to do this, please suggest something. Tha