Comments (7)
Hello, i still have this problem with v2.6.2, did you find a solution? (problem with PathVariable)
from specification-arg-resolver.
A bit readable way
from specification-arg-resolver.
Hi @Sithira, could you provide more details or a more detailed stacktrace?
I could not reproduce your error. Code which I used to reproduction (test shows that everything should work):
package net.kaczmarzyk;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import net.kaczmarzyk.spring.data.jpa.Application;
import net.kaczmarzyk.spring.data.jpa.web.annotation.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import net.kaczmarzyk.spring.data.jpa.Customer;
import net.kaczmarzyk.spring.data.jpa.CustomerRepository;
import net.kaczmarzyk.spring.data.jpa.domain.Equal;
import org.springframework.web.context.WebApplicationContext;
import javax.persistence.*;
@Transactional
@RunWith(SpringRunner.class)
@EnableAutoConfiguration
public class Issue71 extends TestBase {
@Controller
public static class TestController {
@Autowired
TestEntityRepository repository;
@RequestMapping(method = RequestMethod.GET, value = "/{parentId}/translations/{translationId}/meta/search")
@ResponseBody
public Object search(
@Conjunction (value = {
@Or(value = @Spec(path = "metaType", params = {"meta_type"}, spec = Equal.class))},
and = @Spec(path = "entity_id", pathVars = "parentId", spec = Equal.class)) Specification<TestEntity> spec) {
return repository.findAll(spec);
}
}
@Autowired
TestEntityRepository repository;
@Before
public void setupDb() {
repository.save(new TestEntity("metaType1", "parentId1Value"));
repository.save(new TestEntity("metaType1", "parentId2"));
}
@Test
public void test() throws Exception {
mockMvc.perform(get("/parentId1Value/translations/translationIdIgnoredValue/meta/search")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$").isArray())
.andExpect(jsonPath("$[0].entityId").value("parentId1Value"))
.andExpect(jsonPath("$[1]").doesNotExist());
}
}
@Configuration
@ComponentScan
@EnableAutoConfiguration
@WebAppConfiguration
@EnableJpaRepositories
class TestBase {
@PersistenceContext
protected EntityManager em;
@Autowired
WebApplicationContext wac;
MockMvc mockMvc;
@Before
public void setup() {
mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
}
@Entity
public class TestEntity {
@Id @GeneratedValue
private Long id;
private String metaType;
private String entity_id;
public TestEntity(String metaType, String entity_id) {
this.metaType = metaType;
this.entity_id = entity_id;
}
public String getMetaType() {
return metaType;
}
public String getEntityId() {
return entity_id;
}
}
}
@Repository
interface TestEntityRepository extends JpaRepository<TestBase.TestEntity, Long>, JpaSpecificationExecutor<TestBase.TestEntity> {
}
from specification-arg-resolver.
Hi @jradlica,
This is the stack trace you asked for :-)
net.kaczmarzyk.spring.data.jpa.web.InvalidPathVariableRequestedException: Requested path variable {parentId} is not present in Controller request mapping annotations at net.kaczmarzyk.spring.data.jpa.web.WebRequestProcessingContext.getPathVariableValue(WebRequestProcessingContext.java:68) at net.kaczmarzyk.spring.data.jpa.web.SimpleSpecificationResolver.resolveSpecArgumentsFromPathVariables(SimpleSpecificationResolver.java:148) at net.kaczmarzyk.spring.data.jpa.web.SimpleSpecificationResolver.resolveSpecArguments(SimpleSpecificationResolver.java:135) at net.kaczmarzyk.spring.data.jpa.web.SimpleSpecificationResolver.buildSpecification(SimpleSpecificationResolver.java:61) at net.kaczmarzyk.spring.data.jpa.web.ConjunctionSpecificationResolver.buildSpecification(ConjunctionSpecificationResolver.java:66) at net.kaczmarzyk.spring.data.jpa.web.ConjunctionSpecificationResolver.resolveArgument(ConjunctionSpecificationResolver.java:54) at net.kaczmarzyk.spring.data.jpa.web.ConjunctionSpecificationResolver.resolveArgument(ConjunctionSpecificationResolver.java:36) at net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver.resolveArgument(SpecificationArgumentResolver.java:51) at net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver.resolveArgument(SpecificationArgumentResolver.java:63) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:167) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:645) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)
and I have posted a photo of what my controller method looks like. Kindly tell me what I'm i doing wrong here?
from specification-arg-resolver.
@Sithira please retry with v2.3.0 (just released)
from specification-arg-resolver.
(assuming that fixes in 2.3.0 solved this -- feel free to reopen if your issue persists, though)
from specification-arg-resolver.
+++ Hello, i still have this problem with v2.6.2, did you find a solution? (problem with PathVariable)
from specification-arg-resolver.
Related Issues (20)
- Required field HOT 2
- Specification arguments set HOT 1
- Java 17 incompatibility HOT 2
- Can you add SPeL in @Spec constVal with value from headers? HOT 2
- Issue with Join on Hierarchical Entities HOT 1
- [BUG] JoinFetch alias while pagination HOT 5
- Missing support for Spring Boot 3 and transition from javax to jakarta HOT 3
- Redundant proxy is created for multi-spec specifications when expected type is not a spec-interface HOT 3
- Path variables from `@RequestMapping` annotation above the class are not included in springdoc api documentation HOT 1
- Additional specifications HOT 1
- Support for auto-configuration
- Is it possible to reference the indices of the database? HOT 5
- Fail search with an error on unknown search parameters
- Add "description" attribute in the "@Spec" annotation HOT 2
- Json body params should not impose restrictions on requests HOT 3
- Interface extending Specification referenced from a method is not visible from class loader HOT 1
- Specification adds duplicate join when query has been built manually with existing join (Spring Boot 3.x)
- No params in Swagger UI generated by Springdoc-OpenAPI 1.6.13
- How to use with Dto and without entities in presentation layer (Controller)? HOT 2
- Query param with type Integer is not compatible when used with Blaze-Persistence
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from specification-arg-resolver.