Wierd exception in JAXB deserialization

View: New views
4 Messages — Rating Filter:   Alert me  

Wierd exception in JAXB deserialization

by Avinash Lakshman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Could someone please give me some pointers as to where I should start looking when I attempt tracking this one?

We are reading some bytes from a TCP socket and submitting these bytes to be deserialized on a separate thread in a dedicated thread pool. Every once in a while I see this wierd exception.
java.io.IOException: Illegal state for UTF-8 encoded string
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringIllegalState(Decoder.java:1780)
at com.sun.xml.fastinfoset.Decoder.decodeTwoToFourByteUtf8Character(Decoder.java:1532)
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringIntoCharBuffer(Decoder.java:1471)
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringAsCharBuffer(Decoder.java:1392)
at com.sun.xml.fastinfoset.stax.StAXDocumentParser.processUtf8CharacterString(StAXDocumentParser.java:488)
at com.sun.xml.fastinfoset.stax.StAXDocumentParser.next(StAXDocumentParser.java:323)
at com.sun.xml.bind.v2.runtime.unmarshaller.FastInfosetConnector.bridge(FastInfosetConnector.java:130)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
at com.firm.infrastructure.net.io.BinarySerializer.deserialize(BinarySerializer.java:177)
at com.firm.infrastructure.net.MessageDeserializationTask.run(MessageDeserializationTask.java:36)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:675)

Here is how I implement the serialization/deserialization:

public byte[] serialize(Object message) throws IOException
    { 
        byte[] bytes = new byte[0];
        long startTime = System.currentTimeMillis();
       
        if ( message != null )
        {
            try
            { 
                JAXBContext context =  SerializationManager.getContext();                      
                Marshaller m = context.createMarshaller();                
                FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
                StAXDocumentSerializer sw = new StAXDocumentSerializer();
                sw.setOutputStream(bos);
                m.marshal(message, (XMLStreamWriter)sw);               
                bytes = bos.toByteArray();               
            }
            catch ( JAXBException ex )
            {
                SerializationManager.handleJAXBException(ex, message);           
            }
        }
        logger_.info("JAXB serialize: " + (System.currentTimeMillis() - startTime) + " ms.");
        return bytes;
    }

    public Object deserialize(byte[] bytes) throws IOException
    {
        Object message = null;       
        long startTime = System.currentTimeMillis();
        try
        {              
            JAXBContext context = SerializationManager.getContext();                        
            Unmarshaller um = context.createUnmarshaller();            
            FastByteArrayInputStream bis = new FastByteArrayInputStream(bytes);
            XMLStreamReader xr = new StAXDocumentParser(bis);           
            message = um.unmarshal(xr);           
        }
        catch ( JAXBException ex )
        {           
            SerializationManager.handleJAXBException(ex);           
        }
        logger_.info("JAXB deserialize: " + (System.currentTimeMillis() - startTime) + " ms.");
        return message;
    }

What would cause this? Please advice.

Thanks
A


Connect and share in new ways with Windows Live. Get it now!

Re: Wierd exception in JAXB deserialization

by Oleksiy Stashok :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

can you pls. attach byte[] dump, result of serialize method call?

Thanks.

WBR,
Alexey.

On Feb 29, 2008, at 0:03 , Avinash Lakshman wrote:

Could someone please give me some pointers as to where I should start looking when I attempt tracking this one?

We are reading some bytes from a TCP socket and submitting these bytes to be deserialized on a separate thread in a dedicated thread pool. Every once in a while I see this wierd exception.
java.io.IOException: Illegal state for UTF-8 encoded string
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringIllegalState(Decoder.java:1780)
at com.sun.xml.fastinfoset.Decoder.decodeTwoToFourByteUtf8Character(Decoder.java:1532)
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringIntoCharBuffer(Decoder.java:1471)
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringAsCharBuffer(Decoder.java:1392)
at com.sun.xml.fastinfoset.stax.StAXDocumentParser.processUtf8CharacterString(StAXDocumentParser.java:488)
at com.sun.xml.fastinfoset.stax.StAXDocumentParser.next(StAXDocumentParser.java:323)
at com.sun.xml.bind.v2.runtime.unmarshaller.FastInfosetConnector.bridge(FastInfosetConnector.java:130)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
at com.firm.infrastructure.net.io.BinarySerializer.deserialize(BinarySerializer.java:177)
at com.firm.infrastructure.net.MessageDeserializationTask.run(MessageDeserializationTask.java:36)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:675)

Here is how I implement the serialization/deserialization:

public byte[] serialize(Object message) throws IOException
    {  
        byte[] bytes = new byte[0];
        long startTime = System.currentTimeMillis();
        
        if ( message != null )
        {
            try
            {  
                JAXBContext context =  SerializationManager.getContext();                       
                Marshaller m = context.createMarshaller();                 
                FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
                StAXDocumentSerializer sw = new StAXDocumentSerializer();
                sw.setOutputStream(bos);
                m.marshal(message, (XMLStreamWriter)sw);                
                bytes = bos.toByteArray();                
            }
            catch ( JAXBException ex )
            {
                SerializationManager.handleJAXBException(ex, message);            
            }
        }
        logger_.info("JAXB serialize: " + (System.currentTimeMillis() - startTime) + " ms.");
        return bytes;
    }

    public Object deserialize(byte[] bytes) throws IOException
    {
        Object message = null;        
        long startTime = System.currentTimeMillis();
        try
        {               
            JAXBContext context = SerializationManager.getContext();                         
            Unmarshaller um = context.createUnmarshaller();             
            FastByteArrayInputStream bis = new FastByteArrayInputStream(bytes);
            XMLStreamReader xr = new StAXDocumentParser(bis);            
            message = um.unmarshal(xr);            
        }
        catch ( JAXBException ex )
        {            
            SerializationManager.handleJAXBException(ex);            
        }
        logger_.info("JAXB deserialize: " + (System.currentTimeMillis() - startTime) + " ms.");
        return message;
    }

What would cause this? Please advice.

Thanks
A 


Connect and share in new ways with Windows Live. Get it now!


if SAXDocumentSerializer support CDATA

by Jia, Quansheng-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi;

 

I use below code snip to convert a JAXB bean to a FI string in my application. I wonder if SAXDocumentSerializer support CDATA. If it supports, can you provide an example?

 

 

          ByteArrayOutputStream output = new ByteArrayOutputStream();

               SAXResult _result = new SAXResult();

                    SAXDocumentSerializer serializer = new SAXDocumentSerializer();

                    serializer.setOutputStream(output);

                    _result.setHandler(serializer);

                         _result.setLexicalHandler(serializer);

                    m.marshal(newPayload, _result);

 

 

 

Thanks

 

Quansheng Jia


From: Oleksiy.Stashok@... [mailto:Oleksiy.Stashok@...]
Sent: Friday, February 29, 2008 4:54 AM
To: dev@...
Subject: Re: Wierd exception in JAXB deserialization

 

Hello,

 

can you pls. attach byte[] dump, result of serialize method call?

 

Thanks.

 

WBR,

Alexey.

 

On Feb 29, 2008, at 0:03 , Avinash Lakshman wrote:



Could someone please give me some pointers as to where I should start looking when I attempt tracking this one?

We are reading some bytes from a TCP socket and submitting these bytes to be deserialized on a separate thread in a dedicated thread pool. Every once in a while I see this wierd exception.
java.io.IOException: Illegal state for UTF-8 encoded string
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringIllegalState(Decoder.java:1780)
at com.sun.xml.fastinfoset.Decoder.decodeTwoToFourByteUtf8Character(Decoder.java:1532)
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringIntoCharBuffer(Decoder.java:1471)
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringAsCharBuffer(Decoder.java:1392)
at com.sun.xml.fastinfoset.stax.StAXDocumentParser.processUtf8CharacterString(StAXDocumentParser.java:488)
at com.sun.xml.fastinfoset.stax.StAXDocumentParser.next(StAXDocumentParser.java:323)
at com.sun.xml.bind.v2.runtime.unmarshaller.FastInfosetConnector.bridge(FastInfosetConnector.java:130)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
at com.firm.infrastructure.net.io.BinarySerializer.deserialize(BinarySerializer.java:177)
at com.firm.infrastructure.net.MessageDeserializationTask.run(MessageDeserializationTask.java:36)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:675)

Here is how I implement the serialization/deserialization:

public byte[] serialize(Object message) throws IOException
    {  
        byte[] bytes = new byte[0];
        long startTime = System.currentTimeMillis();
        
        if ( message != null )
        {
            try
            {  
                JAXBContext context =  SerializationManager.getContext();                       
                Marshaller m = context.createMarshaller();                 
                FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
                StAXDocumentSerializer sw = new StAXDocumentSerializer();
                sw.setOutputStream(bos);
                m.marshal(message, (XMLStreamWriter)sw);                
                bytes = bos.toByteArray();                
            }
            catch ( JAXBException ex )
            {
                SerializationManager.handleJAXBException(ex, message);            
            }
        }
        logger_.info("JAXB serialize: " + (System.currentTimeMillis() - startTime) + " ms.");
        return bytes;
    }

    public Object deserialize(byte[] bytes) throws IOException
    {
        Object message = null;        
        long startTime = System.currentTimeMillis();
        try
        {               
            JAXBContext context = SerializationManager.getContext();                         
            Unmarshaller um = context.createUnmarshaller();             
            FastByteArrayInputStream bis = new FastByteArrayInputStream(bytes);
            XMLStreamReader xr = new StAXDocumentParser(bis);            
            message = um.unmarshal(xr);            
        }
        catch ( JAXBException ex )
        {            
            SerializationManager.handleJAXBException(ex);            
        }
        logger_.info("JAXB deserialize: " + (System.currentTimeMillis() - startTime) + " ms.");
        return message;
    }

What would cause this? Please advice.

Thanks
A 


Connect and share in new ways with Windows Live. Get it now!

 

______________

The information contained in this message is proprietary and/or confidential. If you are not the
intended recipient, please: (i) delete the message and all copies; (ii) do not disclose,
distribute or use the message in any manner; and (iii) notify the sender immediately. In addition,
please be aware that any message addressed to our domain is subject to archiving and review by
persons other than the intended recipient. Thank you.
_____________

Re: if SAXDocumentSerializer support CDATA

by Oleksiy Stashok :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Quansheng Jia,

I wonder if SAXDocumentSerializer support CDATA.
There is CDATA processing code in SAXDocumentSerializer, so I expect it should work.

If it supports, can you provide an example?
Just wanted to make sure.
Using code snippet bellow, you got some error when processing CDATA?

Thanks.

WBR,
Alexey.

 
 
          ByteArrayOutputStream output = new ByteArrayOutputStream();
               SAXResult _result = new SAXResult();
                    SAXDocumentSerializer serializer = new SAXDocumentSerializer();
                    serializer.setOutputStream(output);
                    _result.setHandler(serializer);
                         _result.setLexicalHandler(serializer);
                    m.marshal(newPayload, _result);
 
 
 
Thanks
 
Quansheng Jia

From: Oleksiy.Stashok@... [Oleksiy.Stashok@...] 
Sent: Friday, February 29, 2008 4:54 AM
To: dev@...
Subject: Re: Wierd exception in JAXB deserialization
 
Hello,
 
can you pls. attach byte[] dump, result of serialize method call?
 
Thanks.
 
WBR,
Alexey.
 
On Feb 29, 2008, at 0:03 , Avinash Lakshman wrote:


Could someone please give me some pointers as to where I should start looking when I attempt tracking this one?

We are reading some bytes from a TCP socket and submitting these bytes to be deserialized on a separate thread in a dedicated thread pool. Every once in a while I see this wierd exception.
java.io.IOException: Illegal state for UTF-8 encoded string
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringIllegalState(Decoder.java:1780)
at com.sun.xml.fastinfoset.Decoder.decodeTwoToFourByteUtf8Character(Decoder.java:1532)
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringIntoCharBuffer(Decoder.java:1471)
at com.sun.xml.fastinfoset.Decoder.decodeUtf8StringAsCharBuffer(Decoder.java:1392)
at com.sun.xml.fastinfoset.stax.StAXDocumentParser.processUtf8CharacterString(StAXDocumentParser.java:488)
at com.sun.xml.fastinfoset.stax.StAXDocumentParser.next(StAXDocumentParser.java:323)
at com.sun.xml.bind.v2.runtime.unmarshaller.FastInfosetConnector.bridge(FastInfosetConnector.java:130)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
at com.firm.infrastructure.net.io.BinarySerializer.deserialize(BinarySerializer.java:177)
at com.firm.infrastructure.net.MessageDeserializationTask.run(MessageDeserializationTask.java:36)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:675)

Here is how I implement the serialization/deserialization:

public byte[] serialize(Object message) throws IOException
    {  
        byte[] bytes = new byte[0];
        long startTime = System.currentTimeMillis();
        
        if ( message != null )
        {
            try
            {  
                JAXBContext context =  SerializationManager.getContext();                       
                Marshaller m = context.createMarshaller();                 
                FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
                StAXDocumentSerializer sw = new StAXDocumentSerializer();
                sw.setOutputStream(bos);
                m.marshal(message, (XMLStreamWriter)sw);                
                bytes = bos.toByteArray();                
            }
            catch ( JAXBException ex )
            {
                SerializationManager.handleJAXBException(ex, message);            
            }
        }
        logger_.info("JAXB serialize: " + (System.currentTimeMillis() - startTime) + " ms.");
        return bytes;
    }

    public Object deserialize(byte[] bytes) throws IOException
    {
        Object message = null;        
        long startTime = System.currentTimeMillis();
        try
        {               
            JAXBContext context = SerializationManager.getContext();                         
            Unmarshaller um = context.createUnmarshaller();             
            FastByteArrayInputStream bis = new FastByteArrayInputStream(bytes);
            XMLStreamReader xr = new StAXDocumentParser(bis);            
            message = um.unmarshal(xr);            
        }
        catch ( JAXBException ex )
        {            
            SerializationManager.handleJAXBException(ex);            
        }
        logger_.info("JAXB deserialize: " + (System.currentTimeMillis() - startTime) + " ms.");
        return message;
    }

What would cause this? Please advice.

Thanks
A 

Connect and share in new ways with Windows Live. Get it now!
 
______________

The information contained in this message is proprietary and/or confidential. If you are not the 
intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, 
distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, 
please be aware that any message addressed to our domain is subject to archiving and review by 
persons other than the intended recipient. Thank you.
_____________