IBM MFP v8: NullPointerException while calling Java Adapter from Java Adapter - ibm-mobilefirst

My MFP Version is 8.0.0-2017012016.
When I am trying to call a Java Adapter from other Java Adapter, it is always throwing NullPointerException at the line:
HttpResponse response = adapterAPI.executeAdapterRequest(req);
What I have done is create the adapter named Producer, which contains method named sayHello which I am calling from Consumer Adapter.
Consumer Adapter contains method named getHello, which is consuming above mentioned sayHello method.
I have tested sayHello method alone and it is working fine.
I have tested the getHello method using WLResourceRequest and also with Swagger, but it is always throwing error.
Here is the link to download both the adapters. Both adapters are inside zip file.
Any help is greatly appreciated.
Thanks.

Related

Error creating bean named `conversionServicePostProcessor` when using spring-boot-admin-server

I was trying to enable Spring boot admin server for my application. The default settings work perfectly fine but when I attempt to enable security, I am getting following error:
APPLICATION FAILED TO START
Description:
The bean 'conversionServicePostProcessor', defined in class path
resource
[org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class],
could not be registered. A bean with that name has already been
defined in class path resource
[org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class]
and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting
spring.main.allow-bean-definition-overriding=true
Process finished with exit code 1
I am using the latest SNAPSHOT version of spring-boot-admin-starter-server (2.2.0-SNAPSHOT). Here is my security configuration:
#EnableAdminServer
#EnableWebFluxSecurity
#Configuration(proxyBeanMethods = false)
class AdminServerSecurityConfigurations(val adminServerProperties: AdminServerProperties) {
#Bean
fun adminServerSecurityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain = http
// #formatter:off
.authorizeExchange()
.pathMatchers("${adminServerProperties.contextPath}/assets/**").permitAll()
.pathMatchers("${adminServerProperties.contextPath}/login").permitAll()
.anyExchange().authenticated().and()
.formLogin().loginPage("${adminServerProperties.contextPath}/login").and()
.logout().logoutUrl("${adminServerProperties.contextPath}/logout").and()
.httpBasic().and()
// #formatter:on
.csrf().disable()
.build()
#Bean
fun notifyLogger(instanceRepository: InstanceRepository) = LoggingNotifier(instanceRepository)
}
I found a pull request to update the documentation: https://github.com/spring-projects/spring-boot/issues/14069
For Reactive WebSockets,
{spring-reference}web-reactive.html#webflux-websocket[Spring WebFlux] offers rich support,
which is accessible through the spring-boot-starter-webflux module.
See the spring-boot-sample-websocket-reactive sample project to see how WebSockets may
be implemented using Spring WebFlux.
it turns out that using webflux and websocket leads to conflicts.
also in this pull request was denied in the resolution of the conflict
https://github.com/spring-projects/spring-boot/issues/14810
for reactive websocket see this sample https://www.baeldung.com/spring-5-reactive-websockets
I had the same issue and was able solve it by adding
spring.main.allow-bean-definition-overriding=true
to my application.properties.
Sounds like a workaround and it was also only necessary if I deployed it as WAR -- as a standalone application the exception never occured.
I also faced this error, after Reimport All Mavne Projects(Intellij IDE) it works fine for me. Here my detailed input on this issue here

Unable to create session while mocking Appium's behavior using WireMock

