简体   繁体   中英

java.lang.NoClassDefFoundError: org/apache/cxf/service/invoker/Invoker

Does anyone know how to fix this? I created a client to consume a webservice. The client code is:

package cliente;

import java.util.List;

import handler.HeaderHandler;
import webservice.BoletinOficial;
import webservice.BoletinOficialService;
import petanuncio.PeticionAnuncio;
import respanuncio.RespuestaAnuncio;

import org.apache.cxf.jaxws.binding.DefaultBindingImpl;

import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
import java.util.ArrayList;


public class Cliente {

/**
 * Main
 * @param args
 */
 @SuppressWarnings("rawtypes")
public static void main(String[] args) {

  String endpointURL = "";
  try {


       BoletinOficialService service = new BoletinOficialService();

       BoletinOficial proxy = service.getBoletinOficialSoap11();


//rest of code

  } catch (Exception e) {
   e.printStackTrace();
  }
 }

The problem is when running the program and get the following error anc cannot even create "service":

 Exception in thread "main" java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider org.apache.cxf.jaxws.spi.ProviderImpl could not be instantiated
    at java.util.ServiceLoader.fail(Unknown Source)
    at java.util.ServiceLoader.access$100(Unknown Source)
    at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source)
    at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
    at java.util.ServiceLoader$1.next(Unknown Source)
    at javax.xml.ws.spi.Provider.getProviderUsingServiceLoader(Unknown Source)
    at javax.xml.ws.spi.Provider.provider(Unknown Source)
    at javax.xml.ws.Service.<init>(Unknown Source)
    at webservice.BoletinOficialService.<init>(BoletinOficialService.java:46)
    at cliente.Cliente.main(Cliente.java:35)
Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/service/invoker/Invoker
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    ... 8 more
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.service.invoker.Invoker
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 12 more

This class and others were created via wsimport from a wsdl file, althoug I don't think this is related to the error I am getting. The class org.apache.cxf.jaxws.spi.ProviderImpl is in cxf-rt-frontend-jaxws-3.1.1.jar file whis is added as referece to the project.

这是项目结构

这些是图书馆

Is there anything I am missing? Thank you in advance.

Invoker is part of the CXF API. Looks like the cxf-api is missing.

If you use maven, add the dependency :

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-api</artifactId>
    <version>YOUR_VERSION</version>
</dependency>

Else add the jar to your classpath.

Add the compile dependencies you find at https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws/3.1.1

Better, switch to Maven.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM