Spring unit testing #ContextConfiguration - exception

I am using #ContextConfiguration annotation to load my application context in a unit test for a spring batch application.
The application context specifies a bean with properties and their values. The values are read from a property file. So the syntax used for the values is ${a.b:default}.
On running the junit, I get the following error:
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'xyz'; nested exception is java.lang.NumberFormatException: For input string: "${a.b:50}"
The batch job itself runs fine. I only see this issue in the junit.

Related

custom exception message in spring cloud function deployed in aws-lambda

I have a java project written using spring-cloud-function and deployed in aws-lambda.
I am trying to return a custom exception with some fields in the exception message body, something like"
{
reason: <exception reason>
code: <error code>
<some other fields>
}
#ExceptionHandler, that is generally used in spring boot doesn't seem to work here.
I can return the exception in the required format by creating a class for building the exception message in required format but in that case the error code will always be 200 since it will not be an exception object per se. Instead it will be my custom error object.
Is there a way I can set this up so that the above required format of exception object is returned and correct error code can be returned too?
Thanks in advance
First, the exception has nothing to do with Spring Boot. It's part of spring-web, so yes it would not work here since s-c-function is a general purpose framework, where the same function could be deployed and triggered via web, streaming, aws-lambda etc. .
Now, yes we had a problem returning JSON error (as you show) or object that represents the same, but that was fixed. So please update s-c-function to 3.2.3.

Get the true exception class from asmx web service using MSTest

So I have this web service that I am testing using MS Test and I want to get the original exception class which is InvalidOperationException. However whenever I run my test, the exception that I get is the FaultException class (which is the default exception when consuming a web service). I only get the exception in the message property of the exception.
Below is the exception message that I am getting.
`System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Invalid Entity\n at BL.Lib.WebService.BLWebServiceImpl.UpdateIDNumber(GetUpdateIDNumberRequest idNumberRequest) in [some file]:line 369\n at SSMWebService.Blacklist.BLWebService.BlacklistUpdateIDNumber(GetUpdateIDNumberRequest request) in [some asmx file]:line 132\n --- End of inner exception stack trace ---
Is there a way to get the InvalidOperationException class from the web service?

Oracle SOA BPEL calling a MySQL Procedure - parameter number 2 is not an out parameter

Currently I have a use case where I need to invoke a Mysql Procedure thorough Oracle BPEL. The adapter configuration is fine and shows me the available In/Out parameters during the configuration and the composite is deployed successfully. However the invocation is failed during the webs service call.
Any idea about the issue particularly in SOA. The weblogic version is 12c & I am using jDev 11g for the composite development.
Below is the error message received during the web service call-
The selected operation process could not be invoked.
A fault occurred while invoking the webservice operation. The fault is : <env:Fault xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>env:Server</faultcode>
<faultstring>Exception occurred when binding was invoked.
Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation 'getUserFirstName' failed due to: Register out parameter error.
Error registering parameter First_Name as an out parameter.
An error occurred when registering parameter First_Name as an out parameter of the getUserName API. Cause: java.sql.SQLException: Parameter number 2 is not an OUT parameter
Check to ensure that the parameter is a valid IN/OUT or OUT parameter of the API. This exception is considered retriable, likely due to a communication failure. To classify it as non-retriable instead add property nonRetriableErrorCodes with value "0" to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers.
".
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
</faultstring>
<faultactor/>
<detail>
<exception>Parameter number 2 is not an OUT parameter</exception>
</detail>
</env:Fault>
oracle.sysman.emInternalSDK.webservices.util.SoapTestException: Client received SOAP Fault from server : Exception occurred when binding was invoked.
Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation 'getUserFirstName' failed due to: Register out parameter error.
Error registering parameter First_Name as an out parameter.
An error occurred when registering parameter First_Name as an out parameter of the getUserName API. Cause: java.sql.SQLException: Parameter number 2 is not an OUT parameter
Check to ensure that the parameter is a valid IN/OUT or OUT parameter of the API. This exception is considered retriable, likely due to a communication failure. To classify it as non-retriable instead add property nonRetriableErrorCodes with value "0" to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers.
".
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
Step wise DB Adapter configuration is here-
https://drive.google.com/open?id=1cei0OFje1dmefDn7PfBIjxW4vb81Ngez
I think you made a mistake while you are selecting in and out parameters, probably you have added more variable than your database are expecting. Please look at the following and if possible send more details like screenshots of your db adapter configurations and db table
java.sql.SQLException: Parameter number 2 is not an OUT parameter

java.lang.NoSuchFieldError: USE_DEFAULTS thrown while validating json schema through json schema validator

I am new to RestAPI testing. I am trying to use Jsonschemavalidor. I added the jar file and all the dependencies. Still I get following error. Can anyone give solution to the problem.
Exception in thread "main" java.lang.NoSuchFieldError: USE_DEFAULTS
at com.fasterxml.jackson.annotation.JsonInclude$Value.<clinit>(JsonInclude.java:205)
at com.fasterxml.jackson.databind.cfg.MapperConfig.<clinit>(MapperConfig.java:45)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:543)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:460)
at com.github.fge.jackson.JacksonUtils.newMapper(JacksonUtils.java:155)
at com.github.fge.jackson.JacksonUtils.<clinit>(JacksonUtils.java:55)
at com.github.fge.jackson.JsonNodeReader.<init>(JsonNodeReader.java:82)
at com.github.fge.jackson.JsonLoader.<clinit>(JsonLoader.java:50)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$4.createJsonNodeInstance(JsonSchemaValidator.java:164)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$4.createJsonNodeInstance(JsonSchemaValidator.java:161)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$JsonSchemaValidatorFactory.create(JsonSchemaValidator.java:254)
at com.jayway.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchema(JsonSchemaValidator.java:161)
at com.jayway.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath(JsonSchemaValidator.java:117)
at com.nasdaq.api.GenericLib.validateJsonSchema(GenericLib.java:441)
Did you add the latest version of jackson-annotations? The USE_DEFAULTS enum constant was added in 2.6:

nullPointerException while linking jsp file to mysql

HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
root cause
java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.
GlassFish Server Open Source Edition 4.0
I'm not able to open the stack trace. the log file under domain is empty. pls help
NullPointerException means you are trying to call a non-static method (or an attribute) of an object which is not defined.
Example:
String s = "Foo";
System.out.println(s.length());
This code prints 3, because the length of Foo is 3, and s has been initialized as Foo.
Example with NullPointerException:
String s = null;
System.out.println(s.length());
Here s is null and I try to call the method length(), which is a non-static method. Obviously I will get a NullPointerException: there is no sense to get the length of "nothing" (null).
Nevertheless, you still can call static methods with s:
String s = null;
System.out.println(s.valueOf('a'));
Prints a. Note that it is not a good way to call static methods.
The static method valueOf(char) from the type String should be accessed in a static way
This warning explains you should access valueOf(char) this way:
System.out.println(String.valueOf('a'));
Now I let you find the error in your code because you didn't share it.