I am trying to mock Appium’s behavior using WireMock.
Problem I am facing is: my POST stub is able to respond me with the response code I have set (which I have monitored using Wireshark), but it is throwing exceptions related to session creation.
POST stubs I have tried for creating session for reference:
- Trial 1:
wireMockRule.stubFor(post(urlEqualTo("/wd/hub/session”)).
withRequestBody(matching(“JSON representation of set of desired capabilities specific to application"))
.willReturn(aResponse().
withStatus(200).
withHeader("Content-Type", "application/json”).
withBody("{\"sessionId\":\"e523dc70-c068-46e7-b966-8462401119b4\",\"status\":0,\"value\":\"Created Session\"}")));
Outcome: “It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible” exception.
Trial 2: Just removed request body from above stub
wireMockRule.stubFor(post(urlEqualTo("/wd/hub/session”))
.willReturn(aResponse().
withStatus(200).
withHeader("Content-Type", "application/json”).
withBody("{\"sessionId\":\"e523dc70-c068-46e7-b966-8462401119b4\",\"status\":0,\"value\":\"Created Session\"}")));
Outcome:
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session” exception.
Environment reference:
Java-client of Appium: 6.0.0
Selenium standalone server: 3.12.0
Selenium client of Java: 3.12.0
Please help.
This does not really seem to related to WireMock?
Maybe you can switch to the .NET version from WireMock to simulate your calls?

MobileFirst - JavaScript Adapter calling Java Adapter via REST endpoint

This question is related to - [How to invoke Java adapter from HTTP adapter? ][1]
I have 2 adapters in my MobileFirst 7.1 project :
A Java Adapter that is exposing Rest Endpoint.
A JavaScript adapter will call the Java Adapter via Rest Endpoint
To be exact, this is what I call in the JS adapter :
function JSAdapterCalltoJavaAdapter() {
var input = {
method : 'get',
returnedContentType : 'xml',
path : "adapter/JavaAdapterRestPath"
};
return WL.Server.invokeHttp(input);
}
We have run JMeter load test for 800 Threads on Java Adapter, there is no issue. However, when we run load Test on JS Adapter, the MobileFirst server stop responding, and does not accept incoming request from JS Adapter. The new requests timeout and the MobileFirst console become unresponsive. When we stop the load test, the server gradually recovered.
I have configured the following params adapter.xml :
<connectionTimeoutInMilliseconds>, <socketTimeoutInMilliseconds>, and <maxConcurrentConnectionsPerNode>
It seems like there is threading issue when using JS adapter to call Java adapter under load.
Sounds like you need to open a PMR (support ticket) if you are encountering a threading issue in the MobileFirst Server so that the support/dev team could help you. If you have an actual programming question, ask it.

"Multiple serializers are not supported" configuration error in NServiceBus 4.0.4 during unit testing

I am trying to unit test message handlers for NServiceBus 4.0.4. The bus is configured to use JSON serializer in the application using the Configure.Serialization.Json(); method call.
Whenever I call the Test.Initialize() method from the unit tests assembly I get the following exception: System.Configuration.ConfigurationErrorsException : Multiple serializers are not supported. Please make sure to only enable one
I tried calling Configure.Serialization.Json() and Serializers.SetDefault<JsonSerialization>() before calling the Test.Initialize() method without any success.
Does anyone know what am I doing wrong? All examples I see on the internet do not mention any Configure calls.
This issue has been reported previously here and looks like it will be fixed in the next NServiceBus build (both 4.0.5 and 4.1.0)
A workaround is to explicitly disable the xml serializer when enabling the json one.
Configure.Serialization.Json();
Feature.Disable<XmlSerialization>(); // hack to make NSB unit tests work

WebReference vs ServiceReference

I have to following problem. In my application I used a service reference to a non-WCF service from some external company. I created a proxy class using svcutil.exe tool. Everything worked fine for about a year.
Yesterday however, clients reported that it's not possible to get any response from the service. I figured out that the error returned from the service was:
The formatter threw an exception while
trying to deserialize the message:
There was an error while trying to
deserialize parameter
http://serviceurl:someResponse. The
InnerException message was 'There was
an error deserializing the object of
type specificType
So, what I did I firstly updated the service reference and also generated the new proxy using svcutil.exe. The problem still occurs.
I resolve the problem by using either 1) wsdl.exe tool to generate proxy class 2) add web reference (which behind the scenes using wsdl.exe tool internally to create proxy).
My question is : Why everything worked fine for a quite long time even if I used a service reference? How can I checked whether has something changed in the web service? Any help would be appreciated.
Contact the company that provides the web service and find out what changed.