w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Spring MVC Rest: No mapping found for HTTP request with URI [/ecommerce-api/rest/checkout] in DispatcherServlet
Weird behaviour is often caused by inconsistency in your compiled and source files. I suggest you to perform proper cleaning (assume you are using eclipse). Stop server, then perform Project -> clean. After that clean server. Try restart your application. Other tip is try to debug what is happening when spring is looking for correct handler.

Categories : Java

Injecting custom parameter to request mapping method in Spring MVC
You should be able to retrieve it using the @ModelAttribute tag, and annotating the user as a session attribute, this way: @SessionAttributes("user") public class MyController { @RequestMapping(value = "/{cid}/read") public @ResponseBody boolean markAsRead(@PathVariable("cid") Comment comment, @ModelAttribute("user") User user) { //No need to inject HttpSession and //no need to call user = ((User) session.getAttribute("user")); ... } }

Categories : Spring

Request mapping does not choose correct controller method in Spring
Shouldn't params be defined with multiple String parameter names as separate array entries? E.g.: @RequestMapping(method = RequestMethod.GET, params = {"page", "limit"})

Categories : Java

Spring Data REST PUT Method Not Allowed
You are trying to use the same url for POST and PUT requests, but PUT usually requires the id of the object that has to be updated. Spring does have mapping for localhost:8080/<applicationname>/<entityName>, but only for POST request and hence the error. Try using PUT with: http://localhost:8080/<applicationname>/<entityName>/<objectId>

Categories : Java

spring-mvc - No mapping found for HTTP request with URI
By default, most app servers will make the URL to your servlet something like <context>/<servlet_path>/<rest_of_mapping>, where <context> is usually the WAR name. In your example code, you don't have any mapping on the Controller at all, and "/" on the method, but you somehow expect /gitsystem to make it to your handler? It doesn't work that way. Not to mention, your sample request doesn't have any Context portion, unless they WAR you are deploying is called gitsystem.war. First, you should have SOMETHING on your Controller. Second, you should have something on your handler as well. Although you can modify the Context portion to not be the WAR name, you cannot get rid of the Context altogether, at least not that I know of. After the app server matches the Con

Categories : Java

No mapping found for HTTP request with URI Spring MVC
With the web.xml configured they way you have in the question, in particular: <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> ALL requests being made to your web app will be directed to the DispatcherServlet. This includes requests like /tasklist/, /tasklist/some-thing.html, /tasklist/WEB-INF/views/index.jsp. Because of this, when your controller returns a view that points to a .jsp, instead of allowing your server container to service the request, the DispatcherServlet jumps in and starts looking for a controller that can service this request, it doesn't find any and hence the 404. The simplest way to solve is to have your servlet url mapping as follows: <servlet-mapping

Categories : Java

Java Spring MVC: No mapping found for HTTP request with URI
@RequestMapping("/form.html") vs /SpringTest/form.htm You have an extra l in your @RequestMapping url. Don't forget to component-scan the package your controller is in.

Categories : Java

Ensuring that two Request Mapping variables match in Spring MVC
I would change these to seperate integers so you can compare them and end up with the below. Given your example above this should cause no problems and you wouldn't need to edit any client side code of the request either. @RequestMapping(value = "{personId}/rbc-{secondPersonId}-badge.pdf", method = RequestMethod.GET) public ModelAndView produceBadgePdf(@PathVariable Integer personId, @PathVariable Integer secondPersonId){ if(secondPersonId !=null && secondPersonId.equals(personId)) { } }

Categories : Java

HTTP Request Mapping to Different Channels - Spring MVC Framework
Not sure why you need new channels for each request. The incoming HTTP request is bounded to some container Thread and if you will use just direct channel you'll get the same result. If your subscriber to that channel is thread-safe everything will be OK. Method invocation concept. Or provide, please, more info regarding your item 2).

Categories : Spring

Authentication failed in Spring due to no mapping found for HTTP request with URI?
Remove <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/WEB-INF/pages/*</url-pattern> </filter-mapping> Also you can refer to this tutorials: http://www.mkyong.com/spring-security/spring-security-hello-world-example http://www.mkyong.com/spring-security/spring-security-form-login-example/

Categories : Spring

Spring session factory not finding mapping files in multiple directories with same class path
You are using maven. And since you put your Bar mapping into the test resource directory, it is only available when running tests. I assume you have a persistence-unit configured similar to the example below <persistence-unit ...> <class>something.Foo</class> <class>something.Bar</class> </persistence-unit> What happens at start-up is that Spring starts Hibernate, hibernates reads the persistence-unit and asks the factory for the mappings. But remember, Bar is only a test class. So Spring finds the mappings from src/main/resources, but since it does not run as a test, it does not see src/test/resources.

Categories : Spring

org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI Spring 3
I believe the application may not be scanning the package that contains the controllers. I see a dao package being scanned but I assume you wouldn't put your controllers there. In your configuration scan the package with the controllers. <context:component-scan base-package="by.mvc.spring" />

Categories : Java

Static Resources (js,css..) in Spring MVC app not available when adding spring-data-rest
I'm faced with same with some differences. In my case I add my handler for static resources: @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**").addResourceLocations("/WEB-INF/static/"); } After that some static files with long path (like /a/b/c/d.css or /a/b/c/d.js) served as static content but some files (like /a/b/c.js) is not. I found that in my case RepositoryRestHandlerMapping registers itself using Ordered.HIGHEST_PRECEDENCE and most of CSS and JavaScript requests handled into this handler by rules like [/{repository}/{id}/{property}]. This is a bug in Spring-Data, now this fixed (thanks to Oliver Gierke), you can get fixed version 2.0.0.BUILD-SNAPSHOT from snapshot repo and I hope this can help.

Categories : Spring

Spring - Jackson request mapping with validation. Throws "HttpMessageNotReadableException" when string given for long property
It's important to understand that first Jackson deserializes the JSON content of the request body and creates a UserAgreement object. Only then can standard bean validation be applied as a result of the @Valid annotation. So you can think of @Valid as an added layer of validation only after JSON deserialization succeeds. Use an @ExceptionHandler method for deserialization errors.

Categories : Spring

SPRING REST: The request was rejected because no multipart boundary was found
The problem isn't in your code - it's in your request. You're missing boundary in your multipart request. As it said in specification: The Content-Type field for multipart entities requires one parameter, "boundary", which is used to specify the encapsulation boundary. The encapsulation boundary is defined as a line consisting entirely of two hyphen characters ("-", decimal code 45) followed by the boundary parameter value from the Content-Type header field. This and this posts should also be helpful.

Categories : Spring

Can we have more than one @Path annotation for same REST method
You can't have mutliple @Path annotations on a single method. It causes a "duplicate annotation" syntax error. However, there's a number of ways you can effectively map two paths to a method. Solution for simple paths - regular expressions in @Path annotation The @Path annotation in JAX-RS accepts parameters, whose values can be restricted using regular expressions. This annotation: @Path("a/{parameter: path1|path2}") would enable the method to be reached by requests for both /a/path1 and /a/path2. Unfortunately, this solution only works when path1 and path2 are simple path segments that contain no slashes. Serving responses with a redirection status code Alternatively, you could set up a redirection. Here's a way to do it in Jersey (the reference implementation of JAX-RS), by def

Categories : Java

Cross-domain Ajax request with Spring MVC Rest API works with Safari only
I don't think its likely that there's anything wrong with the API. Instead, what is very likely is that the functions you're using to send the data to the API is not supported across all browsers. You may not always be getting a value for the url variable You may not always have the .toUrlValue method Using firebug in firefox, you can inspect the POST params that you're sending from the request. Make sure that your POST data is not different between the different browsers.

Categories : Jquery

How to validate if a record exists when issuing a REST update request using spring jdbcTemplate?
I had a similar issue. Here is how I tackled the issue Whenever its a new user, then mark the id with a default number (eg. 51002122) here 51002122 is never the id in db. So the page shows "/51002122/user". When ever the id of the user is 51002122 then I would do an insert to db. After the insert, I render the page with the id from db. Eg. after insertion, the page would be "/27/user". For all other ids other than 51002122 ( eg. /12/user or /129/user ) I would do an update in the db because I know that this user exists in the db. Not sure if this is the right approach but this works. Can someone tell a better or correct approach.

Categories : Java

REST api request method input parameters
PUT, POST, PATCH, etc (everything but GET and DELETE*) accept request bodies. Generally data is passed as either: A URL encoded string of name/value pairs (exactly the same as a URL querystring) that is decoded and parsed by the server into $_POST (or similar depending on your web framework of choice). This typically relies on the presence of a Content-Type header set to application/x-www-form-urlencoded (browsers do this by default when forms are submitted). If you see the data in file_get_contents('php://input') but not $_POST it's very likely this header is not present or is set to another value. If you're using Chrome, you can see what headers and body the client is sending in the Network tab of the dev tools. The other popular request body format is to use Content-Type: application/

Categories : Api

Call Data in different/many request mapping
It is kind of weird that you have to pass an instance to get your list of banner... What about having this code in a private method and then use that method instead of copying the code. Something like that : @RequestMapping(value ="support",method = RequestMethod.GET) public String support(Model model){ model.addAttribute("listBannerWeb", getBannerList()); return "menu/support"; } @RequestMapping(value ="news",method = RequestMethod.GET) public String news(Model model){ model.addAttribute("listBannerWeb", getBannerList()); return "menu/news"; } private List<Banner> getBannerList() { Banner banner = new Banner(); List<Banner> listBannerWeb = bannerService.getBannerList(banner); return listBannerWeb; }

Categories : Java

Spring REST service.. How do I secure REST calls I am making in Spring MVC
Use HTTPS Use Spring Security with HTTP-header-based authentication Official examples: https://github.com/SpringSource/spring-security/tree/master/samples

Categories : Spring

Routing based on REST method with Spring integration
you can use a header-value-router for this one as the http method is automatically set in the message header. something like this <int-http:inbound-channel-adapter channel="input.channel" path="/log" supported-methods="PUT,POST" request-payload-type="java.lang.String"/> <int:channel id="input.channel"/> <int:header-value-router input-channel="input.channel" header-name="#{T(org.springframework.integration.http.HttpHeaders).REQUEST_METHOD"> <int:mapping value="PUT" channel="put.input.channel"/> <int:mapping value="POST" channel="post.input.channel"/> </int:header-value-router> hope that helps

Categories : Spring

Spring Data Mongodb POJO mapping
I think you can achieve it through this mapping (If I understood your question correctly): class Person { String name; int age; } class Outer { @Field("columns") List<Person> persons; }

Categories : Mongodb

helper path generated by Rails based on a custom REST method fails
Short answer: There is no automatic way in Rails to do so. The reason is that RESTul URL relies basically on the format /controller/action. Meaning if your controller ResoController has 3 methods show, foo, and bar, a correct restful implementation will result in the URLS: /reso /reso/foo /reso/bar Rails can help you do achieve this, and the solution is using members in your routes, exactly the way you described in your question. Using URLs such as /foo_reso or /bar_reso - in other words /action_controller is not Rails standard, and Rails base philosophy is "convention over configuration". So if you really need those you must declare them by hand

Categories : Ruby On Rails

Spring MVC REST: Method to Search Active Directory using LdapTemplate, LdapContextSource and SpringSecurityAuthenticationSource
http://forum.spring.io/forum/spring-projects/data/ldap/130283-search-active-directory-with-ldaptemplate-ldapcontextsource-sp-sec-auth-sou-rce dont use the DefaultValuesAuthenticationSourceDecorator, if you want to use only default user and password. The DefaultValuesAuthenticationSourceDecorator try to use the spring security user in session to perform the actions in LdapContext: Solution: <beans:bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"> <beans:constructor-arg ref="contextSource" /> <beans:property name="ignorePartialResultException" value="true" /> </beans:bean> <beans:bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"> <beans:property name="url" value="${ldap.url}" />

Categories : Spring

Spring Data Rest - Caching
The easiest way to implement this on the repository level is to use Spring's @Cacheable as it can be seen in the Spring Data JPA Examples project. Another option is to leverage HTTP Caching using the Apache HTTPD settings or a Varnish for example.

Categories : Caching

Spring data / Neo4j path length with large data sets
You're almost there :) Your first query is a full graph scan, which effectively loads the whole database into memory and pulls all nodes through this pattern match multiple times. So it won't be fast, also it would return huge datasets, don't know if that's what you want. The second query looks good, the only thing is that you cannot parametrize the min-max values of variable length relationships. Due to effects to query optimization / caching. So for right now you'd have to go with template.query() or different query methods in your repo for different max-values.

Categories : Java

Does Spring Data REST support JPA @Version?
I would say no, and that has not much to do with the use of Spring Data REST. You already mention you cannot set the version yourself as what happens then is undefined (I had this pleasant experience myself also). You basically have the same issue when posting normal form data and not storing the current version in the session (@SessionAttributes). What we ended up doing was that we wrote a hibernate interceptor (would be a listener now I guess) which does the checking (so that we could actually set the version field). This worked without to much problems (but that was about 6 years ago), so Hibernate might have changed and could be acting differently now.

Categories : Spring

EmberJS not making a request to get data from rest api
OK there are a few things going on here. First is that there is no route definition, that is where you specify how ember should lookup your model data. In this case you can specify an application route with a model hook that calls your api, like: App.ApplicationRoute = Ember.Route.extend({ model: function(){ return App.Response.find(); } }); With this in place ember will attempt to call your api. But the request will not be to the url you are expecting: instead it will call /myapp/stuff/list/responses since ember appends the pluralized model name to the adapter's base url. Finally if your api returns the above json ember will complain that Your server returned a hash with the key response but you have no mapping for it. By convention the API should be returning an array of resp

Categories : Javascript

How to update reference object in Spring-data rest?
How about something like this: curl -v -X PUT -H "Content-Type: text/uri-list" -d "http://localhost:7070/study-spring-data/teacher/1" http://localhost:7070/study-spring-data/course/123/teacher This is a way suggested by O'Reilly's Spring Data book.

Categories : Java

Spring security - securing method request with hasPermission
Yap, it is possible. You just need to switch to expression based evaluation  <security:http use-expressions="true"> and provide PermissionEvaluator to your expression handler: <security:expression-hanlder ref="webSecurityExpressionHandler" /> <bean id="webSecurityExpressionHandler" class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler> <property name="permissionEvaluator" ref="aclPermissionEvaluator" /> </bean> Of course you need to have PermissionEvaluator implementation. You can write your own or you can use spring-acl project.

Categories : Spring

Spring Data REST - Failed to Lazily Load collection
You can either enforce eager loading by configarion (e.g. with JPA annotation): @Fetch(value = FetchType.EAGER) or you can specify eager loading per select statement with HQL's join fetch select x from X left join fetch x.y y

Categories : Java

Just need a simple way to request rest data from my server from windows phone
try using HttpClient, it's less clunky and have friendlier syntax. There's no shortcut for getting data into the phone, minimally, you would have to create a class and deserialize the json string into objects. Several useful tools are available, such as JSON.net for deserialization and json2csharp for lazy people like u and me to create classes directly from json i would also reconsider putting the http request in other events, putting it within the loaded event would trigger it every time the user navigates back and forth

Categories : C#

Directly consuming Spring-Data-Rest repositories on Client side?
I assume your client is Java. It could be anything that can consume REST though. You could use RestTemplate in Spring to get the data from the server, and it can convert it into a class on the client for you. http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html

Categories : Spring

Can't override method (Flash Builder) - #1065 Variable Override is not defined
I solved it myself, kind of an strange error, but oh well. I had to press the cross icon that says "Remove Launch" and "Remove All Terminated Launches" next to the stop icon in the console tab. I even restarted my PC, tried project>clean, and restarted Flash Builder several times but only that fixed it. I leave this here just in case anyone meets the same error.

Categories : Actionscript

Spring MVC - Annotation based controller failed to find request handler method
The root cause was the purpleleaf-admin-1.0.0 on the url. util.AntPathRequestMatcher could not resolve the path correctly when it contains a dot(.). The class was not in the path until the security filter was added.

Categories : Rest

c# WCF HTTP rest client with WebHttpBinding/Behavior for POSTing RAW data in request body
I found the solution by adding the following code to my ClientBase inherited class: public class HttpXmlClient : ClientBase<IHttpXmlClient>, IHttpXmlClient { public void Send(Stream data) { using (new OperationContextScope((IContextChannel) Channel)) { var request = WebOperationContext.Current.OutgoingRequest; request.ContentType = "text/xml;charset=UTF-8"; Channel.Send(data); } } }

Categories : C#

Format of XML request data for REST POST command via power shell script
I don't think you are constructing the XML via strings correctly. You want to use a "here string" e.g.: $createacl = @" <AclRule xmlns='http://cloud.net/schemas/network'> <name>$newaclname</name> <position>$newaclposition</position> <action>$aclaction</action> <protocol>$protoltype</protocol> <sourceIpRange> <ipAddress>$SourceIP</ipAddress> <netmask>$SourceSubnetMask</netmask> </sourceIpRange> <destinationIpRange> <ipAddress>$DestIP</ipAddress> <netmask>$DestSubnetMask</netmask> </destinationIpRange> <portRange> <type>$portRange</type> <port1>$port1</port1>

Categories : Xml

why is there a need to override hashcode if I override equals method in java?
Go to this link The hashcode is used to maintain the contract and uniquely identify each object in hashmap or hashtable.

Categories : Java

Is returning data fields on successful REST API POST/PUT/DELETE request an acceptable best practice?
Yes, it is perfectly acceptable, and perhaps even desirable. REST, after all, stands for Representational State Transfer, and so there is nothing wrong in showing the state of the affected entity/entities after a state-change has been effected. You also minimize chatter by not requiring a subsequent GET request. You can also convey this if you have a semantic media-type defined for the result of this operation.

Categories : Ajax



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.