|
next
|
Subject: Erratic behaviour in EDIFACT adapter Author: Oddbjørn Overskott Date: 17 Jan 2007 05:24 PM Originally Posted: 17 Jan 2007 07:28 AM
|
I'm trying out a java-based conversion of EDIFACT messages to XML. The conversion libraries give three different exceptions;
On the first one or two calls, I sometimes, but not always, can't unlock the api, because I'm on a one week trial license, and on a computer that is not directly connected to the internet:
<log>
2007-01-17 11:19:42,297 [EDIFACT_OUT] DEBUG no.nmd.was.messagecentral.map.AbstractMap - The call to StylusFileFactory.unlockAPI() failed:
2007-01-17 11:19:42,297 [EDIFACT_OUT] DEBUG no.nmd.was.messagecentral.map.AbstractMap - You must be connected to the internet to use an evaluation copy of Stylus Studio.
2007-01-17 11:19:42,312 [EDIFACT_OUT] DEBUG no.nmd.was.messagecentral.map.AbstractMap - The call to StylusFileFactory.unlockAPI() failed:
2007-01-17 11:19:42,312 [EDIFACT_OUT] DEBUG no.nmd.was.messagecentral.map.AbstractMap - You must be connected to the internet to use an evaluation copy of Stylus Studio.
</log>
Then when I call the Converter for the second or third time after startup, I get one of the two following exceptions; either a NullPointerException or an InvalidFormatException. These two take turns, without any apparent pattern:
<NullPointer>
2007-01-17 11:21:20,359 [EDIFACT_OUT] ERROR no.nmd.was.messagecentral.map.AbstractMap - Converter error:
com.stylusstudio.converter.ConverterException: Error during conversion:
at com.stylusstudio.converter.ConverterImpl.wrapAsConverterException(ConverterImpl.java:1363)
at com.stylusstudio.converter.ConverterImpl.access$1900(ConverterImpl.java:52)
at com.stylusstudio.converter.ConverterImpl$Job$PullPush.go(ConverterImpl.java:561)
at com.stylusstudio.converter.ConverterImpl$Job.<init>(ConverterImpl.java:537)
at com.stylusstudio.converter.ConverterImpl$Job.<init>(ConverterImpl.java:464)
at com.stylusstudio.converter.ConverterImpl.convert(ConverterImpl.java:124)
at no.nmd.was.messagecentral.map.AbstractMap.Map(AbstractMap.java:69)
at no.nmd.was.messagecentral.map.in.OrdersD93AInMap.map(OrdersD93AInMap.java:15)
at no.nmd.was.messagecentral.MessageProcessor.run(MessageProcessor.java:69)
at java.lang.Thread.run(Thread.java:568)
Caused by: java.io.IOException: Error in Converter adapter:
at com.stylusstudio.converter.ConverterImpl$Job.startAdapter(ConverterImpl.java:918)
at com.stylusstudio.converter.ConverterImpl$Job.access$1800(ConverterImpl.java:464)
at com.stylusstudio.converter.ConverterImpl$Job$PullPush.go(ConverterImpl.java:558)
... 7 more
Caused by: java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java(Inlined Compiled Code))
at java.io.InputStreamReader.<init>(InputStreamReader.java(Inlined Compiled Code))
at java.util.Properties.load(Properties.java(Compiled Code))
at com.stylusstudio.adapter.edi.Dialect.getResource(Dialect.java:181)
at com.stylusstudio.adapter.edi.Dialect.getResource(Dialect.java:113)
at com.stylusstudio.adapter.edi.EDIFACT.getResource(EDIFACT.java:142)
at com.stylusstudio.adapter.edi.EDIFACT.sniffVersion(EDIFACT.java:576)
at com.stylusstudio.adapter.edi.Parser.readSegment(Parser.java:306)
at com.stylusstudio.adapter.edi.EDI.toXML(EDI.java:385)
at com.stylusstudio.adapter.AdapterBase.toXML(AdapterBase.java:182)
at com.stylusstudio.converter.ConverterImpl$Job.startAdapter(ConverterImpl.java:911)
... 9 more
</NullPointer>
... or ...
<InvalidFormat>
2007-01-17 11:21:41,375 [EDIFACT_OUT] ERROR no.nmd.was.messagecentral.map.AbstractMap - Converter error:
com.stylusstudio.converter.ConverterException: Error during conversion:
at com.stylusstudio.converter.ConverterImpl.wrapAsConverterException(ConverterImpl.java:1363)
at com.stylusstudio.converter.ConverterImpl.access$1900(ConverterImpl.java:52)
at com.stylusstudio.converter.ConverterImpl$Job$PullPush.go(ConverterImpl.java:561)
at com.stylusstudio.converter.ConverterImpl$Job.<init>(ConverterImpl.java:537)
at com.stylusstudio.converter.ConverterImpl$Job.<init>(ConverterImpl.java:464)
at com.stylusstudio.converter.ConverterImpl.convert(ConverterImpl.java:124)
at no.nmd.was.messagecentral.map.AbstractMap.Map(AbstractMap.java:69)
at no.nmd.was.messagecentral.map.in.OrdersD93AInMap.map(OrdersD93AInMap.java:15)
at no.nmd.was.messagecentral.MessageProcessor.run(MessageProcessor.java:69)
at java.lang.Thread.run(Thread.java:568)
Caused by: java.io.IOException: Error in Converter adapter:
at com.stylusstudio.converter.ConverterImpl$Job.startAdapter(ConverterImpl.java:918)
at com.stylusstudio.converter.ConverterImpl$Job.access$1800(ConverterImpl.java:464)
at com.stylusstudio.converter.ConverterImpl$Job$PullPush.go(ConverterImpl.java:558)
... 7 more
Caused by: com.stylusstudio.adapter.InvalidFormatException: EDIFACT resources not reachable. Check classpath for EDIFACT.jar
at com.stylusstudio.adapter.edi.Dialect.getResource(Dialect.java:140)
at com.stylusstudio.adapter.edi.EDIFACT.getResource(EDIFACT.java:142)
at com.stylusstudio.adapter.edi.EDIFACT.sniffVersion(EDIFACT.java:576)
at com.stylusstudio.adapter.edi.Parser.readSegment(Parser.java:306)
at com.stylusstudio.adapter.edi.EDI.toXML(EDI.java:385)
at com.stylusstudio.adapter.AdapterBase.toXML(AdapterBase.java:182)
at com.stylusstudio.converter.ConverterImpl$Job.startAdapter(ConverterImpl.java:911)
... 9 more
</InvalidFormat>
The EDIFACT.jar file is explicitly added to the classpath.
I run StylusStudio 2007 Enterprise suite, build 735f. I downloaded it for evaluation / proof-of-concept on Friday, so I'm on a one week evaluation license.
The code I'm developing runs on an IBM WebSphere app server, version 6.0.2.15, and the app server uses IBM java version 1.4.2. It runs on a Windows 2000 Workstation.
com.stylusstudio.bindir is C:\Programfiler\Stylus Studio 2007 XML Enterprise Suite\bin
I am trying to invoke the EDI adapter, in order to map an edifact string to XML (and then transform it to our generic message format). The Java code is a work in progress, and as of now it looks like this:
<javacode>
private static ConverterFactory factory = null;
public AbstractMap() {
super();
if (factory == null) {
if (StylusFileFactory.unlockAPI("XXX") != true) {
String eMsg = StylusFileFactory.getUnlockAPIError();
if (eMsg != null && eMsg.startsWith("Insert your")) {
logger.debug("Edit this demo program and insert your Installation ID in the call to unlockAPI");
logger.debug("Make sure CustomFileSystem.jar is in your classpath,");
logger.debug("then compile and run it again.");
}
else {
logger.debug("The call to StylusFileFactory.unlockAPI() failed:\n");
if (eMsg==null)
logger.debug("No reason for failure was returned.");
else logger.debug(eMsg);
}
}
else {
logger.debug("StylusFileFactory was unlocked ok.");
factory = ConverterFactory.newInstance();
System.setProperty("com.stylusstudio.bindir",
"C:\\Programfiler\\Stylus Studio 2007 XML Enterprise Suite\\bin");
}
}
}
protected GenericMessage Map(String messageString) {
String prop = System.getProperty("com.stylusstudio.bindir");
logger.debug("com.stylusstudio.bindir = " + prop);
try {
StringWriter sw = new StringWriter();
StreamSource input = new StreamSource(new ByteArrayInputStream(messageString.getBytes()));
StreamResult output = new StreamResult(sw);
Converter conv = factory.newConvertToXML("adapter:EDI:decode=no:tbl=no:typ=no:opt=yes");
conv.convert(input, output);
logger.debug(sw.toString());
}
catch (ConverterException ex) {
logger.error("Converter error: ", ex);
}
return null;
}
</javacode>
|
|
|
|