'OMException: No meta factory found for feature 'dom';
I am working on a SOAP client (Dynamic Dispatch Client) and I am running into an error when trying to execute the call after the JAR is created. I am using a shaded JAR to include all dependencies within the JAR. The odd thing is that the client works from my test class in Eclipse, however, when I deploy it to the server and try to invoke the call, I get the following error:
- org.apache.axiom.om.OMException: No meta factory found for feature 'dom'; this usually means that axiom-dom.jar is not in the classpath or that the META-INF/axiom.xml resource can't be read
This seems to happen when I invoke the call to create the message SOAPMessage request = mf.createMessage();. I took a peek inside the JAR and do see an "axiom.xml" file within the "META-INF" directory in my JAR and the following three jars are present in my Maven Dependencies in my project build path:
- axiom-dom-1.2.21.jar
- axiom-api-1.2.21.jar
- axiom-impl-1.2.21.jar
Here is the complete code for my class that is making the call to the SOAP service:
package com.waterfield.webcallback;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.SOAPBinding;
import org.apache.logging.log4j.Logger;
import com.waterfield.util.LoggerUtil;
import com.waterfield.util.PropsUtil;
public class WebCallbackClient {
private static Logger logger = LoggerUtil.getLogger();
private static final QName SERVICE_QN = new QName("http://impl.webcallback.callback.csi.avaya.com/",
"WebCallback50");
private static final QName PORT_QN = new QName("http://impl.webcallback.callback.csi.avaya.com/",
"WebCallbackWs50ImplPort");
private static final String SOAP_ENV_PREFIX = "soapenv";
private static final String MOD_NS_PREFIX = "mod";
private static final String MOD_NS_URI = "http://model.webcallback.callback.csi.avaya.com";
private static final String WEB_NS_PREFIX = "web";
private static final String WEB_NS_URI = "http://webcallback.callback.csi.avaya.com/";
private static final String OPERATION_LOCAL_NAME = "createImmediateWebCallbackRequest";
private static final String OPERATION_RESPONSE_NS_URI = "http://model.webcallback.callback.csi.avaya.com";
private static final String OPERATION_RESPONSE_LOCAL_NAME = "requestId";
private static final String WSSE_PREFIX = "wsse";
private static final String WSSE_AUTHTYPE_LOCAL_NAME = "UsernameToken";
private static final String WSSE_UNAME_LOCAL_NAME = "Username";
private static final String WSSE_PASSWD_LOCAL_NAME = "Password";
private static final QName WSSE_Q_NAME = new QName(
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security",
WSSE_PREFIX);
private String wsdlPath;
private PropsUtil propsUtil;
public WebCallbackClient() {
logger.traceEntry();
this.propsUtil = PropsUtil.getInstance();
this.wsdlPath = String.format("http://%s:8081/webcallback/WebCallback50?wsdl", propsUtil.getCbaIpAddress());
logger.traceExit();
}
public String createImmediateWebCallbackRequest(List<String> args) throws SOAPException, IOException {
logger.info("Entering createImmediateWebCallbackRequest");
String webCallbackRequestId = null;
SOAPMessage response = null;
try {
Service service = Service.create(SERVICE_QN);
service.addPort(PORT_QN, SOAPBinding.SOAP12HTTP_BINDING, wsdlPath);
Operation foundOp = createCreateImmediateWebCallbackOperation();
Dispatch<SOAPMessage> dispatcher = service.createDispatch(PORT_QN, SOAPMessage.class, Service.Mode.MESSAGE);
MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage request = mf.createMessage();
SOAPPart part = request.getSOAPPart();
SOAPEnvelope env = part.getEnvelope();
SOAPHeader header = env.getHeader();
SOAPBody body = env.getBody();
SOAPHeaderElement securityParent = header.addHeaderElement(WSSE_Q_NAME);
SOAPElement securityChild = securityParent.addChildElement(WSSE_AUTHTYPE_LOCAL_NAME, WSSE_PREFIX);
securityChild.addChildElement(WSSE_UNAME_LOCAL_NAME, WSSE_PREFIX).setTextContent(propsUtil.getCbaApiUser());
securityChild.addChildElement(WSSE_PASSWD_LOCAL_NAME, WSSE_PREFIX)
.setTextContent(propsUtil.getCbaApiUserPassword());
env.removeNamespaceDeclaration(env.getPrefix());
env.setPrefix(SOAP_ENV_PREFIX);
env.addNamespaceDeclaration(MOD_NS_PREFIX, MOD_NS_URI);
env.addNamespaceDeclaration(WEB_NS_PREFIX, WEB_NS_URI);
env.removeNamespaceDeclaration("env");
header.setPrefix(SOAP_ENV_PREFIX);
body.setPrefix(SOAP_ENV_PREFIX);
SOAPElement operation = body.addChildElement(OPERATION_LOCAL_NAME, WEB_NS_PREFIX);
int argrIndex = 0;
for (String arg : foundOp.getParameterNames()) {
SOAPElement value = operation.addChildElement(arg, WEB_NS_PREFIX);
value.setTextContent(args.get(argrIndex));
argrIndex++;
}
request.saveChanges();
response = dispatcher.invoke(request);
if (response != null) {
webCallbackRequestId = getCallbackRequestIdFromResponse(response.getSOAPBody());
}
} catch (WebServiceException e) {
logger.error(e);
} catch (SOAPException e) {
logger.error(e);
}
return webCallbackRequestId;
}
public String getCallbackRequestIdFromResponse(SOAPElement body) {
for (Iterator<?> iterator = body.getChildElements(); iterator.hasNext();) {
Object child = iterator.next();
if (child instanceof SOAPElement) {
SOAPElement elem = (SOAPElement) child;
if (elem.getElementName().toString().contains("requestId")) {
return elem.getTextContent();
}
getCallbackRequestIdFromResponse((SOAPElement) elem);
}
}
return null;
}
private Operation createCreateImmediateWebCallbackOperation() {
List<String> params = new ArrayList<String>();
params.add("configurationId");
params.add("phoneNumber");
params.add("timeZone");
return new Operation(OPERATION_LOCAL_NAME, params);
}
}
Has anyone else run into this issue? I can not figure it out for the life of me. I will admit I am not extremely familiar with interacting with SOAP services. Any pointers or suggestions on how to resolve this is greatly appreciated.
Thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
