Same title question already exists, however the environment seems to be different.
I'm trying to execute Spring Boot Web MVC test using MockMvc and WebDriver, so I don't need to run Selenium Server.
I created sample project on GitHub as public repository.
I try to impelent the code referencing Spring Framework Document and Spring Boot Document.
The test code works when using MockMvc and HtmlUnit (MessageControllerMockMvcAndHtmlUnitTest.java).
However, when I execute the test using MockMvc and WebDriver (MessageControllerMockMvcAndWebDriverTest.java), the error occurs as follows:
java.lang.IllegalStateException: Unable to locate element by name for com.gargoylesoftware.htmlunit.TextPage#~
Does anyone know what is wrong and how to fix it?
I finally solved the problem by myself.
I just made 2 mistakes.
I misstyped the URL (messages not messagges)
I tried to operate hidden element. So I need to operate by JavaScript.
before (wrong)
this.id.sendKeys(id);
after (correct)
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
javascriptExecutor.executeScript("document.getElementById('id').value = '" + id + "';");
Related
im trying to setup a cucumber with spring project to use autowiring and spring config options (application.yml). Now that i created a runner class to pass parameters from outside executing runs on following exception:
Weird is, i have a class exactly with the proposed annotations, so i guess it's not found and something on the project structure is off, but i don't get what exactly.
Here is my project structure:
src.main.java.package.config.SpringConfig.java
src.main.java.package.steps.StepsSpringConfig.java
src.test.java.package.runner.CucumberRunner.java
SpringConfig.java
#ComponentScan("package")
#EnableConfigurationProperties{PropertyClasses}
StepsSpringConfig.java
#SpringBootTest(classes = SpringConfig.class)
#CucumberContextConfiguration
All Step classes extend from this class
CucumberRunner.java
#RunWith(Cucumber.class)
#CucumberOptions(steps = path/to/features, glue = {src.package.steps, src.package.config})
In my JUnit RunConfig I use this runner class
When i run i get the error on the screenshot above. What am i missing?
Im using the latest version of IntelliJ (2021.2.2)
Im using Spring 2.3.12 and cucumber-junit 6.8.0
Ok im dumb, the solution is found here: Cucumber options annotation
i specified the glue path like "src.main.java.package.steps" but it needs to be just "package.steps" and it works fine
Project structure:
Here is the repository (no class exceeds 20 lines of code): https://github.com/MoskovchenkoD/spring5-jokes
Here is the problem: Service implementation isn't used, and 'joke' attribute doesn't get printed on the page (just '123'). Controller's #RequestMapping method is simply ignored or bypassed.
How to fix it? I was following a step-by-step video from generating a project at start.spring.io to launching it.
Much appreciated!
Yet another childish error =(
I moved the Application class one level up and now it works fine.
I want to use Spring Integration RedisLockRegistry . I have some questions about Spring Integration RedisLockRegistry.
Can I use the redisLockRegistry as a Spring bean ? it means my application just a single redisLockRegistry.
I see the RedisLockRegistry implement ExpirableLockRegistry in the version 5.0,
Should I need run the expireUnusedOlderThan method?
I met the same questions and start analyze spring code. So from sources I can state that:
Yes you can create and configure it as a bean of any instance of LockRegistry like RedisLockRegistry, JdbcLockRegistry. For test purposes I'd like even use PassThruLockRegistry
I tried to find any invocation of expireUnusedOlderThan inside Spring without success.
So I have created simple scheduler as following:
#Autowired
private ExpirableLockRegistry lockRegistry;
#Scheduled(fixedDelay=50000)
public void cleanObsolete(){
lockRegistry.expireUnusedOlderThan(50000);
}
I have a persistence layer (JPA entity objects) created and managed by Roo. It is in its own project, builds to a jar, and I have used it with a separate Spring MVC 3 web application.
I'd like to use this same Roo persistence project in another web application powered by Apache Wicket. I have seen a couple of the Roo add-ons made for Wicket, but none of them even compile (I'm not the only one to have the issue).
The problem I am encountering is that whenever I try to call one of my Roo entities from within a Wicket Page or component, I get the following exception:
Caused by: java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)
at com.x.domain.UserAccount_Roo_Entity.ajc$interMethod$com_x_domain_UserAccount_Roo_Entity$com_x_domain_UserAccount$entityManager(UserAccount_Roo_Entity.aj:91)
at com.x.domain.UserAccount.entityManager(UserAccount.java:1)
I have configured my application following the Spring+Wicket wiki here: https://cwiki.apache.org/WICKET/spring.html
Does anyone know the 1,2,3 steps to set up a Wicket application to utilize Spring Roo entities? Any help is appreciated. Thanks!
I found this in google code, sounds like its doing exactly what you want http://code.google.com/p/spring-roo-wicket-addon/
I found the solution to my problem. When I ran my wicket webapp using the Maven jetty:run goal, it worked. However, I was trying to start Jetty via Java code:
public class Start {
public static void main(String[] args) throws Exception {
Server server = new Server();
SocketConnector connector = new SocketConnector();
server.start();
}
}
I was not loading the Spring ApplicationContext in this "Start" class. Once I modified this class to load the Spring application context, it worked
I'm new in spring roo. I want to create a page with file upload. I used spring roo to create all pages and i try to use it to create a file browser button in file upload page. The problem is spring roo using spring form tag which doesn't have file browser. I solve this problem by using html input type="file" tag instead, but the spring roo showed the error like this "Failed to invoke handler method [public void egat.spring.roo.ptu.io.web.ImportExcelController.post(java.lang.Long,org.springframework.ui.ModelMap,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)]; nested exception is java.lang.IllegalStateException: Could not find #PathVariable [id] in #RequestMapping "
How can i solve this problem?
There is defect in jira raised against this issue you can vote for it.
https://jira.springsource.org/browse/ROO-442
Spring file upload in a mixed form
Check this out till this bug is resolved