RFC Destination does not exist - s4sdk

I'm trying to configure an application running in Tomcat 8.5 with Neo Cloud SDK 3.54.23 to connect to an RFC destination and run the following code:
String destinationName = "RFCQueryEndpoint";
ErpConfigContext erpConfigContext = new ErpConfigContext(destinationName);
ErpEndpoint endpoint = new ErpEndpoint(erpConfigContext);
response.getWriter().write(new Gson().toJson(new
DefaultFinancialTransactionService().getList()
.execute(endpoint).getListOfSelectedTransactions()));
I have tried multiple ways of configuring the RFC destination, but none of them worked.
I've tried setting a destinations environment variable with:
[{name: "RFCQueryEndpoint", type: "RFC", jco.client.ashost: "host-here", jco.client.client: "100", jco.client.lang: "EN", jco.client.passwd: "pass-here", jco.client.sysnr: "01", jco.client.user: "user-here"}]
I have tried configuring the destination within the server config, as explained in https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/7fa92ffa007346f58491999361928303.html
I have tried creating a file with a .jcoDestination ending and setting the property -Djco.destinations.dir=/home/cassio/jco-destinations but none of them worked.
I'm always getting:
12:20:50.040 [http-nio-8080-exec-4] ERROR - com.sap.conn.jco.JCoException: (106) JCO_ERROR_RESOURCE: Destination RFCQueryEndpoint does not exist
12:20:50.043 [http-nio-8080-exec-4] ERROR - com.sap.conn.jco.JCoException: (106) JCO_ERROR_RESOURCE: Destination RFCQueryEndpoint does not exist
com.sap.cloud.sdk.s4hana.connectivity.rfc.exception.RemoteFunctionException: com.sap.conn.jco.JCoException: (106) JCO_ERROR_RESOURCE: Destination RFCQueryEndpoint does not exist
at com.sap.cloud.sdk.s4hana.connectivity.rfc.JCoRemoteFunctionQueryExecutor.execute(JCoRemoteFunctionQueryExecutor.java:202)
at com.sap.cloud.sdk.s4hana.connectivity.rfc.JCoRemoteFunctionQueryExecutor.execute(JCoRemoteFunctionQueryExecutor.java:55)
at com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiQuery.execute(BapiQuery.java:91)
at com.sap.cloud.sdk.s4hana.datamodel.bapi.functions.DefaultFinancialTransactionGetListFunction.execute(DefaultFinancialTransactionGetListFunction.java:469)
at MyServlet.doGet(MyServlet.java:77)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.sap.cloud.sdk.cloudplatform.servlet.RequestContextServletFilter$1.execute(RequestContextServletFilter.java:219)
at com.sap.cloud.sdk.cloudplatform.servlet.Executable.call(Executable.java:23)
at com.sap.cloud.sdk.cloudplatform.servlet.Executable.call(Executable.java:13)
at com.sap.cloud.sdk.cloudplatform.servlet.RequestContextCallable.call(RequestContextCallable.java:82)
at com.sap.cloud.sdk.cloudplatform.servlet.RequestContextServletFilter.doFilter(RequestContextServletFilter.java:221)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.sap.cloud.sdk.cloudplatform.security.servlet.HttpCachingHeaderFilter.doFilter(HttpCachingHeaderFilter.java:56)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.sap.cloud.sdk.cloudplatform.security.servlet.HttpSecurityHeadersFilter.doFilter(HttpSecurityHeadersFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.filters.RestCsrfPreventionFilter.doFilter(RestCsrfPreventionFilter.java:113)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at com.sap.cloud.runtime.impl.bridge.security.AbstractAuthenticator.invoke(AbstractAuthenticator.java:206)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at com.sap.core.tenant.valve.TenantValidationValve.invokeNextValve(TenantValidationValve.java:182)
at com.sap.core.tenant.valve.TenantValidationValve.invoke(TenantValidationValve.java:97)
at com.sap.js.statistics.tomcat.valve.RequestTracingValve.callNextValve(RequestTracingValve.java:101)
at com.sap.js.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:57)
at com.sap.core.js.monitoring.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:27)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
How can I properly configure an RFC destination locally, using SAP tools for Eclipse, to connect to an S/4 Hana On-Prem system using Neo Cloud SDK + Tomcat?

