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.
Related
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 ********************** -->```
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?
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.
I am trying to execute this REST api call as shown below using RESTTemplate
When I run this on browser it runs fine
http://ftc-wbpyrdb201:8080/statdata/InsStatData/_aggrs/getData?avars=%7B%22issuerId%22:19038%7D
But when I use URL in code
http://ftc-wbpyrdb201:8080/statdata/InsStatData/_aggrs/getData?avars={"issuerId":19038}
code is
requestURI="http://ftc-wbpyrdb201:8080/statdata/InsStatData/_aggrs/getData";
UriComponentsBuilder builder =
UriComponentsBuilder.fromUriString(requestURI)
// Add query parameter
.queryParam("avars","{\"issuerId\":19038}");
System.out.println(builder.buildAndExpand(requestURI).toUri());
System.out.println(builder.toUriString());
ResponseEntity<String> responseEntity = restTemplate
.exchange(builder.toUriString() , HttpMethod.GET, null,String.class);
I am getting below error, Please let me know what could be wrong here.
org.springframework.web.client.HttpClientErrorException: 400 Bad Request
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:63) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
i think you has problem in the query string of the URL, i used your code to print out the uri
System.out.println(builder.toUriString());
the printed string was
http://ftc-wbpyrdb201:8080/statdata/InsStatData/_aggrs/getData?avars=%7B%22issuerId%22:19038%7D
but if you used w3cschool encoder to encode the same url you will get
http://ftc-wbpyrdb201:8080/statdata/InsStatData/_aggrs/getData?avars=%7B%22issuerId%22%3A19038%7D
there is a little difference between the two urls, instead of : the w3school encoder produce %3A
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.