Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bnd wrap creates an inconsistent jar file #4507

Closed
sparsick opened this issue Jan 15, 2021 · 5 comments · Fixed by #4522
Closed

bnd wrap creates an inconsistent jar file #4507

sparsick opened this issue Jan 15, 2021 · 5 comments · Fixed by #4522
Assignees
Milestone

Comments

@sparsick
Copy link

I try to create an osgi-bundle from wlthint3client-14.1.1.jar (Oracle WebLogic Thin T3 Client) with the following command:

java -jar biz.aQute.bnd-5.2.0.jar wrap -p jars/wlthint3client.bnd jars/wlthint3client-14.1.1.jar

whereby wlthint3client.bnd has the following content:

-fixupmessages "Classes found in the wrong directory";restrict:=error;is:=warning

fixupmessages is needed because bnd doesn't yet support multi release jar see also #2227.

When I check the created jar by bnd with zip -T, I get the following error messsage:

// ....more similiar outputs
weblogic/workarea/WorkContextLocalMap$WorkContextKeys.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/WorkContextLocalMap.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/WorkContextMap.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/WorkContextMapImpl$1.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/WorkContextMapImpl.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/WorkContextOutput.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/AfterCopyContextsListener.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/AfterReceiveRequestListener.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/AfterSendRequestListener.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/BeforeSendRequestListener.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/WorkContextAccessController$WorkContextAccessControllerHolder$1.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/WorkContextAccessController$WorkContextAccessControllerHolder.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/WorkContextAccessController.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/WorkContextEntry.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/WorkContextEntryImpl.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/spi/WorkContextMapInterceptor.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/utils/WorkContextInputAdapter.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/workarea/utils/WorkContextOutputAdapter.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/xml/process/XMLParsingException.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
weblogic/xml/process/XMLProcessingException.class bad extra-field entry:
      EF block length (45534 bytes) exceeds remaining EF data (18 bytes)
test of wlthint3client-14.1.1.jar FAILED

zip error: Zip file invalid, could not spawn unzip, or wrong unzip (original files unmodified)

I unzipped this corrupted zip and what I note that every class file has a strange timestamp.

unzip wlthint3client-14.1.1.jar -d test
tree -D test
.....
    ├── [Jan 11 10:04]  workarea
    │   ├── [Dec 18  1988]  AsciiWorkContext.class
    │   ├── [Dec 18  1988]  LongWorkContext.class
    │   ├── [Dec 18  1988]  NoWorkContextException.class
    │   ├── [Dec 18  1988]  PrimitiveContextFactory.class
    │   ├── [Dec 18  1988]  PrimitiveWorkContext.class
    │   ├── [Dec 18  1988]  PropagationMode.class
    │   ├── [Dec 18  1988]  PropertyReadOnlyException.class
    │   ├── [Dec 18  1988]  SerializableWorkContext$1.class
    │   ├── [Dec 18  1988]  SerializableWorkContext$Carrier.class
    │   ├── [Dec 18  1988]  SerializableWorkContext.class
    │   ├── [Jan 11 10:04]  spi
    │   │   ├── [Dec 18  1988]  AfterCopyContextsListener.class
    │   │   ├── [Dec 18  1988]  AfterReceiveRequestListener.class
    │   │   ├── [Dec 18  1988]  AfterSendRequestListener.class
    │   │   ├── [Dec 18  1988]  BeforeSendRequestListener.class
    │   │   ├── [Dec 18  1988]  WorkContextAccessController$WorkContextAccessControllerHolder$1.class
    │   │   ├── [Dec 18  1988]  WorkContextAccessController$WorkContextAccessControllerHolder.class
    │   │   ├── [Dec 18  1988]  WorkContextAccessController.class
    │   │   ├── [Dec 18  1988]  WorkContextEntry.class
    │   │   ├── [Dec 18  1988]  WorkContextEntryImpl.class
    │   │   └── [Dec 18  1988]  WorkContextMapInterceptor.class
    │   ├── [Dec 18  1988]  StringWorkContext.class
    │   ├── [Dec 18  1988]  UserWorkArea.class
    │   ├── [Jan 11 10:04]  utils
    │   │   ├── [Dec 18  1988]  WorkContextInputAdapter.class
    │   │   └── [Dec 18  1988]  WorkContextOutputAdapter.class
    │   ├── [Dec 18  1988]  WorkContext.class
    │   ├── [Dec 18  1988]  WorkContextFilter.class
    │   ├── [Dec 18  1988]  WorkContextHelper.class
    │   ├── [Dec 18  1988]  WorkContextInput.class
    │   ├── [Dec 18  1988]  WorkContextLocalMap$1.class
    │   ├── [Dec 18  1988]  WorkContextLocalMap$WorkContextIterator.class
    │   ├── [Dec 18  1988]  WorkContextLocalMap$WorkContextKeys.class
    │   ├── [Dec 18  1988]  WorkContextLocalMap.class
    │   ├── [Dec 18  1988]  WorkContextMap.class
    │   ├── [Dec 18  1988]  WorkContextMapImpl$1.class
    │   ├── [Dec 18  1988]  WorkContextMapImpl.class
    │   └── [Dec 18  1988]  WorkContextOutput.class
    └── [Jan 11 10:04]  xml
        └── [Jan 11 10:04]  process
            ├── [Dec 18  1988]  XMLParsingException.class
            └── [Dec 18  1988]  XMLProcessingException.class

When I check the original jar with zip -T, everything is okay.

test of jars/wlthint3client-14.1.1.jar OK

Also, the timestamp of the class files looks correct.

I try it with Java 8 and Java 11. Both have the same result.

Any idea what is going wrong here?

@bjhargrave
Copy link
Member

Can you please provide a small github repo which demonstrates the problem? Then we can investigate. Thanks.

@sparsick
Copy link
Author

@bjhargrave I created a sample repo. I created a dummy jar, with that you can reproduce the error. I couldn't add the original wlthint3client-14.1.1.jar (Oracle WebLogic Thin T3 Client) because of licence reason.

@bjhargrave bjhargrave self-assigned this Feb 1, 2021
@bjhargrave bjhargrave added this to the 5.3 milestone Feb 2, 2021
@bjhargrave
Copy link
Member

ZIP extra fields are structured binary data. See section 4.5 of the ZIP File Format Specification. Bnd had incorrectly assumed the ZIP extra field could be treated as a UTF-8 encoded string. However, the structured binary data of a ZIP extra field cannot be safely decoded as UTF-8 data into a String and then re-encoded into UTF-8 data when writing a ZIP file. This resulted in corrupting the ZIP extra fields when wrapping a jar.

@bjhargrave
Copy link
Member

@sparsick Thanks for the bug report. The example repo really helped. The problem is now fixed in Bnd 5.3 which we hope to release by the end of Feb. See https://github.com/bndtools/bnd#using-the-latest-development-snapshot-build-of-bndbndtools if you want to test the fix with the snapshot builds.

@sparsick
Copy link
Author

sparsick commented Feb 4, 2021

@bjhargrave Thank you for your fast fix. I tested it and it works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants