title: JAX-WS call does not work when calling Java from Javascript using JXBrowser
body: <p>We're trying to migrate from JExplorer to JXBrowser.
  We're injecting a javascript function in the webpage context. That function in turn calls a webservice and does some processing with the result.</p>
  
  <p>The webservice call works fine on its own but fails when called by JXBrowser. The same code worked fine with JExplorer.
  We're using jaxws-rt (Metro) as our SOAP library (our own supplied version, not the JDK bundled version).</p>
  
  <p>Here's an SSCCE: </p>
  
  <p>Main.java</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          System.out.println("calling service from main");
          callService();
  
          Browser browser = new Browser();
          BrowserView view = new BrowserView(browser);
  
          JFrame frame = new JFrame("JxBrowser - Hello World");
          frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
          frame.add(view, BorderLayout.CENTER);
          frame.setSize(500, 400);
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
  
          browser.addScriptContextListener(new ScriptContextAdapter() {
              @Override
              public void onScriptContextCreated(ScriptContextEvent event) {
                  Browser browser = event.getBrowser();
                  JSValue window = browser.executeJavaScriptAndReturnValue("window");
                  window.asObject().setProperty("call", (JSFunctionCallback) args -&gt; callService());
              }
          });
  
          System.out.println("calling service from web page");
          browser.loadHTML("&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body onload='call()'&gt;&lt;h1&gt;Hello World!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;");
      }
  
      private static Object callService() {
          System.out.println("entering callService()");
          Object result = null;
          try {
              URL wsdlSource = new URL("http://www.dneonline.com/calculator.asmx?WSDL");
              QName serviceName = new QName("http://tempuri.org/", "Calculator");
              ServiceDelegate delegate = com.sun.xml.ws.spi.ProviderImpl.INSTANCE.createServiceDelegate(wsdlSource, serviceName, Service.class);
              CalculatorSoap port = delegate.getPort(CalculatorSoap.class);
              result = port.add(2, 3);
              System.out.println("result: " + result);
          } catch (Exception e) {
              e.printStackTrace();
          }
          return result;
      }
  }
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.sscce&lt;/groupId&gt;
      &lt;artifactId&gt;sscce&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
  
      &lt;properties&gt;
          &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
          &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;jaxws-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.5&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;wsimport&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;wsimport&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;wsdlUrls&gt;
                          &lt;wsdlUrl&gt;http://www.dneonline.com/calculator.asmx?WSDL&lt;/wsdlUrl&gt;
                      &lt;/wsdlUrls&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.ws&lt;/groupId&gt;
              &lt;artifactId&gt;jaxws-rt&lt;/artifactId&gt;
              &lt;version&gt;2.2.10&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.teamdev.jxbrowser&lt;/groupId&gt;
              &lt;artifactId&gt;jxbrowser-win32&lt;/artifactId&gt;
              &lt;version&gt;6.22&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.teamdev.jxbrowser&lt;/groupId&gt;
              &lt;artifactId&gt;jxbrowser-license&lt;/artifactId&gt;
              &lt;version&gt;6.0&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>The program prints the following:</p>
  
  <pre><code>calling service from main
  entering callService()
  result: 5
  calling service from web page
  entering callService()
  janv. 15, 2019 3:19:53 PM com.sun.xml.ws.spi.db.BindingContextFactory$1 hasNext
  WARNING: skipping factory: ServiceConfigurationError: com.sun.xml.ws.spi.db.BindingContextFactory: Provider com.sun.xml.ws.db.glassfish.JAXBRIContextFactory is specified in jar:file:/C:/Users/xxx/.m2/repository/com/sun/xml/ws/jaxws-rt/2.2.10/jaxws-rt-2.2.10.jar!/META-INF/services/com.sun.xml.ws.spi.db.BindingContextFactory but not found
  janv. 15, 2019 3:19:53 PM [com.sun.xml.ws.assembler.MetroConfigLoader]  init
  WARNING: MASM0010: Unable to unmarshall metro config file from location [ jar:file:/C:/Users/xxx/.m2/repository/com/sun/xml/ws/jaxws-rt/2.2.10/jaxws-rt-2.2.10.jar!/META-INF/jaxws-tubes-default.xml ]
  java.lang.NullPointerException
      at javax.xml.bind.ContextFinder.find(ContextFinder.java:326)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:431)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:394)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:298)
      at com.sun.xml.ws.assembler.MetroConfigLoader.createJAXBContext(MetroConfigLoader.java:280)
      at com.sun.xml.ws.assembler.MetroConfigLoader.loadMetroConfig(MetroConfigLoader.java:256)
      at com.sun.xml.ws.assembler.MetroConfigLoader.init(MetroConfigLoader.java:146)
      at com.sun.xml.ws.assembler.MetroConfigLoader.&lt;init&gt;(MetroConfigLoader.java:119)
      at com.sun.xml.ws.assembler.TubelineAssemblyController.getTubeCreators(TubelineAssemblyController.java:93)
      at com.sun.xml.ws.assembler.MetroTubelineAssembler.createClient(MetroTubelineAssembler.java:118)
      at com.sun.xml.ws.client.Stub.createPipeline(Stub.java:343)
      at com.sun.xml.ws.client.Stub.&lt;init&gt;(Stub.java:310)
      at com.sun.xml.ws.client.Stub.&lt;init&gt;(Stub.java:243)
      at com.sun.xml.ws.client.Stub.&lt;init&gt;(Stub.java:258)
      at com.sun.xml.ws.client.sei.SEIStub.&lt;init&gt;(SEIStub.java:98)
      at com.sun.xml.ws.client.WSServiceDelegate.getStubHandler(WSServiceDelegate.java:829)
      at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:818)
      at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:451)
      at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:419)
      at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:474)
      at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:478)
      at sscce.Main.callService(Main.java:57)
      at sscce.Main.access$0(Main.java:50)
      at sscce.Main$1.lambda$0(Main.java:42)
      at com.teamdev.jxbrowser.chromium.JSContext.a(SourceFile:1613)
      at com.teamdev.jxbrowser.chromium.JSContext$a.onMessageReceived(SourceFile:666)
      at com.teamdev.jxbrowser.chromium.internal.ipc.q.a(SourceFile:1084)
      at com.teamdev.jxbrowser.chromium.internal.ipc.r.run(SourceFile:68)
      at com.teamdev.jxbrowser.chromium.internal.r.run(SourceFile:79)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Thanks!</p>