Routing ZIP files in File Gateway

Technote (troubleshooting)


Problem(Abstract)

Sterling FileGateway routing fails when files inside a ZIP file have special characters in the file name.

Symptom

Sterling FileGateway file routing fails when files inside a ZIP file have special characters in their file name. Event code FG_0455 “java.lang.IllegalArgumentException”.


Cause

This is a known defect in the JDK both for Sun/Oracle and IBM JDK. The defect is resolved in JDK version 7.
See the information below at https://blogs.oracle.com/xuemingshen/entry/non_utf_8_encoding_in

Environment

JDK 6

Diagnosing the problem

Event code FG_0455 “java.lang.IllegalArgumentException”

filegateway.log
ERRORDTL [1355491932088]java.lang.
IllegalArgumentException
at java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:308)
at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:248)
at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:74)
at com.sterlingcommerce.fg.router.RouteIdentifier.crackOpenZip
(RouteIdentifier.java:621)
at com.sterlingcommerce.fg.router.RouteIdentifier.getZipTOC
(RouteIdentifier.java:601)
at com.sterlingcommerce.fg.router.RouteIdentifier.getMatches
(RouteIdentifier.java:512)
at com.sterlingcommerce.fg.router.RouteIdentifier.
findRoutePlansForChannel(RouteIdentifier.java:227)
at com.sterlingcommerce.fg.router.RouteIdentifier.findRoutePlans
(RouteIdentifier.java:163)
at com.sterlingcommerce.fg.router.ArrivedFile.determineRoutes
(ArrivedFile.java:544)
at com.sterlingcommerce.fg.router.ArrivedFile.startRoute(ArrivedFile.
java:211)
at com.sterlingcommerce.fg.router.FileGatewayRouter.processRoute
(FileGatewayRouter.java:136)
at com.sterlingcommerce.fg.services.FileGatewayRouteService.
primitiveProcessData(FileGatewayRouteService.java:76)
at com.sterlingcommerce.fg.services.TransformingRouterService.
processData(TransformingRouterService.java:79)

Resolving the problem

The solution is in JDK7 with 3 new constructors:
ZipFile(File, Charset)
ZipInputStream(InputStream, Charset)
ZipOutputStream(OutputStream, Charset)

NOTE:- Running SI in JDK 7 is not yet supported.

Here are some suggestions for a workaround to help process the data:
1. Ask the sender to remove accents from the file name.

2. Using (IBM) JDK 7 with the correct OS code page set (ibm437) works OK.



Here is the API to open Zip file to read special characters.
zis = new ZipInputStream(new FileInputStream("../test.zip"), Charset.forName("ibm437"));

The workaround is to install JDK 7 separately.
Run CLA2Client adapter on the server where JDK 7 is installed.

Call CLA2Client to extract the Zip File contents using JDK 7 before passing the extracted contents to SFG for file routing.
Any other command line tool could be used to achieve the same result provided it successfully unzips the contents of the Zip file.

3. For ZIP files, there is no standard encoding, and no standard method to indicate which encoding is used. So zip tools may generally pick some platform default encoding.
If the tool used to create the ZIP file name has the same encoding as the one used to read it, then there may not be a problem. If not, there will be a problem.

Java currently expects UTF-8 encoding in dealing with zip or jar file. For SFG java code to work with a zip file either the name of the file in zip should not have non-ascii characters or the zip tool generating the zip file uses UTF-8 encoding. Jar command in java jdk can generate a zip file with UTF-8 encoding.
For example, "jar -cfM test.zip *" to generate a zip file containing the file with non-ascii characters as its name and tested SFG with the generated zip file.

Please implement one of the workarounds above in order to process the data in SI


Rate this page:

(0 users)Average rating

Document information


More support for:

Sterling B2B Integrator
Adapters

Software version:

5.2

Operating system(s):

All

Reference #:

1621761

Modified date:

2013-01-07

Translate my page

Machine Translation

Content navigation