通过JMS侦听器接收xml消息,并根据XSD验证消息。虽然消息有效,但有时消息被视为无效,并引发以下异常。
xml消息未使用UTF-8编码,消息只是以root开头和结尾。
Msg Format :
<root>
<Message>Sample Message</Message>
</root>
导致邮件无效的问题可能是什么。
Websphere服务器 - 6.1 JDK版本1.6 春季版 - 2.3x
Parser Code :
InputStream inputStream = getResource().getInputStream();
Source schemaSource = new SAXSource(new InputSource(inputStream));
Schema schema = getSchemaFactory().newSchema(schemaSource);
ValidatorHandler validatorHandler = schema.newValidatorHandler();
validatorHandler.setContentHandler(this);
parser = getParser();
parser.setContentHandler(validatorHandler);
InputStream iStream = new ByteArrayInputStream(asyncMsg.getBytes());
InputSource inputSource = new InputSource(iStream);
错误日志:
Exception
at com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java:302)
at java.security.AccessController.doPrivileged(AccessController.java:192)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:65)
at com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java:271)
at com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java:240)
at com.ibm.mq.jms.MQSession.run(MQSession.java:1695)
at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:1040)
at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:1031)
at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:711)
at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:678)
at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:619)
at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:44)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:100)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:136)
at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:536)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at org.apache.xerces.impl.xs.opti.SchemaDOM.endElement(Unknown Source)
at org.apache.xerces.impl.xs.opti.SchemaDOMParser.endElement(Unknown Source)
at org.apache.xerces.impl.xs.traversers.SchemaContentHandler.endElement(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(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 org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
at javax.xml.validation.SchemaFactory.newSchema(Unknown Source)
... 24 more