使用 Cloud SDK 为 S4HANA BAPI 调用定义 SCP 目标
Define SCP destination for S4HANA BAPI call with Cloud SDK
我正在寻找一种在本地和使用 Cloud SDK 在 SAP Cloud Platform 上调用 S4HANA 内部部署 BAPI 的方法。问题是如何像 HTTP 那样定义 RFC 目的地。
我也遇到了 JCo class not found 异常,找不到合适的解决方法。
本地
在 HTTP 目标中,我可以提供如下环境变量:
set destinations=[{name: "destName", url: "URL", username: "username", password: "password"}]
但不清楚如何定义 RFC 目标,哪些属性像 jco 属性一样是强制性的。
SCP Cloud Foundry
我在 SAP Cloud Platform 上创建了一个 RFC 目标。
但是我找不到一种方法来修饰这个目的地,使其像 HTTP 目的地一样涉及 Cloud SDK 中的其他属性。
Destination destination = DestinationAccessor.getDestination(destName);
destination.asHttp().decorate(DefaultErpHttpDestination::new);
请注意,当我调用 bapi 时,RfcDestination 是不可接受的,只需要类型 Destination。 RfcDestination 不是接口 Destination 的实现 class。
JCOClass未发现异常
java.lang.NoClassDefFoundError: com/sap/conn/jco/JCo
将 SAP Java 构建包与 Spring 引导一起使用时存在一个已知问题。我将 jar 文件 sapjco3.jar 手动添加到项目 class 路径。但它仍然没有用。
https://answers.sap.com/questions/12935437/call-op-bapi-using-cloud-sdk.html
更新
JCO Class 运行 时间未发现异常
- 你是对的。我在SCP上部署了应用程序,然后调用我提供的rest API来调用S4HANA On-premise系统的BAPI。然后我在 运行 时间得到了这个异常。
- 我正在使用 Spring 引导应用程序。
- Spring 引导项目由 SAP Cloud SDK spring 原型生成。
- 请查看下面的错误堆栈跟踪。
- 右键单击我的项目 -> 构建路径 -> 配置构建路径 -> 选择库选项卡 -> 添加外部 jars
- 我将我的应用部署为 Jar 文件。
异常堆栈跟踪
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/sap/conn/jco/JCoException
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.lambda$doFilter(RequestAccessorFilter.java:71)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.lambda$execute[=12=](AbstractThreadContextExecutor.java:317)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextCallable.call(ThreadContextCallable.java:247)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.execute(AbstractThreadContextExecutor.java:319)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.doFilter(RequestAccessorFilter.java:71)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at java.lang.Thread.run(Thread.java:836)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR Caused by: java.lang.NoClassDefFoundError: com/sap/conn/jco/JCoException
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiTransactionFactory.createJCoTransaction(BapiTransactionFactory.java:33)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.AbstractTransactionFactory.createTransaction(AbstractTransactionFactory.java:39)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.RemoteFunctionRequestExecutor.execute(RemoteFunctionRequestExecutor.java:41)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiRequest.execute(BapiRequest.java:79)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.bosch.test.service.CostCenterBapiService.getCostCenters(CostCenterBapiService.java:48)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at com.bosch.test.controllers.CostCenterBapiController.getCostCenterBapi(CostCenterBapiController.java:23)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at java.lang.reflect.Method.invoke(Method.java:498)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR ... 47 more
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR Caused by: java.lang.ClassNotFoundException: com.sap.conn.jco.JCoException
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.findClass(URLClassLoader.java:444)
2020-04-09T01:55:46.224+0000 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.loadClass(ClassLoader.java:480)
2020-04-09T01:55:46.224+0000 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:92)
2020-04-09T01:55:46.224+0000 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.loadClass(ClassLoader.java:413)
2020-04-09T01:55:46.224+0000 [APP/PROC/WEB/0] ERR ... 64 more
我想强调的一件事是 SAP 提供的官方文档说“无法将 SAP Java 连接器与 Spring 启动应用程序一起使用".
SAP Java 具有非 spring 启动应用程序的连接器
我基于 SAP Cloud SDK 原型 scp-cf-tomee 创建了一个新项目并尝试调用 bapi。我认为 JCo 问题已经解决,但在调用 Bapi 时我得到了一个新的异常 "User Information is not set"。有人有类似的问题,但似乎还没有解决方案。
https://answers.sap.com/questions/12969692/getting-access-to-the-sap-java-connector-in-cloud.html
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR java.lang.IllegalStateException: User information is not set.
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.security.UserInfoHolder.getUserInfo(UserInfoHolder.java:48)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.core.connectivity.jco.kotyo.cf.auth.CFTenantProvider.getCurrentTenant(CFTenantProvider.java:21)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.conn.jco.rt.TenantContextManager.getTenantContext(TenantContextManager.java:36)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.conn.jco.rt.DefaultDestinationManager.searchDestination(DefaultDestinationManager.java:376)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.conn.jco.rt.DefaultDestinationManager.getDestinationInstance(DefaultDestinationManager.java:109)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:56)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.JCoTransaction.<init>(JCoTransaction.java:99)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiTransactionFactory.createJCoTransaction(BapiTransactionFactory.java:33)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.AbstractTransactionFactory.createTransaction(AbstractTransactionFactory.java:39)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.RemoteFunctionRequestExecutor.execute(RemoteFunctionRequestExecutor.java:41)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiRequest.execute(BapiRequest.java:79)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.bosch.bapi.service.CostCenterBapiService.getCostCenters(CostCenterBapiService.java:44)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.bosch.bapi.CostCenterBapiServlet.doGet(CostCenterBapiServlet.java:30)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.lambda$doFilter(RequestAccessorFilter.java:71)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.lambda$execute[=13=](AbstractThreadContextExecutor.java:317)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextCallable.call(ThreadContextCallable.java:247)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.execute(AbstractThreadContextExecutor.java:319)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.doFilter(RequestAccessorFilter.java:71)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.security.servlet.HttpCachingHeaderFilter.doFilter(HttpCachingHeaderFilter.java:83)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.security.servlet.HttpSecurityHeadersFilter.doFilter(HttpSecurityHeadersFilter.java:41)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.filters.RestCsrfPreventionFilter.doFilter(RestCsrfPreventionFilter.java:125)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke(OpenEJBSecurityListener.java:97)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.java.valves.ErrorReportValve.invoke(ErrorReportValve.java:66)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:256)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.security.TenantIdValve.invoke(TenantIdValve.java:33)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.security.UserInfoValve.invoke(UserInfoValve.java:19)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:43)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.logging.catalina.RuntimeInfoValve.invoke(RuntimeInfoValve.java:40)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at java.lang.Thread.run(Thread.java:836)
装饰目的地
我同意你的解释。也许不需要将其作为 Http 目的地。但由于 SAP Java 连接器问题,我被卡住了。
本地 RFC 目标定义
其实我不知道RFC目标需要什么属性。如果我只使用 HTTP,我会得到 HTTP 状态 404 和服务未找到异常。
感谢您在这里提出这个问题。我可以确定您问题中的不同方面,因此在下文中分别讨论它们。
JCO Class 未发现异常
请提供有关以下问题的更多信息:
- 我了解到您在将应用程序部署到 SCP 后在运行时收到
java.lang.NoClassDefFoundError: com/sap/conn/jco/JCo
。我的理解正确吗?
- 我了解到您使用 Spring 启动应用程序,对吗?
- 您使用过 SAP Cloud SDK 原型吗?
- 请在此处附上申请日志以供进一步参考。
- 您能否详细说明您是如何将 sapjco3.jar 添加到项目类路径的?
- 您将应用部署为 jar 还是 war?
通过环境变量创建 RFC 目标
我了解到您很难理解如何在环境变量中指定 RFC 目标。请问您已经试过分别面临哪些具体问题(报错信息等)?
无法修饰 RFC 目标以涉及其他属性
您正确地指出,考虑到 HTTP 目标上的附加属性,SAP Cloud SDK 能够丰富请求 headers。因此,您需要像这样装饰 HttpDestination
实例:
Destination destination = DestinationAccessor.getDestination(destName);
destination.asHttp().decorate(DefaultErpHttpDestination::new);
我理解您的问题,同样适用于 RFC 目标。据我判断,SAP 提供的 Java 连接器 (JCO) 库无论如何都会查看目标属性。因此,我认为在 RFC 目标领域没有必要这样做。如果您不同意,请您更准确地概述您的要求。
BapiRequest 接受 Destination,而不是 RfcDestination
我理解你的问题,你对 BapiRequest::execute
确实期望 Destination
而不是 RfcDestination
感到惊讶。乍一看这确实令人惊讶,但是,这是有意为之的,因为 SAP Cloud SDK 还支持调用包装为 SOAP API 的 BAPI。这通过 HttpDestination
起作用。对于您的具体用例,使用 DestinationAccessor.getDestination("xyz")
并将该 return 值传递给 execute
方法就足够了。您无需担心其他任何事情。
更新:查看最新的SAP Cloud SDK documentation on BAPI calls。
感谢更新。根据您在原始问题中更新的信息进行回答。再次检查每个单独的标题。
JCO Class 运行 时间未发现异常
Java 连接器的用法仅在使用 Spring 的“传统部署”时可用,其中涉及构建和部署 war 文件而不是 jar 文件。
SAP Java 带有非 spring 启动应用程序的连接器
Java 连接器的使用需要有一个受保护的后端和一个应用路由器。我假设您不使用它,错误消息 User Information is not set
.
表明了这一点
装饰目的地
已回答
本地 RFC 目标定义
据我所知,无法预见在本地部署中使用 Java 连接器。为此,您必须将应用程序部署到 SAP Cloud Platform。
关于在 RFC 目标上设置哪些属性的问题,您可以参考 JavaJava class DestinationDataProvider
的文档,您可以在下载后从 JCo 存档中提取来自 https://support.sap.com/jco
我正在寻找一种在本地和使用 Cloud SDK 在 SAP Cloud Platform 上调用 S4HANA 内部部署 BAPI 的方法。问题是如何像 HTTP 那样定义 RFC 目的地。
我也遇到了 JCo class not found 异常,找不到合适的解决方法。
本地
在 HTTP 目标中,我可以提供如下环境变量:
set destinations=[{name: "destName", url: "URL", username: "username", password: "password"}]
但不清楚如何定义 RFC 目标,哪些属性像 jco 属性一样是强制性的。
SCP Cloud Foundry
我在 SAP Cloud Platform 上创建了一个 RFC 目标。
Destination destination = DestinationAccessor.getDestination(destName);
destination.asHttp().decorate(DefaultErpHttpDestination::new);
请注意,当我调用 bapi 时,RfcDestination 是不可接受的,只需要类型 Destination。 RfcDestination 不是接口 Destination 的实现 class。
JCOClass未发现异常
java.lang.NoClassDefFoundError: com/sap/conn/jco/JCo
将 SAP Java 构建包与 Spring 引导一起使用时存在一个已知问题。我将 jar 文件 sapjco3.jar 手动添加到项目 class 路径。但它仍然没有用。
https://answers.sap.com/questions/12935437/call-op-bapi-using-cloud-sdk.html
更新
JCO Class 运行 时间未发现异常
- 你是对的。我在SCP上部署了应用程序,然后调用我提供的rest API来调用S4HANA On-premise系统的BAPI。然后我在 运行 时间得到了这个异常。
- 我正在使用 Spring 引导应用程序。
- Spring 引导项目由 SAP Cloud SDK spring 原型生成。
- 请查看下面的错误堆栈跟踪。
- 右键单击我的项目 -> 构建路径 -> 配置构建路径 -> 选择库选项卡 -> 添加外部 jars
- 我将我的应用部署为 Jar 文件。
异常堆栈跟踪
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/sap/conn/jco/JCoException
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.lambda$doFilter(RequestAccessorFilter.java:71)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.lambda$execute[=12=](AbstractThreadContextExecutor.java:317)
2020-04-09T01:55:46.220+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextCallable.call(ThreadContextCallable.java:247)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.execute(AbstractThreadContextExecutor.java:319)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.doFilter(RequestAccessorFilter.java:71)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
2020-04-09T01:55:46.221+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at java.lang.Thread.run(Thread.java:836)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR Caused by: java.lang.NoClassDefFoundError: com/sap/conn/jco/JCoException
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiTransactionFactory.createJCoTransaction(BapiTransactionFactory.java:33)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.AbstractTransactionFactory.createTransaction(AbstractTransactionFactory.java:39)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.RemoteFunctionRequestExecutor.execute(RemoteFunctionRequestExecutor.java:41)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiRequest.execute(BapiRequest.java:79)
2020-04-09T01:55:46.222+0000 [APP/PROC/WEB/0] ERR at com.bosch.test.service.CostCenterBapiService.getCostCenters(CostCenterBapiService.java:48)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at com.bosch.test.controllers.CostCenterBapiController.getCostCenterBapi(CostCenterBapiController.java:23)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at java.lang.reflect.Method.invoke(Method.java:498)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR ... 47 more
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR Caused by: java.lang.ClassNotFoundException: com.sap.conn.jco.JCoException
2020-04-09T01:55:46.223+0000 [APP/PROC/WEB/0] ERR at java.net.URLClassLoader.findClass(URLClassLoader.java:444)
2020-04-09T01:55:46.224+0000 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.loadClass(ClassLoader.java:480)
2020-04-09T01:55:46.224+0000 [APP/PROC/WEB/0] ERR at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:92)
2020-04-09T01:55:46.224+0000 [APP/PROC/WEB/0] ERR at java.lang.ClassLoader.loadClass(ClassLoader.java:413)
2020-04-09T01:55:46.224+0000 [APP/PROC/WEB/0] ERR ... 64 more
我想强调的一件事是 SAP 提供的官方文档说“无法将 SAP Java 连接器与 Spring 启动应用程序一起使用".
SAP Java 具有非 spring 启动应用程序的连接器
我基于 SAP Cloud SDK 原型 scp-cf-tomee 创建了一个新项目并尝试调用 bapi。我认为 JCo 问题已经解决,但在调用 Bapi 时我得到了一个新的异常 "User Information is not set"。有人有类似的问题,但似乎还没有解决方案。
https://answers.sap.com/questions/12969692/getting-access-to-the-sap-java-connector-in-cloud.html
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR java.lang.IllegalStateException: User information is not set.
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.security.UserInfoHolder.getUserInfo(UserInfoHolder.java:48)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.core.connectivity.jco.kotyo.cf.auth.CFTenantProvider.getCurrentTenant(CFTenantProvider.java:21)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.conn.jco.rt.TenantContextManager.getTenantContext(TenantContextManager.java:36)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.conn.jco.rt.DefaultDestinationManager.searchDestination(DefaultDestinationManager.java:376)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.conn.jco.rt.DefaultDestinationManager.getDestinationInstance(DefaultDestinationManager.java:109)
2020-04-09T02:25:37.146+0000 [APP/PROC/WEB/0] ERR at com.sap.conn.jco.JCoDestinationManager.getDestination(JCoDestinationManager.java:56)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.JCoTransaction.<init>(JCoTransaction.java:99)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiTransactionFactory.createJCoTransaction(BapiTransactionFactory.java:33)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.AbstractTransactionFactory.createTransaction(AbstractTransactionFactory.java:39)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.RemoteFunctionRequestExecutor.execute(RemoteFunctionRequestExecutor.java:41)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiRequest.execute(BapiRequest.java:79)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.bosch.bapi.service.CostCenterBapiService.getCostCenters(CostCenterBapiService.java:44)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.bosch.bapi.CostCenterBapiServlet.doGet(CostCenterBapiServlet.java:30)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.lambda$doFilter(RequestAccessorFilter.java:71)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.lambda$execute[=13=](AbstractThreadContextExecutor.java:317)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextCallable.call(ThreadContextCallable.java:247)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.execute(AbstractThreadContextExecutor.java:319)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.doFilter(RequestAccessorFilter.java:71)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.security.servlet.HttpCachingHeaderFilter.doFilter(HttpCachingHeaderFilter.java:83)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at com.sap.cloud.sdk.cloudplatform.security.servlet.HttpSecurityHeadersFilter.doFilter(HttpSecurityHeadersFilter.java:41)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.filters.RestCsrfPreventionFilter.doFilter(RestCsrfPreventionFilter.java:125)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
2020-04-09T02:25:37.147+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomee.catalina.OpenEJBSecurityListener$RequestCapturer.invoke(OpenEJBSecurityListener.java:97)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.java.valves.ErrorReportValve.invoke(ErrorReportValve.java:66)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:256)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.security.TenantIdValve.invoke(TenantIdValve.java:33)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.security.UserInfoValve.invoke(UserInfoValve.java:19)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:43)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at com.sap.xs.logging.catalina.RuntimeInfoValve.invoke(RuntimeInfoValve.java:40)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2020-04-09T02:25:37.148+0000 [APP/PROC/WEB/0] ERR at java.lang.Thread.run(Thread.java:836)
装饰目的地
我同意你的解释。也许不需要将其作为 Http 目的地。但由于 SAP Java 连接器问题,我被卡住了。
本地 RFC 目标定义
其实我不知道RFC目标需要什么属性。如果我只使用 HTTP,我会得到 HTTP 状态 404 和服务未找到异常。
感谢您在这里提出这个问题。我可以确定您问题中的不同方面,因此在下文中分别讨论它们。
JCO Class 未发现异常
请提供有关以下问题的更多信息:
- 我了解到您在将应用程序部署到 SCP 后在运行时收到
java.lang.NoClassDefFoundError: com/sap/conn/jco/JCo
。我的理解正确吗? - 我了解到您使用 Spring 启动应用程序,对吗?
- 您使用过 SAP Cloud SDK 原型吗?
- 请在此处附上申请日志以供进一步参考。
- 您能否详细说明您是如何将 sapjco3.jar 添加到项目类路径的?
- 您将应用部署为 jar 还是 war?
通过环境变量创建 RFC 目标
我了解到您很难理解如何在环境变量中指定 RFC 目标。请问您已经试过分别面临哪些具体问题(报错信息等)?
无法修饰 RFC 目标以涉及其他属性
您正确地指出,考虑到 HTTP 目标上的附加属性,SAP Cloud SDK 能够丰富请求 headers。因此,您需要像这样装饰 HttpDestination
实例:
Destination destination = DestinationAccessor.getDestination(destName);
destination.asHttp().decorate(DefaultErpHttpDestination::new);
我理解您的问题,同样适用于 RFC 目标。据我判断,SAP 提供的 Java 连接器 (JCO) 库无论如何都会查看目标属性。因此,我认为在 RFC 目标领域没有必要这样做。如果您不同意,请您更准确地概述您的要求。
BapiRequest 接受 Destination,而不是 RfcDestination
我理解你的问题,你对 BapiRequest::execute
确实期望 Destination
而不是 RfcDestination
感到惊讶。乍一看这确实令人惊讶,但是,这是有意为之的,因为 SAP Cloud SDK 还支持调用包装为 SOAP API 的 BAPI。这通过 HttpDestination
起作用。对于您的具体用例,使用 DestinationAccessor.getDestination("xyz")
并将该 return 值传递给 execute
方法就足够了。您无需担心其他任何事情。
更新:查看最新的SAP Cloud SDK documentation on BAPI calls。
感谢更新。根据您在原始问题中更新的信息进行回答。再次检查每个单独的标题。
JCO Class 运行 时间未发现异常
Java 连接器的用法仅在使用 Spring 的“传统部署”时可用,其中涉及构建和部署 war 文件而不是 jar 文件。
SAP Java 带有非 spring 启动应用程序的连接器
Java 连接器的使用需要有一个受保护的后端和一个应用路由器。我假设您不使用它,错误消息 User Information is not set
.
装饰目的地
已回答
本地 RFC 目标定义
据我所知,无法预见在本地部署中使用 Java 连接器。为此,您必须将应用程序部署到 SAP Cloud Platform。
关于在 RFC 目标上设置哪些属性的问题,您可以参考 JavaJava class DestinationDataProvider
的文档,您可以在下载后从 JCo 存档中提取来自 https://support.sap.com/jco