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

Main Class Not Found with AdoptOpneJDK/IcedTea-Web version >1.8, working in 1.8 #465

Closed
solcaj opened this issue Oct 15, 2019 · 10 comments · Fixed by #719
Closed

Main Class Not Found with AdoptOpneJDK/IcedTea-Web version >1.8, working in 1.8 #465

solcaj opened this issue Oct 15, 2019 · 10 comments · Fixed by #719
Labels
bug Something isn't working
Milestone

Comments

@solcaj
Copy link

solcaj commented Oct 15, 2019

we have an application which is started using JNLP and was working using IcedTeaWeb Version 1.8 (classpath.org, pipermail march 19).

When I tried the same JNLP file with AdoptOpenJDK/IcedTea-Web Version 1.8.1 .. 1.8.3 I got the following errors (identical error for all three versions of IcedTea Web > 1.8)

selected jre: C:\Program Files\Amazon Corretto\jdk1.8.0_222\jre\
JAR https://XXXXX/YY/docs/jnlp/doc-applet.jar not found. Continuing.
JAR https://XXXXX/YY/docs/jnlp/doc-applet.jar not found. Continuing.
netx: Initialization Error: Could not initialize application. (Fatal: Initialization Error: Unknown Main-Class. Could not determine the main class for this application.)
net.sourceforge.jnlp.LaunchException: Fatal: Initialization Error: Could not initialize application. The application has not been initialized, for more information execute javaws from the command line.
        at net.sourceforge.jnlp.Launcher.createApplication(Launcher.java:822)
        at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:531)
        at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:945)
Caused by: net.sourceforge.jnlp.LaunchException: Fatal: Initialization Error: Unknown Main-Class. Could not determine the main class for this application.
        at net.sourceforge.jnlp.runtime.JNLPClassLoader.initializeResources(JNLPClassLoader.java:774)
        at net.sourceforge.jnlp.runtime.JNLPClassLoader.<init>(JNLPClassLoader.java:338)
        at net.sourceforge.jnlp.runtime.JNLPClassLoader.createInstance(JNLPClassLoader.java:421)
        at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:495)
        at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:468)
        at net.sourceforge.jnlp.Launcher.createApplication(Launcher.java:814)
        ... 2 more

The Jar file at https://XXXXX/YY/docs/jnlp/doc-applet.jar is falsely not found since with 1.8 is ok ok and pointing a browser to this URL finds the JAR file. Then in the JNLP the main class is declared in the <application-desc>section.

Any hints or advises would be very helpful

@karianna karianna added this to the 2.0.x milestone Oct 21, 2019
@karianna karianna added the bug Something isn't working label Oct 21, 2019
@karianna karianna modified the milestones: 2.0.x, 1.8.x Oct 21, 2019
@Jamila891
Copy link

@solcaj is this issue still open? If yes, can you please provide a JNLP file?

@jastax
Copy link

jastax commented Oct 13, 2020

I ran into the same issue a few days ago, I think. Deleting the cache solved it as far as i remember. I think there was a problem trying to download a jardiff for an updated jar. The downloader said the jardiff could not be found (it was available on the server though)

@jastax
Copy link

jastax commented Oct 13, 2020

Waiting for exception dialog to be closed
Launch exception
netx: Initialization Error: Could not initialize application. (Fatal: Initialization Error: Unknown Main-Class. Could not determine the main class for this application.)
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
Activate native: http://application.ourdomain/clientstarter/jars/client.jar
Activate jar: http://application.ourdomain/clientstarter/jars/client.jar
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
DownloadServiceListener will be disposed
Download done. Shutting down executor
Download for client.jar has already been started.
Will check and maybe put into cache: client.jar
System logger called with result of 0
System logger called with result of 0
DownloadServiceListener for LAS Client Build 20.09.0.20201007.0 will be created
Jars not ready to provide attribute Application-Name
checkForMain JAR http://application.ourdomain/clientstarter/jars/client.jar not found. Continuing.
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
Activate native: http://application.ourdomain/clientstarter/jars/properties.jar
Activate jar: file:/var/cache/java.deployment/2/244/properties.jar
DownloadServiceListener will be disposed
Download done. Shutting down executor
Download for properties.jar has already been started.
Will check and maybe put into cache: properties.jar
System logger called with result of 0
System logger called with result of 0
DownloadServiceListener for LAS Client Build 20.09.0.20201007.0 will be created
Jars not ready to provide attribute Application-Name
checkForMain JAR http://application.ourdomain/clientstarter/jars/client.jar not found. Continuing.
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
App already has trusted publisher: true
CN=Java Code Signing,O=Company,C=DE found in cacerts (/etc/java-8-oracle/security/cacerts)
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
System logger called with result of 0
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
CN=Java Code Signing,O=Company,C=DE found in cacerts (/etc/java-8-oracle/security/cacerts)
Operating Keystore /etc/.java/deployment/security/trusted.certs
Loading Keystore /etc/.java/deployment/security/trusted.certs
Keystore file /etc/.java/deployment/security/trusted.certs exists.
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
Operating Keystore /etc/.java/deployment/security/trusted.certs
Loading Keystore /etc/.java/deployment/security/trusted.certs
Keystore file /etc/.java/deployment/security/trusted.certs exists.
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.Waiting for exception dialog to be closed
Launch exception
netx: Initialization Error: Could not initialize application. (Fatal: Initialization Error: Unknown Main-Class. Could not determine the main class for this application.)
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
Activate native: http://application.ourdomain/clientstarter/jars/client.jar
Activate jar: http://application.ourdomain/clientstarter/jars/client.jar
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
DownloadServiceListener will be disposed
Download done. Shutting down executor
Download for client.jar has already been started.
Will check and maybe put into cache: client.jar
System logger called with result of 0
System logger called with result of 0
DownloadServiceListener for LAS Client Build 20.09.0.20201007.0 will be created
Jars not ready to provide attribute Application-Name
checkForMain JAR http://application.ourdomain/clientstarter/jars/client.jar not found. Continuing.
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
Activate native: http://application.ourdomain/clientstarter/jars/properties.jar
Activate jar: file:/var/cache/java.deployment/2/244/properties.jar
DownloadServiceListener will be disposed
Download done. Shutting down executor
Download for properties.jar has already been started.
Will check and maybe put into cache: properties.jar
System logger called with result of 0
System logger called with result of 0
DownloadServiceListener for LAS Client Build 20.09.0.20201007.0 will be created
Jars not ready to provide attribute Application-Name
checkForMain JAR http://application.ourdomain/clientstarter/jars/client.jar not found. Continuing.
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
App already has trusted publisher: true
CN=Java Code Signing,O=Company,C=DE found in cacerts (/etc/java-8-oracle/security/cacerts)
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
System logger called with result of 0
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
CN=Java Code Signing,O=Company,C=DE found in cacerts (/etc/java-8-oracle/security/cacerts)
Operating Keystore /etc/.java/deployment/security/trusted.certs
Loading Keystore /etc/.java/deployment/security/trusted.certs
Keystore file /etc/.java/deployment/security/trusted.certs exists.
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
Operating Keystore /etc/.java/deployment/security/trusted.certs
Loading Keystore /etc/.java/deployment/security/trusted.certs
Keystore file /etc/.java/deployment/security/trusted.certs exists.
Operating Keystore /etc/java-8-oracle/security/cacerts
Loading Keystore /etc/java-8-oracle/security/cacerts
Keystore file /etc/java-8-oracle/security/cacerts exists.
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
Jar found at /var/cache/java.deployment/2/244/properties.jar has been verified as SIGNED_NOT_OK
DownloadServiceListener will be disposed
Download done. Shutting down executor
could not download resource location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE from any of theses urls http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0
Exception while downloading resource location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE from http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0 - /home/m500406/.cache/icedtea-web/tmp/d071c8a5-a7a9-4dd5-8c3c-5beac8b0edeb.jardiff (Datei oder Verzeichnis nicht gefunden)
Trying to merge JarDiff for 'client.jar'
Will use JarDiff for 'http://application.ourdomain/clientstarter/jars/client.jar'
Will use no compression-unpacker for 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0'
isCached: http://application.ourdomain/clientstarter/jars/client.jar - (v: 20.09.0.20201007.0) = false
PAC Proxies found for 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' : [DIRECT]
PAC result for url 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' -> 'DIRECT'
Will download in background: http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0
Found best URL for location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE: url:http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0; responseCode:200; location: null; version: 20.09.0.20201007.0; lastModified: 1601977043000; contentLength: 4383915;
Best url for location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE is http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0 by HEAD
URL connection 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' header fields: {Keep-Alive=[timeout=5, max=100], null=[HTTP/1.1 200 200], Content-Disposition=[attachment; filename=client-20.06.0.20200831.0-to-20.09.0.20201007.0.jardiff], Connection=[Keep-Alive], x-java-jnlp-version-id=[20.09.0.20201007.0], Last-Modified=[Tue, 06 Oct 2020 09:37:23 GMT], Content-Length=[4383915], Date=[Thu, 08 Oct 2020 13:38:04 GMT], Content-Type=[application/x-java-archive-diff]}
PAC Proxies found for 'socket://application.ourdomain:80' : [DIRECT]
PAC result for url 'socket://application.ourdomain:80' -> 'DIRECT'
PAC Proxies found for 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' : [DIRECT]
PAC result for url 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' -> 'DIRECT'
System logger called with result of 0
Candidate URLs for location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE: http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0
isCached: remote size:46825503 cached size:46825503 -> true
System logger called with result of 0
Use cached version of resource location=http://application.ourdomain/clientstarter/jars/properties.jar version=20.09.0.20201007.0 state=DOWNLOADED
System logger called with result of 0
Download for client.jar has already been started.
Will check and maybe put into cache: client.jar
Download for properties.jar has already been started.
Will check and maybe put into cache: properties.jar
isCached: http://application.ourdomain/clientstarter/jars/client.jar - (v: 20.09.0.20201007.0) = false
System logger called with result of 0
isCached: http://application.ourdomain/clientstarter/jars/properties.jar - (v: 20.09.0.20201007.0) = true
isCached: remote size:12971 cached size:12971 -> true
System logger called with result of 0
DownloadServiceListener for LAS Client Build 20.09.0.20201007.0 will be created
Download of resource client.jar will start now!
Jars not ready to provide attribute Application-Name
Download has not been started yet: client.jar
Checking download state of client.jar
Download for client.jar has not been started until now
Will check and maybe put into cache: client.jar
Will add resource 'client.jar'
Download of resource properties.jar will start now!
Will add resource at location 'http://application.ourdomain/clientstarter/jars/client.jar'
Download has not been started yet: properties.jar
Checking download state of properties.jar
Error flag set for resource 'http://application.ourdomain/clientstarter/jars/client.jar'. Can not return a local file for the resource
Jar found at /var/cache/java.deployment/2/244/properties.jar has been verified as SIGNED_NOT_OK
DownloadServiceListener will be disposed
Download done. Shutting down executor
could not download resource location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE from any of theses urls http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0
Exception while downloading resource location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE from http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0 - /home/m500406/.cache/icedtea-web/tmp/d071c8a5-a7a9-4dd5-8c3c-5beac8b0edeb.jardiff (Datei oder Verzeichnis nicht gefunden)
Trying to merge JarDiff for 'client.jar'
Will use JarDiff for 'http://application.ourdomain/clientstarter/jars/client.jar'
Will use no compression-unpacker for 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0'
isCached: http://application.ourdomain/clientstarter/jars/client.jar - (v: 20.09.0.20201007.0) = false
PAC Proxies found for 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' : [DIRECT]
PAC result for url 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' -> 'DIRECT'
Will download in background: http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0
Found best URL for location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE: url:http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0; responseCode:200; location: null; version: 20.09.0.20201007.0; lastModified: 1601977043000; contentLength: 4383915;
Best url for location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE is http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0 by HEAD
URL connection 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' header fields: {Keep-Alive=[timeout=5, max=100], null=[HTTP/1.1 200 200], Content-Disposition=[attachment; filename=client-20.06.0.20200831.0-to-20.09.0.20201007.0.jardiff], Connection=[Keep-Alive], x-java-jnlp-version-id=[20.09.0.20201007.0], Last-Modified=[Tue, 06 Oct 2020 09:37:23 GMT], Content-Length=[4383915], Date=[Thu, 08 Oct 2020 13:38:04 GMT], Content-Type=[application/x-java-archive-diff]}
PAC Proxies found for 'socket://application.ourdomain:80' : [DIRECT]
PAC result for url 'socket://application.ourdomain:80' -> 'DIRECT'
PAC Proxies found for 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' : [DIRECT]
PAC result for url 'http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0' -> 'DIRECT'
System logger called with result of 0
Candidate URLs for location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE: http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0
isCached: remote size:46825503 cached size:46825503 -> true
System logger called with result of 0
Use cached version of resource location=http://application.ourdomain/clientstarter/jars/properties.jar version=20.09.0.20201007.0 state=DOWNLOADED
System logger called with result of 0
Download for client.jar has already been started.
Will check and maybe put into cache: client.jar
Download for properties.jar has already been started.
Will check and maybe put into cache: properties.jar
isCached: http://application.ourdomain/clientstarter/jars/client.jar - (v: 20.09.0.20201007.0) = false
System logger called with result of 0
isCached: http://application.ourdomain/clientstarter/jars/properties.jar - (v: 20.09.0.20201007.0) = true
isCached: remote size:12971 cached size:12971 -> true
System logger called with result of 0
DownloadServiceListener for LAS Client Build 20.09.0.20201007.0 will be created
Download of resource client.jar will start now!
Jars not ready to provide attribute Application-Name
Download has not been started yet: client.jar
Checking download state of client.jar
Download for client.jar has not been started until now
Will check and maybe put into cache: client.jar
Will add resource 'client.jar'
Download of resource properties.jar will start now!
Will add resource at location 'http://application.ourdomain/clientstarter/jars/client.jar'
Download has not been started yet: properties.jar
Checking download state of properties.jar

@sclassen
Copy link
Contributor

We suspect that there might be an issue with JarDiff.
Unfortunately we do not have a system setup to test and debug this.
The log contains the following lines:

Exception while downloading resource location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE from http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0 - /home/m500406/.cache/icedtea-web/tmp/d071c8a5-a7a9-4dd5-8c3c-5beac8b0edeb.jardiff (Datei oder Verzeichnis nicht gefunden)
could not download resource location=http://application.ourdomain/clientstarter/jars/client.jar version=20.09.0.20201007.0 state=INCOMPLETE from any of theses urls http://application.ourdomain/clientstarter/jars/client.jar?version-id=20.09.0.20201007.0&current-version-id=20.06.0.20200831.0

So the problem could be at different places. Either with the server to provide the jardiff.
Or with OWS failing to save the diff or failing to apply the diff...

@sclassen
Copy link
Contributor

If you are able to give us access to a system where we can reproduce this behavior we are more than happy to look into this.

@jastax
Copy link

jastax commented Oct 16, 2020

It was no problem to get the Jardiff via browser and it also works via Oracle Webstart, so I don't think it's a server issue. I will try to pin it down further though.

I will see what I can do to reproduce this, but I' not sure it's going to work.

@jastax
Copy link

jastax commented Oct 16, 2020

