This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 257849 - @OnReceive doesn't work in NbBrowsers: Introduce xhr4j module
Summary: @OnReceive doesn't work in NbBrowsers: Introduce xhr4j module
Alias: None
Product: platform
Classification: Unclassified
Component: Html4j (show other bugs)
Version: 8.1
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Jaroslav Tulach
Depends on:
Reported: 2016-02-04 16:44 UTC by maxnitribitt
Modified: 2016-03-18 02:47 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description maxnitribitt 2016-02-04 16:44:46 UTC
When using htmlui api, the @OnReceive annotation doesn't work correctly. 

I have created an application using the DukeScript Wizard that connects to the bitbucket REST API. It works correctly in the normal client, but doesn't work when running in the "Client for NetBeans". 

Debugging showed that with KOTransfer in LoadJSON the XMLHttpRequest returns status code "0", and never gets past a request.readyState of "1".

Similar bugs (XMLHttpRequest returns status code "0") on Stackoverflow almost always are problems with CORS. Apparently it doesn't work when WebView is running inside NetBeans. I tried setting a system property for WebView as a workaround as indicated here, but without success:

Workaround: Using Tyrus (ko-ws-tyrus) instead of KOTransfer the application works correctly.

To use it I added a dependency on Tyrus:


In addition to the dependency you need to register Tyrus on a position lower than 100 (otherwise KOTransfer has preference):

import org.netbeans.html.context.spi.Contexts;
import org.netbeans.html.json.spi.Transfer;
import org.openide.util.lookup.ServiceProvider;

@ServiceProvider(service = Contexts.Provider.class)
public class RegisterTransfer  implements Contexts.Provider {

    public void fillContext(Contexts.Builder context, Class<?> requestor) {
        context.register(Transfer.class, new KOTransfer(), 10);

That is a bit cumbersome, so I would suggest to make it easier to use Tyrus. It should probably be the default when running in NetBeans.
Comment 1 maxnitribitt 2016-02-04 17:15:34 UTC
Here's the project with the workaround:

To test without tyrus just comment out the registration of Provider:

// @ServiceProvider(service = Contexts.Provider.class)
Comment 2 Jaroslav Tulach 2016-02-29 04:29:11 UTC
The best way to simplify this is to provide new xhr4j module that will handle the @OnReceive request with higher priority:
I plan to add the module for HTML/Java 1.3 - e.g. NetBeans 8.2
Comment 3 Jaroslav Tulach 2016-03-01 03:40:59 UTC
The bits for HTML/Java 1.3 are staged at
Please give them a bit of testing.
Comment 4 Jaroslav Tulach 2016-03-04 10:32:22 UTC
2nd attempt to release HTML/Java @ 1.3 bits:
Comment 5 Jaroslav Tulach 2016-03-15 08:04:15 UTC
I plan to release the bits of HTML/Java @ 1.3 in 24h.
Comment 7 Jaroslav Tulach 2016-03-15 22:27:08 UTC
Comment 8 Quality Engineering 2016-03-18 02:47:51 UTC
Integrated into 'main-silver', will be available in build *201603180001* on (upload may still be in progress)

User: Jaroslav Tulach <>
Log: #257849: Switching existing HTML/Java modules to version 1.3