I found what I believe is a workaround.
If I simply set the destination on the server configuration in Eclipse, the SDK finds the destination name but can't find the configuration.
I had to set the destination both in the server config page, as explained here: https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/7fa92ffa007346f58491999361928303.html
And I also had to create the RFCendpoint.jcoDestination file, as follows:
Name=RFCendpoint
Type=RFC
jco.client.client=100
jco.client.lang=EN
jco.client.user=User-here
jco.client.passwd=Password-here
jco.client.ashost=Host-here
jco.client.sysnr=00
jco.destination.pool_capacity=5
jco.destination.peak_limit=10
and pass the directory the file resides in via the -Djco.destinations.dir=/home/cassio/jco-destinations flag in the arguments section of my Run configuration in Eclipse.
With both of these configs I was able to get the SDK to recgonize both the endpoint name and its configuration. Then I was able to use the service as well as call other BAPIs via BapiQuery.

Related

Unable to terminate WSO2 IS sessions

I previously had issues with WSO2 IS active-sessions-limit-handler not working. It was resolved by a previous question I asked (I upgraded to 5.11.0).
Now the issue is that when I follow this guide and setup an active-sessions-limit-handler for an SP, the server knows when I exceed the limit, but it is not able to deal with the situation correctly.
I have the max number of sessions set to 2, so when I try and login with the same user for a third time WSO2 correctly knows it is now over the limit. The issue is it gives me the following screen:
When I select any of the 3 presented options, I get an Authentication Error and the login fails. If I go to the My Account page for the user I can see that the sessions are active that are expected to be.
It seems like WSO2 is unable to retrieve the active sessions. When this error happens, I also see the following error log which appears to be that WSO2 is making a call to it's own API that is being rejected as unauthorized:
java.io.IOException: Server returned HTTP response code: 401 for URL: https://HOST:9443/api/identity/auth/v1.1/context/916aff37-aaf8-464c-bede-7f249279ff1a
Do I need to configure anything differently for the API to not return a 401? I haven't been able to find any open issues that seem to be the same problem.
EDIT, adding full stacktrace:
[2020-12-16 17:49:00,105] [4e6a703b-f19a-4d27-a80e-c2f2088f7d0e] INFO {org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsLogger} - USER Has one of Roles: [admin]
[2020-12-16 17:49:00,334] [2192ca86-fc09-4767-9647-ff8ec91a6698] ERROR {org.wso2.carbon.identity.application.authentication.endpoint.util.AuthContextAPIClient} - Sending GET request to URL : https://HOST:9443/api/identity/auth/v1.1/context/1bef7d0a-5aba-4e14-a7a3-a6bb53e02a62, failed. java.io.IOException: Server returned HTTP response code: 401 for URL: https://HOST:9443/api/identity/auth/v1.1/context/1bef7d0a-5aba-4e14-a7a3-a6bb53e02a62
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1924)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
at org.wso2.carbon.identity.application.authentication.endpoint.util.AuthContextAPIClient.getContextProperties(AuthContextAPIClient.java:69)
at org.apache.jsp.handle_002dmultiple_002dsessions_jsp._jspService(handle_002dmultiple_002dsessions_jsp.java:256)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter.doFilter(ContentTypeBasedCachePreventionFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.wso2.carbon.identity.application.authentication.endpoint.util.filter.AuthenticationEndpointFilter.doFilter(AuthenticationEndpointFilter.java:190)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.wso2.carbon.identity.context.rewrite.valve.TenantContextRewriteValve.invoke(TenantContextRewriteValve.java:107)
at org.wso2.carbon.identity.cors.valve.CORSValve.invoke(CORSValve.java:98)
at org.wso2.carbon.identity.authz.valve.AuthorizationValve.invoke(AuthorizationValve.java:110)
at org.wso2.carbon.identity.auth.valve.AuthenticationValve.invoke(AuthenticationValve.java:102)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:49)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:145)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
at org.wso2.carbon.tomcat.ext.valves.RequestEncodingValve.invoke(RequestEncodingValve.java:49)
at org.wso2.carbon.tomcat.ext.valves.RequestCorrelationIdValve.invoke(RequestCorrelationIdValve.java:126)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Try the scenario by uncommenting the <context-param> block with the name AuthenticationRESTEndpointURL in <IS_HOME>/repository/deployment/server/webapps/authenticationendpoint/WEB-INF/web.xml file.
<!-- *************** Authentication REST API URL Configuration ********************** -->
<context-param>
<param-name>AuthenticationRESTEndpointURL</param-name>
<param-value>https://localhost:9443/api/identity/auth/v1.1/</param-value>
</context-param>
<!-- *************** End of Authentication REST API URL Configuration ********************** -->```

parsing HTTP request parameter

I want to pass a physical path from a file server to a web service using Spring boot Rest API
the path I want to send is
E:\\sharedFile\\data
I am sending my parameter as #RequistParam like so
#PostMapping("/loadPicturesIntoDB")
public ResponseEntity<String> loadDB(#RequestParam String path) {
int size = imageService.loadDB(path);
return new ResponseEntity<String>("the database has been loaded with" + size + " files from the provided path ",
HttpStatus.OK);
}
I am getting the following error
2020-10-03 15:18:34.273 INFO 17356 --- [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in the request target [image/loadPicturesIntoDB?path=%22E:\\sharedFile\\data%22]. The valid characters are defined in RFC 7230 and RFC 3986
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:486) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) [tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.38.jar:9.0.38]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_231]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_231]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.38.jar:9.0.38]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_231]
Thanks in advance guys
Sending URL in request parameter will be problematic as tomcat by default do not perform encoding.
I would recommend you to send this as part of Request body instead.

Spring Boot Error when redirecting to html-file

I always get a "NoSuchMethodError" in my Spring Boot application when I try to redirect to a html-file and I don't understand where this is coming from. Hope someone can help.
Background:
An external server is sending some information to my server by calling a method via url /resolce.
This method processed the information and shall deliver the information to a html-file via redirecting. The processing of the information works fine, but when it comes to the redirect I get an NoSuchMethodError. I thought the template engine can't find the view, but the configuration seems fine.
Here is the stacktrace:
Exception Processing ErrorPage[errorCode=0, location=/error]
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax/servlet/http/HttpServletMapping;
at org.apache.catalina.core.ApplicationHttpRequest.setRequest(ApplicationHttpRequest.java:708)
at org.apache.catalina.core.ApplicationHttpRequest.<init>(ApplicationHttpRequest.java:114)
at org.apache.catalina.core.ApplicationDispatcher.wrapRequest(ApplicationDispatcher.java:917)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:358)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:394)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:253)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:175)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
The method:
#PostMapping ( "response" )
public ModelAndView postResponse ( ..., UriComponentsBuilder ucb, HttpServletRequest request ) {
byte [ ] samlResponseAsBytes = DatatypeConverter.parseBase64Binary ( samlResponse );
...
return new ModelAndView ( "redirect:" + ucb.path ( "/delivery" ).build ( ).toString ( ) );
}
Application.properties
...
spring.thymeleaf.prefix = classpath:views/
spring.thymeleaf.suffix = .html
spring.thymeleaf.check-template-location = true
spring.thymeleaf.cache = false
spring.resources.static-locations = classpath:resources/
spring.resources.cache.period = 0
I've tried several locations for the delivery.html but as it is configured it should be under resources/views.
I can upload more informations, if neccessary.
Can someone help me please?

java.lang.NullPointerException when building Firestore connection with my project id

I am trying to build a Firestore connection from my Google App Engine web application. I have followed the tutorial on google's website (https://cloud.google.com/firestore/docs/quickstart-servers) and setup the necessary service key as well as set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the json file with the key. However, I keep getting a NullPointerException on the line when I call the build() ater setting my project id. Has anyone encountered this same problem and have fixed it before? I can't find any similar problems online. There is not many lines of code so it seems like the problem should be relatively simple.
This is the error itself:
Caused by:
java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:770)
at com.google.cloud.ServiceOptions$Builder.setCredentials(ServiceOptions.java:203)
at com.google.cloud.firestore.FirestoreOptions$Builder.build(FirestoreOptions.java:213)
at com.tellafirma.mappers.PierMapper.(PierMapper.java:63)
at com.tellafirma.controller.PierController.displayLogin(PierController.java:60)
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 org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:867)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:134)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at com.google.appengine.tools.development.jetty9.StaticFileFilter.doFilter(StaticFileFilter.java:123)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610)
at com.google.appengine.tools.development.DevAppServerRequestLogFilter.doFilter(DevAppServerRequestLogFilter.java:44)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at com.google.appengine.tools.development.jetty9.DevAppEngineWebAppContext.doScope(DevAppEngineWebAppContext.java:94)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at com.google.appengine.tools.development.jetty9.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:595)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:502)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748)
I have tried redoing the service key and setting the GOOGLE_APPLICATION_CREDENTIALS again through the command line. I have printed out the FirestoreOptions object and the FirestoreOptions.Builder object and those have memory addresses that are non-null. I separated each metthod call to try and see specificalyl where the error was happening and it is on the build() line. I also updated my cloud components to see if anything was out of date.
public PierMapper(String id)
{
projectId = id;
firestoreOptions = FirestoreOptions.getDefaultInstance();
System.out.println(firestoreOptions.toString());
firestoreBuilder = firestoreOptions.toBuilder();
System.out.println(firestoreBuilder.toString());
firestoreBuilder = firestoreBuilder.setProjectId(projectId);
System.out.println(firestoreBuilder.toString());
System.out.println(firestoreBuilder.build());
firestoreOptions = firestoreBuilder.build();
database = firestoreOptions.getService();
}
I need to get this connection working to Firestore so I can begin to read and write data from my webapp.
Try setting GOOGLE_APPLICATION_CREDENTIALS to the full path to your json file. I suspect your app isn't finding your key file.
You can also try using gcloud auth application-default login, as described here, instead of the env variable.

WSO2 issue creating organization using TenantMgtAdminServiceStub

I wrote a code that adds a tenant to WSO2 using TenantMgtAdminServiceStub.
The tenant is added successfully, however when I try to add API to it using APIM 1.10.0 CreateApi::postApis, I get an exception (all details will follow below).
Only after I login to the admin of the newly created tenant's in the publisher UI (or by curl to login.jag) I'm able to add my API using the same CreateApi::postApis.
Here are the details.
The code to add the tenant:
System.setProperty("javax.net.ssl.trustStore", clientTrustStore.getAbsolutePath());
System.setProperty("javax.net.ssl.trustStorePassword", "admin");
System.setProperty("javax.net.ssl.trustStoreType", "admin");
System.setProperty("carbon.repo.write.mode", "true");
TenantMgtAdminServiceStub stub = new TenantMgtAdminServiceStub("https://localhost:9443/services/TenantMgtAdminService.TenantMgtAdminServiceHttpsSoap12Endpoint/");
ServiceClient sc = stub._getServiceClient();
setBasicAccessSecurityHeaders(adminUser, adminPasswd, sc);
try
{
TenantInfoBean tenant = new TenantInfoBean();
tenant.setActive(true);
tenant.setAdmin("admin");
tenant.setAdminPassword("admin");
tenant.setTenantDomain("testing123.com");
tenant.setFirstname("first");
tenant.setLastname("last");
tenant.setEmail("email#testing123.com");
stub.addTenant(tenant);
}
catch (RemoteException e) { ... }
catch (TenantMgtAdminServiceExceptionException e) { ... }
finally
{
stub.cleanup();
}
The code that adds the API:
ApiClient apiClient = Configuration.getDefaultApiClient();
apiClient.setBasePath("https://localhost:9443/api/am/publisher/v0.9");
apiClient.getAuthentications().put("BasicAuth", new HttpBasicAuth());
apiClient.setUsername("admin#testing123.com");
apiClient.setPassword("admin");
apiClient.setDebugging(true);
CreateApi crApi = new CreateApi(apiClient);
API body = new API();
... invoke setters of body ...
API createdApi = crApi.apisPost(body, "application/json");
...
Doing so I receive the following exception:
TID: [11] [] [2016-04-13 10:13:37,065] admin#testing123.com#testing123.com [11] [AM]ERROR {org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl} - Error in associating lifecycle for the artifact. id: b299a2ca-ae27-4198-a8dc-f69afda05379, path: /apimgt/applicationdata/provider/admin-AT-testing123.com/partnerInfo/1.0.0/api. {org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl}
org.wso2.carbon.registry.core.exceptions.RegistryException: Couldn't find aspectName 'APILifeCycle'
at org.wso2.carbon.registry.core.jdbc.EmbeddedRegistry.associateAspect(EmbeddedRegistry.java:2428)
at org.wso2.carbon.registry.core.caching.CacheBackedRegistry.associateAspect(CacheBackedRegistry.java:458)
at org.wso2.carbon.registry.core.session.UserRegistry.associateAspectInternal(UserRegistry.java:1900)
at org.wso2.carbon.registry.core.session.UserRegistry.access$3800(UserRegistry.java:60)
at org.wso2.carbon.registry.core.session.UserRegistry$39.run(UserRegistry.java:1872)
at org.wso2.carbon.registry.core.session.UserRegistry$39.run(UserRegistry.java:1869)
at java.security.AccessController.doPrivileged(Native Method)
at org.wso2.carbon.registry.core.session.UserRegistry.associateAspect(UserRegistry.java:1869)
at org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl.attachLifecycle(GovernanceArtifactImpl.java:378)
at org.wso2.carbon.apimgt.impl.APIProviderImpl.createAPI(APIProviderImpl.java:2119)
at org.wso2.carbon.apimgt.impl.APIProviderImpl.addAPI(APIProviderImpl.java:574)
at org.wso2.carbon.apimgt.impl.UserAwareAPIProvider.addAPI(UserAwareAPIProvider.java:48)
at org.wso2.carbon.apimgt.rest.api.publisher.impl.ApisApiServiceImpl.apisPost(ApisApiServiceImpl.java:180)
at org.wso2.carbon.apimgt.rest.api.publisher.ApisApi.apisPost(ApisApi.java:68)
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:497)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:200)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:99)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:251)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:293)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:212)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:268)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1739)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1698)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Now, as a workaround, I simply log into the admin of this newly created organization:
curl -X POST -c cookies http://localhost:9763/publisher/site/blocks/user/login/ajax/login.jag -d 'action=login&username=admin#testing123.com&password=admin'
And now when I'm trying to add API using the same code exactly, the API is added successfully.
I believe the meaningful part of the exception is:
{org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl} -
Error in associating lifecycle for the artifact.
id: b299a2ca-ae27-4198-a8dc-f69afda05379,
path: /apimgt/applicationdata/provider/admin-AT-testing123.com/partnerInfo/1.0.0/api.
{org.wso2.carbon.governance.api.common.dataobjects.GovernanceArtifactImpl}
org.wso2.carbon.registry.core.exceptions.RegistryException:
Couldn't find aspectName 'APILifeCycle'
at org.wso2.carbon.registry.core.jdbc.EmbeddedRegistry.associateAspect(EmbeddedRegistry.java:2428)
Again, I did not change anything in the code to make the postApis work, only logged-in to the admin user and it resolved by itself by re-run of the same code.
I cannot tell what exactly is the root cause.

Resources