cancel
Showing results for 
Search instead for 
Did you mean: 

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

thorsten_hautz
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member187339
Active Contributor
0 Kudos

Hi,

Test your prg first

/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio

Regards

Suraj

thorsten_hautz
Participant
0 Kudos

Hi Suraj,

I have tested my program.

The problem is the call of the function "parse".

There would be generated a Stackoverflow.

I tried to use the DOM-parser but I get the same effect.

Our schema file has a size of 160kB and I think that could be the problem. But the xsd-file of ORDERS02 has such a size.

Has anybody an idea how to solve this problem?

Regards

Thorsten

Answers (1)

Answers (1)

Former Member
0 Kudos

Are you sure the value

static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";

is correct?This is because I got an exception when tried running your code in NWDS..stacktrace below for your ref.

<i>org.xml.sax.SAXNotRecognizedException: Property: http://java.sun.com/xml/jaxp/properties/schemaLanguage

at org.apache.crimson.parser.XMLReaderImpl.setProperty(XMLReaderImpl.java:272)at org.apache.crimson.jaxp.SAXParserImpl.setPropertySAXParserImpl.java:190)at

DocumentValidation.execute(DocumentValidation.java:67)

at DocumentValidation.main(DocumentValidation.java:100)</i>

The statement at line number 67 in the code is

sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);

~ Amol

thorsten_hautz
Participant
0 Kudos

Hi Amol,

thanks for your answer.

The error you describing appears if you use an earlier version than 1.2 of JAXP. In Eclipse 2.1 an earlier version of JAXP is integrated, so you can't test this program there.

In SAPHelp <a href="http://help.sap.com/saphelp_nw04/helpdata/de/c4/e1343e8c7f6329e10000000a114084/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/de/c4/e1343e8c7f6329e10000000a114084/frameset.htm</a> you can find the original code from SAP. In this code you can also find this string. XI supports version 1.2 of JAXP. That couldn't be the problem.

If the document isn't valid I get an error, that the document isn't valid. The problem only exists when the document is valid.

It's very strange.

Regards

Thorsten

Former Member
0 Kudos

Hi Thorsten,

Remove <b>out.flush();</b> statement.

Why do you flush the output stream?

I am sure by removing this line will make the Javamapping work.

Best regards,

Felix

thorsten_hautz
Participant
0 Kudos

Hi Felix,

thanks for your answer.

I removed the line "out.flush();", but ist doesn't work.

I had to restart the J2EE-engine, because it was killed again.

I dont't understand this effect.

Regards,

Thorsten