Я занимаюсь разработкой REST-сервисов в Spring Boot, в которых мне нужно загружать данные на сервер Oracle Fusion с использованием предоставляемых им SOAP-сервисов. Приложение отлично работает на сервере Tomcat, но при развертывании на Weblogic я сталкиваюсь с исключением приведения класса.
HCMDataLoader loaderPort = getHcmDataLoaderPort(hcmDataLoader);
BindingProvider wsbp = (BindingProvider) loaderPort;
Binding binding = wsbp.getBinding();
List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(new SoapHandler());
binding.setHandlerChain(handlerChain);
Map<String, Object> requestContext = wsbp.getRequestContext();
requestContext.put("javax.xml.ws.security.auth.username", username);
requestContext.put("javax.xml.ws.security.auth.password", password);
String parameters = "ImportMaximumErrors=100,LoadMaximumErrors=100,LoadConcurrentThreads=4,DeleteSourceFile=N";
contentIdValue = loaderPort.importAndLoadData(contentId.trim(), parameters);
public static HCMDataLoader getHcmDataLoaderPort(String dataLoaderUrl) throws Exception {
try {
if (hcmDataLoaderPort != null) {
return hcmDataLoaderPort;
} else {
URL url = new URL(dataLoaderUrl);
hcmDataLoaderService = new HCMDataLoader_Service(url,
new QName(
"http://xmlns.oracle.com/apps/hcm/common/dataLoader/core/dataLoaderIntegrationService/",
"HCMDataLoader"));
SecurityPolicyFeature[] m_securityFeature = new SecurityPolicyFeature[] {
new SecurityPolicyFeature("oracle/wss_username_token_over_ssl_client_policy") };
hcmDataLoaderPort = hcmDataLoaderService.getHCMDataLoaderSoapHttpPort(m_securityFeature);
return hcmDataLoaderPort;
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
Ниже приведена трассировка стека, которую я получаю, когда запускаю этот код на сервере Weblogic.
java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl cannot be cast to oracle.j2ee.ws.saaj.soap.SOAPDoc
at weblogic.wsee.jaxws.WLSContainer$WLSSAAJFactory.readAsSAAJ(WLSContainer.java:1061)
at com.sun.xml.ws.api.message.saaj.SAAJFactory.read(SAAJFactory.java:208)
at com.sun.xml.ws.message.AbstractMessageImpl.toSAAJ(AbstractMessageImpl.java:236)
at com.sun.xml.ws.api.message.MessageWrapper.readAsSOAPMessage(MessageWrapper.java:176)
at com.sun.xml.ws.handler.SOAPMessageContextImpl.getMessage(SOAPMessageContextImpl.java:85)
at weblogic.wsee.jaxws.framework.jaxrpc.SOAPMessageContext.getMessage(SOAPMessageContext.java:260)
at weblogic.wsee.security.wssp.handlers.WssHandler.getSecurityContext(WssHandler.java:321)
at weblogic.wsee.security.wssp.handlers.WssHandler.setupSecurityContext(WssHandler.java:291)
at weblogic.wsee.security.wssp.handlers.WssHandler.getSecurityPolicyDriver(WssHandler.java:270)
at weblogic.wsee.security.wssp.handlers.WssClientHandler.processRequest(WssClientHandler.java:66)
at weblogic.wsee.security.wssp.handlers.WssHandler.handleRequest(WssHandler.java:112)
at weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory$JAXRPCTube.processRequest(TubeFactory.java:234)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
at com.sun.xml.ws.client.Stub.process(Stub.java:463)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:191)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161)
at com.sun.proxy.$Proxy474.importAndLoadData(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler.invoke(ClientInstanceInvocationHandler.java:147)
at com.sun.proxy.$Proxy475.importAndLoadData(Unknown Source)
at com.payslip.util.elemententry.beans.UploadToUcmBean.processFileFromUCM_HDLService(UploadToUcmBean.java:203)
at com.payslip.util.elemententry.beans.UploadToUcmBean.beginUploadToUCM(UploadToUcmBean.java:293)
at com.payslip.util.elemententry.beans.UploadToUcmBean.run(UploadToUcmBean.java:350)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Я не думаю, что есть какие-либо проблемы с реализацией, поскольку то же приложение работает нормально при развертывании на Tomcat, но не работает при работе на Weblogic.
--------------------------
РЕДАКТИРОВАТЬ: 19-04-2019
Как предложил Роман ниже, я попытался отредактировать файл weblogic.xml, теперь он выбрасывает NPE.
<wls:prefer-application-resources>
<wls:resource-name>javax.xml.soap.MessageFactory</wls:resource-name>
<wls:resource-name>javax.xml.soap.MetaFactory</wls:resource-name>
<wls:resource-name>javax.xml.soap.SOAPConnectionFactory</wls:resource-name>
<wls:resource-name>javax.xml.soap.SOAPFactory</wls:resource-name>
</wls:prefer-application-resources>
После добавления я получаю нулевой указатель.
java.lang.NullPointerException
at weblogic.wsee.security.saml.SAMLTrustCredentialProvider.getCredentialFromRSTR(SAMLTrustCredentialProvider.java:784)
at weblogic.wsee.security.saml.SAMLTrustCredentialProvider.createCredential(SAMLTrustCredentialProvider.java:727)
at weblogic.wsee.security.saml.SAMLTrustCredentialProvider.getCredentialSTSCSS(SAMLTrustCredentialProvider.java:213)
at weblogic.wsee.security.saml.SAMLTrustCredentialProvider.getCredential(SAMLTrustCredentialProvider.java:121)
at weblogic.xml.crypto.wss.WrapperCredentialProvider.getCredential(WrapperCredentialProvider.java:55)
at weblogic.xml.crypto.wss.SecurityBuilderImpl.getCredential(SecurityBuilderImpl.java:778)
at weblogic.xml.crypto.wss.SecurityBuilderImpl.getSecurityToken(SecurityBuilderImpl.java:751)
at weblogic.xml.crypto.wss.SecurityBuilderImpl.addSecurityToken(SecurityBuilderImpl.java:287)
at weblogic.wsee.security.wss.plan.SecurityMessageArchitect.doProcessIdentity(SecurityMessageArchitect.java:927)
at weblogic.wsee.security.wss.plan.SecurityMessageArchitect.processIdentity(SecurityMessageArchitect.java:893)
at weblogic.wsee.security.wss.plan.SecurityMessageArchitect.constructMessage(SecurityMessageArchitect.java:188)
at weblogic.wsee.security.wss.plan.SecurityMessageArchitect.buildWssMessage(SecurityMessageArchitect.java:141)
at weblogic.wsee.security.wss.plan.SecurityMessageArchitect.buildWssMessage(SecurityMessageArchitect.java:124)
at weblogic.wsee.security.wss.SecurityPolicyArchitect.processOutbound(SecurityPolicyArchitect.java:227)
at weblogic.wsee.security.wss.SecurityPolicyArchitect.processMessagePolicy(SecurityPolicyArchitect.java:135)
at weblogic.wsee.security.wss.SecurityPolicyConductor.processRequestOutbound(SecurityPolicyConductor.java:117)
at weblogic.wsee.security.wss.SecurityPolicyConductor.processRequestOutbound(SecurityPolicyConductor.java:89)
at weblogic.wsee.security.wssp.handlers.WssClientHandler.processOutbound(WssClientHandler.java:115)
at weblogic.wsee.security.wssp.handlers.WssClientHandler.processRequest(WssClientHandler.java:67)
at weblogic.wsee.security.wssp.handlers.WssHandler.handleRequest(WssHandler.java:112)
at weblogic.wsee.jaxws.framework.jaxrpc.TubeFactory$JAXRPCTube.processRequest(TubeFactory.java:234)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
at com.sun.xml.ws.client.Stub.process(Stub.java:463)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:191)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161)
at com.sun.proxy.$Proxy474.importAndLoadData(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler.invoke(ClientInstanceInvocationHandler.java:147)
at com.sun.proxy.$Proxy475.importAndLoadData(Unknown Source)
at com.payslip.util.elemententry.beans.UploadToUcmBean.processFileFromUCM_HDLService(UploadToUcmBean.java:203)
at com.payslip.util.elemententry.beans.UploadToUcmBean.beginUploadToUCM(UploadToUcmBean.java:293)
at com.payslip.util.elemententry.beans.UploadToUcmBean.run(UploadToUcmBean.java:350)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)