简体   繁体   中英

Web Service (Server - Client). Server uses external project

I'm using a Web Service with this structure:

Server:

@WebService @HandlerChain(file="handler-chain.xml") @XmlRootElement 

public class RDA_DenegarRenovacion{

HashMapWrapper map =  new HashMapWrapper();


@WebMethod
public String getServerName() {

    return "RDA - DenegarPropuesta";

}

@WebMethod(operationName="pc_ren_propuesta")
@WebResult(name="hashMapWrapper")

public HashMapWrapper pc_ren_propuesta() {

    HashMap<String,String> realMap = new HashMap<String,String>();
    realMap.put("jaja1", "jeje1");
    realMap.put("jaja2", "jeje2");
    map.setRealMap(realMap);

    //I JUST DECLARE THE FACADE AND SERVICE FROM THE IMPORTED PROJECT, 
    //BUT I'M NOT USING THEM YET
    CommonFacade commonFacade = new CommonFacade();
    CommonDataService service = (CommonDataService) commonFacade.commonDataService;


    return map;
}

In the server method, I just access another java project in the same workspace (declaring facade and service).

In order to declare classes from another project, I configure the buildpath and I also add the jar commons-discovery-0.2, because if not, I get the error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/discovery/tools/DiscoverSingleton at com.ibm.ws.webservices.engine.components.logger.LogFactory$2.run(LogFactory.java:144) at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63) at com.ibm.ws.webservices.engine.components.logger.LogFactory.createLogFactory(LogFactory.java:140) at com.ibm.ws.webservices.engine.components.logger.LogFactory.(LogFactory.java:97) at com.ibm.ws.webservices.engine.xmlsoap.Utils.(Utils.java:49) at com.ibm.ws.webservices.engine.soap.MessageFactoryImpl.(MessageFactoryImpl.java:116) at com.ibm.ws.webservices.engine.soap.SAAJMetaFactoryImpl.newMessageFactory(SAAJMetaFactoryImpl.java:56) at javax.xml.soap.MessageFactory.newInstance(Unknown Source) at com.sun.xml.internal.ws.api.SOAPVersion.(Unknown Source) at com.sun.xml.internal.ws.api.SOAPVersion.(Unknown Source) at com.sun.xml.internal.ws.api.BindingID.(Unknown Source) at com.sun.xml.internal.ws.spi.Provide rImpl.createAndPublishEndpoint(Unknown Source) at javax.xml.ws.Endpoint.publish(Unknown Source) at RDA_DenegarRenovacion.publisher.WsPublisher.main(WsPublisher.java:14) Caused by: java.lang.ClassNotFoundException: org.apache.commons.discovery.tools.DiscoverSingleton at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) 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) ... 14 more

With all this, I publish the server part, and when running the client, due to the fact I added that external jar, I obtain the following error:

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source) at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source) at $Proxy29.pcRenPropuesta(Unknown Source) at rda_denegarrenovacion.client.WsClient.main(WsClient.java:21)

If I don't declare any class from the other project and I don't import any jar, it works fine.

Summary:

I need the following.

Client --> Server --> Informix Java project --> Server --> Client.

I'm having problems when accessing Informix Java project.

Thank you in advance

Problem solved.

I set JAVA_HOME and Path variables, and I add external wsgen jar. Restarted computer and it worked.

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