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

REST client appears broken on 0.6.0 dev versions #407

Closed
Pneumaticat opened this issue Aug 4, 2019 · 5 comments

Comments

@Pneumaticat
Copy link

commented Aug 4, 2019

@Path("")
public interface UserService {
    @Path("login")
    @POST
    void login(LoginBody body);
}

...

UserService r = RESTClient.factory(UserService.class).createResource("");
BackgroundWorker worker = new BackgroundWorker();
worker.run(() -> {
    try {
        // Should make a POST request to /login with JSON body
        r.login(new LoginBody("bob", "bob"));
    } catch (Exception e) {
        e.printStackTrace();
    }
});

Results in:

image

The core issue is actually not a Java exception; rather, it's a JavaScript error from within standard library RequestImpl code, hence why it provides no description of what the error is. The REST client attempts, in 0.6.0-dev-816, to call a JS function that does not exist (otfri_RequestImpl_send0), and it fails with the JavaScript error otfri_RequestImpl_send0 is not defined. The only way I've been able to fix this is to roll back to Java 8 + TeaVM 0.5.1, which fixes the problem.

@konsoletyper

This comment has been minimized.

Copy link
Owner

commented Aug 5, 2019

Could not reproduce. Can you provide more info on how you using TeaVM? Do you build using Maven or IDEA code server? What optimization level are you using? Can you publish a self-contained example to reproduce the issue?

@Pneumaticat

This comment has been minimized.

Copy link
Author

commented Aug 5, 2019

Sure!

Using OpenJ9 Java 11:

openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.14.0, JRE 11 Linux amd64-64-Bit Compressed References 20190417_202 (JIT enabled, AOT enabled)
OpenJ9   - bad1d4d06
OMR      - 4a4278e6
JCL      - 5cc996a803 based on jdk-11.0.3+7)

Running TeaVM through Maven, at default optimization level and minifying off. The issue manifests on the Knoweth application I am building; the link points to a branch where the issue occurs. You can run it by running the com.github.knoweth.server.Application class and then compiling TeaVM in another window (mvn fizzed-watcher:run -f pom.xml).

@konsoletyper

This comment has been minimized.

Copy link
Owner

commented Aug 5, 2019

You can't use Flavour 0.1 with TeaVM 0.6-dev, you should switch to Flavour 0.2-dev instead. I found that I forgot to publish Flavour that works with latest TeaVM, I did it now, you should upgrade Flavour to 0.2.0-dev-70. Also, latest Flavour imposes new requirements: you should put @JsonPersistable annotation on every class you want to serialize to JSON and @Resource annotation on every JAX-RS interface. Sorry for these breaking changes, but I had to introduce them due to some major changes in the TeaVM architecture. Also sorry for not documenting this: current stable versions are 0.5 (TeaVM) and 0.1 (Flavour), and latest versions are not released yet (but will be very soon).

As for not providing reason for the original exception. I'm aware of this issue, but can't do anything with this, since it's not TeaVM issue, but the general issue with the design of exceptions in JavaScript (there's no 'official' way to get stack trace, there's no concept of cause like in Java). So the only way to figure out what's going on is to open browser dev tools, go to 'Debugger' section and setting 'pause on exceptions/pause on caught exceptions' flag.

@PokingUrsa

This comment has been minimized.

Copy link

commented Aug 6, 2019

A new release coming soon! Very exciting...

Our large TeaVM/Flavour-based project just went live. We use a lot of Flavour's features. Thanks for creating and maintaining it!

We will test with the new versions. It sounds like we will need to add tome new annotations to make it work.

@Pneumaticat

This comment has been minimized.

Copy link
Author

commented Aug 11, 2019

@konsoletyper Sorry for the late response - you are correct that switching to Flavor 0.2.0-dev-70 fixes the problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.