NoSuchMethodException with getter and setter in play framework 1.2.5, when deployed in weblogic - playframework-1.x

I am using play framework for my application. It workks correctly in dev mode but gives me an error in prod mode
Execution exception (In /app/helper/FinansHelper.java around line 189)
NoSuchMethodException occured : finansServis.helper.KayitliIslemDto.getIpcMemo()
How can I solve this problem?
Edit: My KayitliIslemDto class
public class KayitliIslemDto {
public IPCMemo ipcMemo;
public TahsilatMemoOut tahsilatMemoOut;
public HesabaHavaleMemoOut hesabaHavaleMemoOut;
public IsmeHavaleMemoOut ismeHavaleMemoOut;
public KayitliIslemDto(IPCMemo ipcMemo, IsmeHavaleMemoOut ismeHavaleMemoOut) {
this.ipcMemo = ipcMemo;
this.ismeHavaleMemoOut = ismeHavaleMemoOut;
}
public KayitliIslemDto(IPCMemo ipcMemo, HesabaHavaleMemoOut hesabaHavaleMemoOut) {
this.ipcMemo = ipcMemo;
this.hesabaHavaleMemoOut = hesabaHavaleMemoOut;
}
public KayitliIslemDto(IPCMemo ipcMemo, TahsilatMemoOut tahsilatMemoOut) {
this.ipcMemo = ipcMemo;
this.tahsilatMemoOut = tahsilatMemoOut;
}

I had a similar problem with Play Framework. It might highly possible that your JVM locale is Turkish. 'I' in method names are sometimes converted to 'İ' by the JVM that you use.
I solved the problem by setting up JVM system parameters:
play run ExampleProject -Duser.language=en -Duser.country=TR -Duser.variant=TR
I hope it works for you, too.

Related

Mock #AuthenticationPrincipal MockMvc with addFilters = false

I am using mockMvc to write unit tests for Controllers in Rest Application.
I am facing challenge in testing below rest End Point -
#GetMapping("/details")
public ResponseEntity<UserDetails> getUserDetails(#AuthenticationPrincipal UserDetails userDetails)
{
return ResponseEntity.ok(userDetails);
}
As you can see , I need to mock #AuthenticationPrincipal to get this rest end Point unit tested
Now the challenge is the unit test class I am using has below skeleton :
public class ControllerTest extends BaseControllerTest{
}
and BaseControllerTest is :
#WebMvcTest
#ContextConfiguration(
classes = {
TestClass1.class,
TestClass2.class,
})
#AutoConfigureMockMvc(addFilters = false)//here is a problem
#TestExecutionListeners(MockitoTestExecutionListener.class)
#ActiveProfiles("test")
public class BaseControllerTest extends AbstractTestNGSpringContextTests {
}
So as you can see all filters are disabled as we are usig addFilters = false.
When I debugged the unit tests with eclipse I can see NO SPRING SECURITY FILTERS are being added in call chain as addFilters = true
I have searched a lot on public forum and it seems using annotations like #WithUserDetails and #WithMockUser , it is possible to achieve this.
But these will not work as there is no spring security behind the scenes
Can anybody please help here ?

Not able to get values from the yaml file using Mock in Groovy test case

I'm writing a unit test case for my functionality using Groovy. But, however I'm not able to configure the values that are available in the class. The values are configured in my yaml file.
Here is my code
class UpdateServiceImplTest extends Specification {
DataSourceRestTemplateConfig dataSourceRestTemplateConfig
def setup() {
dataSourceRestTemplateConfig= Mock(DataSourceRestTemplateConfig )
}
}
This DataSourceRestTemplateConfig class is using some properties, which is coming as null while executing the test
public class DataSourceRestTemplateConfig {
#Autowired
RestTemplate restTemplate;
#Value("${datasource.auth.username}")
private String userNameNew;
#Value("${datasource.auth.password}")
private String passwordNew;
// Method to call DB here
}
The above values are coming as null when I evaluate the expression. Are there any other configurations am I missing?
Any ideas would be greatly helpful to me.

#EnableFeignClients package scan - spring boot

I have annotated spring boot application with Feign Client
#SpringBootApplication
#EnableFeignClients({"com.ms.Foo1.api", "com.ms.Foo2.api",
"com.ms.Foo3.api", "com.ms.Foo4.api", "com.ms.Foo5.api", "com.ms.Foo6.api",
"com.ms.Foo7.api", "com.ms.Foo8.api", "com.ms.Foo9.api", "com.ms.Foo10.api"})
public class AnalyticsApplication extends SpringBootServletInitializer {
}
everything working fine, AS I just modify the bases packages. its start scanning package outside the api.
#SpringBootApplication
#EnableFeignClients({"com.ms.*.api"})
public class AnalyticsApplication extends SpringBootServletInitializer {
}
I am expecting that #EnableFeignClients({"com.ms.*.api"}) will scan only clients inside the api but it start scanning outside the api package as well.
what I need to change ? or can we apply regex here instead of mention every package ?
You can use a regex filter on #ComponentScan like this:
#ComponentScan(basePackages = "com.ms",
includeFilters = #Filter(type = FilterType.REGEX, pattern="com.ms.*.api"))
public class AnalyticsApplication extends SpringBootServletInitializer {
}
But #EnableFeignClients haven't this feature. The only thing you can do is:
#EnableFeignClients(basePackages = "com.ms")
public class AnalyticsApplication extends SpringBootServletInitializer {
}

