2017-06-29 4 views
0

Ich habe WSDL-Datei verwendet, um Java-Klassen zu generieren, aber ich kann nicht MarkLogic-Client in Endpunkt erstellen (es NoClassFound-Ausnahme ausgelöst).ClassNotFount-Ausnahme beim Erstellen von MarkLogic-Client in Java WebService

Endpoint Code:

/** 
* Please modify this class to meet your needs 
* This class is not complete 
*/ 

package yu.ac.ns.ftn.informatika.ws.hello; 

import java.util.logging.Logger; 

import yu.ac.ns.ftn.informatika.ws.hello.types.RequestMissType; 

import com.marklogic.client.DatabaseClient; 
import com.marklogic.client.DatabaseClientFactory; 
import com.marklogic.client.DatabaseClientFactory.Authentication; 

/** 
* This class was generated by Apache CXF 2.1.3 
* Fri Jan 23 09:13:16 CET 2009 
* Generated source version: 2.1.3 
* 
*/ 
@javax.ejb.Stateless 
@javax.jws.WebService(
    serviceName = "HelloDocumentService", 
    portName = "HelloDocumentPort", 
    targetNamespace = "http://informatika.ftn.ns.ac.yu/ws/hello", 
    endpointInterface = "yu.ac.ns.ftn.informatika.ws.hello.HelloDocument") 

public class HelloDocumentImpl implements HelloDocument { 

private static final Logger LOG = 
Logger.getLogger(HelloDocumentImpl.class.getName()); 

/* (non-Javadoc) 
* @see 
yu.ac.ns.ftn.informatika.ws.hello.HelloDocument#sayHelloMiss 
(yu.ac.ns.ftn.informatika.ws.hello.types.RequestMissType requestMiss)* 
*/ 


public java.lang.String sayHelloMiss(RequestMissType requestMiss) { 
    LOG.info("Executing operation sayHelloMiss"); 
    System.out.println(requestMiss); 

    DatabaseClient client = 
     DatabaseClientFactory.newClient(
      "localhost", 8000, 
      new DatabaseClientFactory.DigestAuthContext("user1", "user1")); 
    System.out.println(client); 



    return "Hello miss " + requestMiss.getFirstName() + " " + requestMiss.getLastName(); 
} 

} 

Client-Code:

package yu.ac.ns.ftn.informatika.ws.client; 
import java.net.MalformedURLException; 
import java.net.URL; 

import javax.xml.namespace.QName; 
import javax.xml.ws.Service; 

import yu.ac.ns.ftn.informatika.ws.hello.HelloDocument; 
import yu.ac.ns.ftn.informatika.ws.hello.HelloDocumentService; 
import yu.ac.ns.ftn.informatika.ws.hello.types.RequestMissType; 

public class HelloClient { 

    public void testIt1() { 

     try { 
      URL wsdlLocation = new URL("http://localhost:8080/vezbe-wsdl-ws/services/HelloDocument?wsdl"); 
      QName serviceName = new QName("http://informatika.ftn.ns.ac.yu/ws/hello", "HelloDocumentService"); 
      QName portName = new QName("http://informatika.ftn.ns.ac.yu/ws/hello", "HelloDocumentPort"); 

      Service service = Service.create(wsdlLocation, serviceName); 

      HelloDocument hello = service.getPort(portName, HelloDocument.class); 

      RequestMissType request = new RequestMissType(); 
      request.setFirstName("Dijana"); 
      request.setLastName("Ninkovic"); 

      String response = hello.sayHelloMiss(request); 
      System.out.println("Response from WS: " + response); 

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

    public static void main(String[] args) { 

     HelloClient client = new HelloClient(); 
     client.testIt1(); 
    } 

} 

Wenn ich Code löschen für die Erstellung alles Marklogic Client funktioniert gut.

Apache tomee Ausnahme:

org.apache.catalina.LifecycleException: Failed to start component 
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/vezbe-wsdl-ws]] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) 
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) 
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963) 
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.NoClassDefFoundError: com/marklogic/client/DatabaseClientFactory$SecurityContext 
    at java.lang.Class.getDeclaredMethods0(Native Method) 
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source) 
    at java.lang.Class.privateGetPublicMethods(Unknown Source) 
    at java.lang.Class.getMethods(Unknown Source) 
    at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.processApplicationExceptions(AnnotationDeployer.java:2657) 
    at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:2176) 
    at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:1662) 
    at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:335) 
    at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:363) 
    at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:850) 
    at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:791) 
    at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:746) 
    at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118) 
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 10 more 
Caused by: java.lang.ClassNotFoundException: com.marklogic.client.DatabaseClientFactory$SecurityContext 
    at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:114) 
    at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:66) 
    ... 27 more 
Caused by: java.io.IOException: Stream closed 
    at java.io.BufferedInputStream.getInIfOpen(Unknown Source) 
    at java.io.BufferedInputStream.fill(Unknown Source) 
    at java.io.BufferedInputStream.read1(Unknown Source) 
    at java.io.BufferedInputStream.read(Unknown Source) 
    at java.io.FilterInputStream.read(Unknown Source) 
    at org.apache.openejb.loader.IO.copy(IO.java:279) 
    at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:111) 
    ... 28 more 
+0

Gibt es eine Chance, dass Sie zwei Versionen von Java-Client-API-Jar auf dem Klassenpfad haben? Ich frage, weil DatabaseClientFactory $ SecurityContext in Version 4.0.1 neu ist, also vielleicht 3.0.x auf dem Klassenpfad verursachen könnte. –

Antwort

0

Es sieht aus wie Sie einige Gläser fehlen, während die Anwendung bereitstellen. Bitte stellen Sie sicher, dass Ihre build.xml-Konfiguration so eingestellt ist, dass sie alle benötigten marklogic-Dateien bereitstellt.

<target name="war" depends="compile"> 
    <delete file="${war.name}"/> 
    <war warfile="${dist.dir}/${war.name}" webxml="${webinf.dir}/web.xml"> 
     <classes dir="${bin.dir}"> 
      <exclude name="**/client/*.class"/> 
      <include name="**/*.class"/> 
     </classes> 
     <lib dir="${lib.dir}"> 
      <include name="*.jar"/> 
     </lib> 
     <webinf dir="${webinf.dir}"> 
      <include name="wsdl/**"/> 
      <include name="cxf-servlet.xml"/> 
     </webinf> 
    </war> 
</target> 

Viel Glück!

Verwandte Themen