Question

I have created a Perl module to provide an interface with the RNG-processing Java library Jing. The code is located here. I use [Inline::Java][3] to compile and load a small class which utilizes jing.jar, both located in the java directory, which is shared via [File::ShareDir][4]. Running prove -vl or dzil test, the module works perfectly fine, and the tests all pass:

>prove -vl
t\0-use.t .............
1..1
ok 1 - use XML::Jing;
ok
t\01-validates_xml.t ..
1..3
ok 1 - successfully reads a valid RNG
ok 2 - returns nothing when XML file is valid
ok 3
ok
t\02-exceptions.t .....
1..5
ok 1 - warning for nonexistent RNG file
ok 2 - constructor returns nothing for non-existent RNG file
ok 3 - warning for bad RNG file
ok 4 - constructor returns nothing for bad RNG file
ok 5 - warning for nonexistent XML file
ok
All tests successful.
Files=3, Tests=9,  6 wallclock secs ( 0.11 usr +  0.05 sys =  0.16 CPU)
Result: PASS

Tests also pass when a distro is built using dzil build:

dzil build
cd XML-Jing-0.x
perl Build.PL
build
build test

However, using dzil release, Inline::Java croaks when it tries to load jing.jar. We get these crazy errors below:

BEGIN failed--compilation aborted at t/01-validates_xml.t line 5.
t/01-validates_xml.t ..........
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run

A problem was encountered while attempting to compile and install your InlineJava code. The command that failed was:
  "C:\Program Files\Java\jdk1.7.0_21\bin\javac.exe" -deprecation  -d "C:\strawberry\cpan\build\XML-Jing-0.01-Skydfp\_Inline\lib\auto\XML\Jing_706b" RNGValidator.java > cmd.out 2>&1

The build directory was:
C:\strawberry\cpan\build\XML-Jing-0.01-Skydfp\_Inline\build\XML\Jing_706b

The error message was:
error: error reading C:\strawberry\cpan\build\XML-Jing-0.01-Skydfp\blib\lib\auto\share\dist\XML-Jing\jing.jar; invalid END header (bad central directory offset)

Currently I load the jar using a begin block to edit the CLASSPATH variable:

BEGIN{
    use Env::Path;
    my $classpath = Env::Path->CLASSPATH;
    $classpath->Append(path(dist_dir('XML-Jing'),'jing.jar'));
}

Using jarsigner, I verified that the jar is corrupted in the build folder created by dzil release but not in the one created by dzil build:

In the build created via dzil build:

jarsigner -verify java/jing.jar
jar is unsigned. (signatures missing or not parsable)

In the build created via dzil release:

jarsigner -verify java/jing.jar
jarsigner: java.util.zip.ZipException: invalid END header (bad central directory offset)

To summarize, dzil release clobbers a jar in my shared directory, while dzil build does not. Can anyone tell me what I need to do to make this module work properly?

Was it helpful?

Solution

Its a bug. The kind that happens often and that has happened before in dzil.
Dist-Zilla-4.300034\lib\Dist\Zilla\Dist\Builder.pm line 388
replace open my $fh, '<', $filename; with open my $fh, '<:raw', $filename;

OTHER TIPS

Based on the error message "jing.jar; invalid END header (bad central directory offset)" what I can make out is that might be a case that jing.jar is corrupted. I would suggest you to download the jing.jar file again and then try putting it on the CLASS_PATH. Below is one link from where you can download jing

http://jing-trang.googlecode.com/files/jing-20091111.zip

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top