SOAP - JAVA - java.lang.ClassNotFoundException: com.sun.xml.bind.api.JAXBRIContext

0

Main Class

import javax.swing.RowFilter.ComparisonType;

import net.webservicex.ComputerUnit;
import net.webservicex.ComputerUnitSoap;
import net.webservicex.Computers;

public class llamarServicio {

    public static void main(String[] args) {

        ComputerUnitSoap servicio = new ComputerUnit().getComputerUnitSoap();
        double result = servicio.changeComputerUnit(4000, Computers.MEGABYTE, Computers.BYTE);
        System.out.println(result);
    }

}

pom.xml

   <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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.soap</groupId>
  <artifactId>example</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>com.sun.xml.ws</groupId>
      <artifactId>jaxws-rt</artifactId>
      <version>2.2.8</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.11</version>
    </dependency>

  </dependencies>

    <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.4.1</version>
        <configuration>
            <wsdlUrls>
              <wsdlUrl>http://www.webservicex.net/ConvertComputer.asmx?WSDL</wsdlUrl>
            </wsdlUrls>
            <vmArgs>
              <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
            </vmArgs>
          <!-- The name of your generated source package -->
          <sourceDestDir>src/main/java</sourceDestDir>
        </configuration>
       </plugin>
    </plugins>
  </build>

</project>

Error

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/bind/api/JAXBRIContext
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:271)
    at com.sun.xml.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:100)
    at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:74)
    at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:58)
    at com.sun.xml.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:127)
    at com.sun.xml.ws.client.WSServiceDelegate.buildRuntimeModel(WSServiceDelegate.java:863)
    at com.sun.xml.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:879)
    at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:843)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:446)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:415)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:397)
    at javax.xml.ws.Service.getPort(Service.java:119)
    at net.webservicex.ComputerUnit.getComputerUnitSoap(ComputerUnit.java:72)
    at llamarServicio.main(llamarServicio.java:13)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.api.JAXBRIContext
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 14 more

I'm new to this, so excuse me if it's a very obvious mistake. What would be the reason for the error?

    
asked by Jesus Oviedo Riquelme 05.07.2017 в 20:41
source

1 answer

1

Reading some blog and related sites I noticed the following: the dependencies cited below should not have the pom.xml because it causes a conflict, remove the dependencies and function without a call SOAP service call.

<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>jaxws-rt</artifactId>
  <version>2.2.8</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.11</version>
</dependency>
    
answered by 06.07.2017 в 16:38