No primary or default constructor found for interface org.springframework.data.domain.Pageable
I would suggest refactoring you controller to
public List<ItemCategory> getAllItemCategoryByPage(@RequestParam("page") int pageIndex,
@RequestParam("size") int pageSize){
return itemCategoryService
.getAllItemCategoriesByPageable(PageRequest.of(pageIndex, pageSize)).getContent();
}
I think you are missing an annotation before Pageable (how are you sending that data from client?).
No primary or single public constructor found for interface javax.ws.rs.core.UriInfo - and no default constructor found either
As Paul mentioned above in the comments legacy code has mixed up JAX-RS and Spring MVC in the controller code and I have no clue how it was working so far (maybe because running on Java6/7?) but the solution in my case was to use @RequestParam
instead of @Context
, as there is no equivalent of URIInfo
in the Spring MVC, and the code will looks like this:
@RestController
@RequestMapping(APIConstants.API_BASE_URI + APIConstants.MYCONTROLLER)
public class MyController extends APIRESTResource {
@Context
UriInfo uriInfo;
@GetMapping({"/activate"})
public ResponseEntity<String> activateAccount(@PathVariable("service") String srvc, @RequestParam String accId) {
HttpStatus status = HttpStatus.OK;
MediaType type = MediaType.TEXT_PLAIN;
String payload = "Activated";
try {
List<Long> accountIdList = extractAccountIdsAsList(accId);
String datasource = getDatasourceForService(srvc);
AccountsServiceImpl mgr = new AccountsServiceImpl(datasource);
mgr.activateAccounts(accIdList);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(type);
return new ResponseEntity<>(payload, headers, status);
}
catch (Exception ex) {
return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}
where
private List<Long> extractAccountIdsAsList(String accIdStr) throws Exception {
String fieldName = "accId";
validateRequiredField(fieldName, accIdStr);
accIdStr = accIdStr.replace(" ", ""); // remove any spaces...
String[] accIds = null;
if (accIdStr.contains(",")) {
accIds = accIdStr.split("\\,");
}
else {
accIds = new String[1];
accIds[0] = accIdStr;
}
List<Long> accIdList = new ArrayList<Long>();
for (int i = 0; i < accIds.length; i++) {
validateFieldValueType(fieldName, accIds[i], Long.TYPE);
Long accId = new Long(accIds[i]);
accIdList.add(accId);
}
return accIdList;
}
Selenium python Error: element could not be scrolled into view
This error message...
selenium.common.exceptions.ElementNotInteractableException: Message: Element <span class="ui-button-text"> could not be scrolled into view
...implies that the WebDriver instance i.e. driver was unable to scroll the element within the Viewport to invoke click()
.
First of all, as your usecase is to invoke click()
on the element, ideally instead of using presence_of_element_located()
you need to use the ExpectedConditions as element_to_be_clickable()
as follows:
WebDriverWait(driver, 1000000).until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[5]/div[3]/div/button/span'))).click()
You can find a couple of detailed discussions in:
- Message: Element could not be scrolled into view while trying to click on an option within a dropdown menu through Selenium
- org.openqa.selenium.ElementNotInteractableException: Element could not be scrolled into view when trying to click a button
As an alternative, as per the error message, to scroll an element within the Viewport before invoking click()
you can also use the Element.scrollIntoView() method.
You can find a detailed discussion in:
- What is the difference between the different scroll options?
At this point it is worth to mention, the following methods:
- move_to_element() from selenium.webdriver.common.action_chains
- element_to_be_clickable() from selenium.webdriver.support.expected_conditions
will automatically scroll the element within the Viewport.
You can find a detailed discussion in:
- How to scroll a webpage using selenium webdriver in Python without using javascript method execute_script()
This usecase
The button with text as Continue is within the Top Level Content but rendered within a Modal Dialog Box.
DevTools Snapshot:
As the desired element is within a Modal Dialog Box, so to locate and invoke click()
on the element you have to induce WebDriverWait for the element_to_be_clickable()
and you can use the following Locator Strategy:
Using
XPATH
:WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[starts-with(@aria-describedby, 'ui-id-')]//span[@class='ui-button-text' and text()='Continue']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
DevTools Snapshot:
Related Topics
Codility Tape Equilibrium Getting Zero on Some Cases
Array Pairwise Matching in Java Give Error Also Store Data Between Two Similar Element
How to Initialize a Byte Array in Java
Badpaddingexception Decrypting the Encrypted Data in Android
Removing a Column in Java from a 2D Array
In Activity.Oncreate(), Why Does Intent.Getextras() Sometimes Return Null
Spring Data Query Method With Optional @Param
Generate Any Random Number of Any Length in Java
How to Check If the File Is Image
How to Change the Colors of Text and Background for Cmd in Java
How to Reconnect Kafka Producer Once Closed
How to Get Response as Json With Responseentity in Java
Replacement for Wsimport With Jdk 11
How to Make a Java Program Quit When "Q" Is Inputted, Issue Is the Default Input Variable Is Double
Android Classnotfoundexception: Didn't Find Class on Path
Simplifying the If-Else Condition Using Java Functional Style Programming