Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

J2EE engine killed by a Java-Mapping-program (XI SP16)

Hi,

we have created a Java-Mapping prgram which has the task to validate incoming documents using a schema.

When we test this program, there would be thrown an exception, if the document is not valid. But if the document is valid the program kills the J2EE engine completley. All the services are stopped.

Does anybody know, why this happens?

We used the Blog "Validating messages in XI using XML-Schema" as template for our program.

Here our mapping class:

public class DocumentValidation implements StreamTransformation 
{
	
   static final String JAXP_SCHEMA_LANGUAGE =
		"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
	  
   static final String W3C_XML_SCHEMA =
		"http://www.w3.org/2001/XMLSchema"; 
			
   static final String JAXP_SCHEMA_SOURCE =
		"http://java.sun.com/xml/jaxp/properties/schemaSource";
	
   private Map            param = null;
   private AbstractTrace  trace = null;


   public void setParameter (Map param) 
   {
	  this.param = param;
	  if (param == null) 
	  {
		 this.param = new HashMap();
	  }
   }


   public void execute(InputStream in, OutputStream out) 
   {
	  
	  try 
	  {
		 trace = (AbstractTrace)param.get(
						   StreamTransformationConstants.MAPPING_TRACE );
		
	     String messageID = (String)param.get(
	    				   StreamTransformationConstants.MESSAGE_ID);
	    				   
		 trace.addInfo("Validating document with MessageID " + messageID + " ..."); 


	  	 DocumentValidation dv = new DocumentValidation();		 
		 InputStream schema = null;
		 String schemaName = new String("orders02.xsd");
		 
		 schema = dv.getClass().getClassLoader().getResourceAsStream(schemaName); 
		 
		 SAXParserFactory spf = SAXParserFactory.newInstance();
		 spf.setNamespaceAware(true);
		 spf.setValidating(true);
		 SAXParser sp = spf.newSAXParser();
		 
		 sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
		 
		 sp.setProperty(JAXP_SCHEMA_SOURCE, schema);
		 
		 sp.parse(in, new ParseErrorHandler());
		 
		 // InputStream nach OutputStream kopieren
		 int readcount;
		 byte[] buffer = new byte[1024];
		   
		 while ( (readcount = in.read(buffer)) > -1) 
		 {  
		 	out.write(buffer, 0, readcount); 
		 } 			 
		 
		 trace.addInfo("Stream was copied ... ");
		 
		 out.flush();
		 
	  }
	  catch(Exception ex)
	  {
	  	throw new RuntimeException("Error in Validation: " + ex);
	  }

   }
}


final class ParseErrorHandler extends DefaultHandler
{
	public void error(SAXParseException ex) throws SAXException
	{
		throw ex;
	}
}

I hope anybody can help us.

Regards

Thorsten

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question