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

Sender example can't find OemCodes.json #3

Closed
Firionus opened this issue Jul 1, 2020 · 4 comments
Closed

Sender example can't find OemCodes.json #3

Firionus opened this issue Jul 1, 2020 · 4 comments
Assignees
Labels
bug Something isn't working confirmed

Comments

@Firionus
Copy link
Contributor

Firionus commented Jul 1, 2020

Describe the bug
Sender example from README.md throws ExceptionInInitializerError.

To Reproduce

  • gradle init a standard application.
  • Add implementation 'de.deltaeight:LibArtNet:1.1-beta' to the dependencies in build.gradle.
  • Run Sender example from README.md
  • Get back Exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
        at de.deltaeight.libartnet.builders.ArtPollReplyBuilder.<init>(ArtPollReplyBuilder.java:107)
        at firstVSCode.App.main(App.java:16)
Caused by: java.nio.file.FileSystemNotFoundException
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:156)
        at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:142)
        at java.base/java.nio.file.Path.of(Path.java:208)
        at java.base/java.nio.file.Paths.get(Paths.java:98)
        at de.deltaeight.libartnet.descriptors.OemCode.<clinit>(OemCode.java:57)
        ... 2 more

Expected behavior
Don't throw an exception.

Code examples

/*
 * This Java source file was generated by the Gradle 'init' task.
 */
package firstVSCode;

import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

import de.deltaeight.libartnet.builders.ArtPollReplyBuilder;
import de.deltaeight.libartnet.descriptors.OemCode;
import de.deltaeight.libartnet.network.ArtNetSender;

public class App {
    public static void main(String[] args) throws SocketException, UnknownHostException {
        ArtPollReplyBuilder builder = new ArtPollReplyBuilder()
                // report as Robert Juliat Dalis Reference : 860
                .withProduct(OemCode.getProductByOemCode("OemRobertJulDalis1")).withBindIp(new byte[] { 127, 0, 0, 1 });

        ArtNetSender sender = new ArtNetSender();
        sender.start();

        sender.send(InetAddress.getByName("127.0.0.1"), builder.build());

        // Do other stuff

        sender.stop();
    }
}

System:

  • OS: Windows 10 Pro 1903, Build 18362.900
  • JDK/JRE Version
>java --version
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)
  • Library version: 1.1-beta

Additional context
jar-builds need a ZIP File System. ZipFileSystemProvider apparently cannot be created automatically.

Googling for FileSystemNotFoundException bring up lots of relevant results, but I can't make anything of it yet - I'm still new to Java.

@schw4rzlicht schw4rzlicht self-assigned this Jul 1, 2020
@schw4rzlicht schw4rzlicht added bug Something isn't working confirmed labels Jul 1, 2020
@schw4rzlicht
Copy link
Member

I just confirmed the issue. Thanks for reporting back.

It actually only happens in the published artifacts due to Paths.get() not being able to resolve files inside a .jar file. The error occurs here:

products = new Gson().fromJson(new String(Files.readAllBytes(Paths.get(OemCode.class
.getResource("OemCodes.json").toURI()))), Product[].class);

It simply fails when loading OEM codes from the included .json file. I'm looking into the issue but appreciate every input :)

@schw4rzlicht
Copy link
Member

Should be fixed in v1.1.1-beta. Would be nice if you could verify that :)

@Firionus
Copy link
Contributor Author

Firionus commented Jul 1, 2020

Yes, with v1.1.1-beta in the dependencies the error is gone.

The sender example sent an ArtPollReply and I already modified it to send an ArtDmx packet. Thanks for the fast fix - excited to try this library out now!

@Firionus Firionus closed this as completed Jul 1, 2020
@schw4rzlicht
Copy link
Member

Awesome! Let me know if there are any issues or features you might miss :)

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

No branches or pull requests

2 participants