Unit Testing ODataQueryOptions Gives MissingMethodException DependencyInjection

So here is my problem, I have an OData Web Api service that uses ODataQueryOptions to filter data from our sql server and I am trying to setup a .Net Framework Unit Test project to test the controllers with different query options. I have been searching for several days now and found many examples but most of them use an older version of OData. This example is the best one I have found so far, the only problem is that calling config.EnableDependencyInjection(); gives me the following exception:
Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
Here is an example of my code:
using System.Collections.Generic;
using System.Web.Http.Results;
using System.Web.OData;
using System.Web.OData.Query;
using System.Net.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using University.API.OData.Controllers;
using University.API.OData.Models;
using System.Web.OData.Routing;
using System.Web.Http;
using System.Web.OData.Extensions;
[TestClass]
public class SalesforceUnitTest
{
private HttpRequestMessage request;
private ODataQueryOptions<Product> _options;
[TestInitialize]
public void TestInitialize()
{
request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/odata/product?$top=5");
var model = WebApiConfig.GetModel();
HttpConfiguration config = new HttpConfiguration();
config.EnableDependencyInjection(); //Throws Missing Method Exception
WebApiConfig.Register(config);
config.EnsureInitialized();
request.SetConfiguration(config);
ODataQueryContext context = new ODataQueryContext(
model,
typeof(Product),
new ODataPath(
new Microsoft.OData.UriParser.EntitySetSegment(
model.EntityContainer.FindEntitySet("product"))
)
);
_options = new ODataQueryOptions<Product>(context, request);
}
[TestMethod]
public void ProductTest()
{
var controller = new ProductController();
controller.Request = request;
var response = controller.Get(_options);
var contentResult = response as OkNegotiatedContentResult<List<Product>>;
Assert.IsNotNull(contentResult);
Assert.IsNotNull(contentResult.Content);
}
}
Let me know if there is any other information you may need.
Thank you for any help you can provide.
EDIT:
Here what is referenced in the unit test project:
EntityFramework
EntityFramework.SqlServer
Microsoft.Data.Edm
Microsoft.Data.OData
Microsoft.Extensions.DependencyInjection
Microsoft.Extensions.DependencyInjection.Abstractions
Microsoft.OData.Core
Microsoft.Odata.Edb
Microsoft.Spatial
Microsoft.Threading.Tasks
Microsoft.Threading.Tasks.Extensions
Microsoft.Threading.Tasks.Extensions.Desktop
Microsoft.VisualStudio.TestPlatform.TestFramework
Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions
System
System.ComponentModel.DataAnnotations
System.Net
System.Net.Http
System.Net.Http.Extensions
System.Net.Http.Primitives
System.Net.Http.WebRequest.
System.Spatial
System.Web
System.Web.Http
System.Web.OData
ODataAPI
I figured it out after some more digging. It seems that my Unit Test project was using a different version than my ODataApi project. This for some weird reason was causing the MissingMethodException instead of a VersionMismatchException. Hopefully this helps someone else who is looking into why Dependency Injection isnt working for your Unit Test project.

Domino: Webservice: Class do not have a property of the name

I have the following Problem.
I tried to create a web service a standard cmis Webservice Interface on IBM, Domino with wsdl2java (with cxf). After creating all java classes I tried to get answers from the webservice with the eclipse Java Client. It works find. After this test I import the generated java classes into a Domino Database.
Now I have the problem to run the webservice, because the following error message:
class org.oasis_open.docs.ns.cmis.messaging._200908.GetTypeDefinition
do not have a property of the name {URL..}repositoryId
In the JAVA Class the following code:
public class GetTypeDefinition {
#XmlElement(required = true)
protected String repositoryId;
#XmlElement(required = true)
protected String typeId;
#XmlElementRef(name = "extension", namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", type = JAXBElement.class)
protected JAXBElement<CmisExtensionType> extension;
The Domino JAVA Env. does not understand the Tag #XmlElement(required = true) without the name, namespace and the type definition.
If I add in the same line the following code:
#XmlElement(required = true, name = "repositoryId", namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", type = String.class)
protected String repositoryId;
it works (error then in the next line:
GetTypeDefinition do not have a property of the name {URL}typeId
Now the question is: why? Can I generate the java classes with an other tool (not with cxf wsdl2java) or do I need other parameters to get the complete code?
In the generated JAVA Classes are round about 170 lines with the problematic code.
Have somebody an Idea to solve the problem on the Domino Server (x64 9.0)?