I think the wrong cache folder is used when doing the operation. It's configured to be /var/cache/java.deployment but it tries to use icedtea-web/cache (default).

I have to leave now but may look into whether this is the case later.

@jastax
Copy link

jastax commented Oct 16, 2020

Btw: using CacheUtil.downloadAndGetCacheFile on the jardiff seems to work

@jastax
Copy link

jastax commented Oct 19, 2020

I'm currently unable to reproduce, but I now believe this exceptions occurs, because the folder ~/.cache/icedtea-web/tmp does not exist, i. e. when using another cache folder than the default one. In other cases there are calls like this

final File recentlyUsedFile = recentlyUsed.getFile();
        if (!recentlyUsedFile.exists()) {
            try {
                FileUtils.createParentDir(recentlyUsedFile);
                ...

so the folder seems to get created at some point.

But when using another folder it does not get created. Calling unpack(final InputStream input) does

    final File diffJarFile = new File(TMP_DIR.getFile(), UUID.randomUUID().toString() + JARDIFF_EXTENSION);

which is using /.cache/icedtea-web/tmp/, but the (parent) folder was not created at any point.

Is this possible? I will try to reproduce the issue if you need more information, but I'm short of time at the moment.

So to fix this issue I think you must make sure that the folder

~/.cache/icedtea-web/tmp/

exists.

@jastax
Copy link

jastax commented Oct 20, 2020

@sclassen This test throws java.io.FileNotFoundException: /home/myuser/.cache/icedtea-web/tmp/1bd2adfe-77dc-44d7-bdc8-21b073fa8aa6.jardiff (Datei oder Verzeichnis nicht gefunden) if /home/myuser/.cache/icedtea-web/tmp/ does not exist.

 @Test
    public void unpack() throws IOException {
        //given
        final URL jar1Url = JarDiffMergerTest.class.getResource("version-1.jar");
        final URL diffUrl = JarDiffMergerTest.class.getResource("diff-1-to-2.jardiff");

        File jar = new File(jar1Url.getFile());

        JarDiffUnpacker jarDiffUnpacker = new JarDiffUnpacker(jar);

        InputStream diffInputStream = diffUrl.openStream();

        InputStream unpackedInputStream = jarDiffUnpacker.unpack(diffInputStream);
        assertTrue(true);
    }

Adding FileUtils.createParentDir(diffJarFile); seems to fix the issue for me. I'm not sure it's the right way to do it though

  @Override
   public InputStream unpack(final InputStream input) throws IOException {
       Assert.requireNonNull(input, "input");

       LOG.info("Trying to merge JarDiff for '{}'", cacheFile.getName());
       final JarFile originalJar = new JarFile(cacheFile);
       final File diffJarFile = new File(TMP_DIR.getFile(), UUID.randomUUID().toString() + JARDIFF_EXTENSION);
       FileUtils.createParentDir(diffJarFile);

       try(final FileOutputStream outputStream = new FileOutputStream(diffJarFile)) {
           IOUtils.copy(input, outputStream);
           final JarFile diffJar = new JarFile(diffJarFile);
           final ByteArrayOutputStream mergedJarContent = new ByteArrayOutputStream();
           try(final JarOutputStream resultJarOutputStream = new JarOutputStream(mergedJarContent)) {
               JarDiffMerger.merge(originalJar, diffJar, resultJarOutputStream);
           }
           return new ByteArrayInputStream(mergedJarContent.toByteArray());
       } finally {
           if(diffJarFile.exists() && !diffJarFile.delete()) {
               LOG.debug("Temp file '{}' for JarDiff merge can not be deleted. Will try to delete it on exit", diffJarFile.getName());
               diffJarFile.deleteOnExit();
           }
       }
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants