• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UnmarshalException

 
manikandan malathy
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem in Unmarshall......

This s my code

package Sample;
import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.apache.log4j.Logger;
import com.sun.jmx.remote.internal.Unmarshal;
class MarshalUnmarshal
{
JAXBContext jc;
Object parseObject=null;
String message="<?xml version=\'1.0\' encoding=\'UTF-8\'?><MSG_VER>1</MSG_VER><VAR_COU>0034</VAR_COU><LEG_COU>1</LEG_COU>";

private static Logger log=Logger.getLogger(MarshalUnmarshal.class);

public MarshalUnmarshal()
{
try
{
jc=JAXBContext.newInstance("Sample");
Unmarshaller u=jc.createUnmarshaller();
parseObject=u.unmarshal(new StringReader(message));
log.debug("parsedObject= " + parseObject);
}
catch(Exception e)
{
System.out.println("This s parsed error"+e);
}

}
public static void main(String[] s)
{
MarshalUnmarshal MU=new MarshalUnmarshal();
}



}

after executing i am getting this error:
errorjavax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"MSG_VER"). Expected elements are (unknown)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic