Spring Boot - Why it does not consider project name as context for the dispatcher servlet mapping - spring-mvc

Just like Spring MVC when we used deploy the application in the servlet container it is used to pickup the project name as servlet context and then as per our servlet mapping the container will process the request.
Here my question is i created spring-boot rest application having crud operations and deployed in tomcat server. But when i try to access any url like [http://localhost:8080/findAllRecords] then the server return 404 error request url not found but i add extra / in the url[http://localhost:8080//findAllRecords] it successfully execute the request.

Related

Camel to route external REST web service

I'm working on spring MVC and using Apache camel to integrate external services.
I wanted to use Apache Camel route to make a Webservice call.
Like my local REST service (http://localhostsmiliex.xx:8080/users) fetching data from external REST service (http://xxx:000/users) and wanted routing to fetch external data.
Which Apache component would be suitable for a web-service route such as Jetty or producer template?
Have you tried HTTP4 or HTTP ?
http://camel.apache.org/http4.html
Use ProducerTemplate, it works like a charm for calling external endpoints REST, DB, SOAP etc..
You can either autowire it
#Autowired
ProducerTempalete prodcuerTemplate
prodcuerTemplate.sendBody("http://xyz...", "<hello>world!</hello>");
or
ProducerTemplate template = exchange.getContext().createProducerTemplate();
// send to default endpoint
template.sendBody("<hello>world!</hello>");
// send to a specific queue
template.sendBody("http://xyz...", "<hello>world!</hello>");

Could not resolve view with name 'forward:/oauth/confirm_access' error in Spring OAuth2

I'm getting the following error in Spring OAuth2:
javax.servlet.ServletException: Could not resolve view with name 'forward:/oauth/confirm_access' in servlet with name 'dispatcherServlet'
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1237) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) ~[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE]
By debugging in Spring impelmentation I noticed that it is hardcoded this view name. Shouldn't it be implemented in Spring? I suppose I shall not build that view and is just a matter of configuration.
My OAuth2 authorization server and resource servers are properly configured, so I skiped that part.
Is there a configuration that handles this view?
Thanks.
P.S I am using Postman client to generate token.
I just found the problem.
The client should have autoApprove flag set on true.

Is there a component in camel for a service built on Spring RestTemplate?

I have a REST Service running in Tomcat server. I created this REST Service using Spring RESTTemplate. So is there a component in CAMEL to use this exposed Web service?
i have used http component. i am aware that we cannot use http component to expose a service. So please let me know which component to use.Here is a detailed description of the problem.
Service created in rest Template runs in a server which you can see in from part of camel code
i use camel to expose this service to another http service and the response of this service is the response from the other service.
so my camel code looks like this:
from("http://localhost:8080/rest/emp/dummy").to(http://anotherweservice.com")
I get this error.
Failed to create route route1: Route(route1)[[From[]] -> [process[com.routes..... because of uri must be specified and not empty
Have a look at http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html.
Using the Jetty component, this looks as follows:
from("jetty:http://0.0.0.0:8080/myapp?matchOnUriPrefix=true")
.log("myapp: httpPath = ${header.CamelHttpPath}")
.to("jetty:http://localhost:8082/remoteapp?bridgeEndpoint=true&throwExceptionOnFailure=false")
In this example, the request is forwarded to another Jetty Camel endpoint:
from("jetty:http://0.0.0.0:8082/remoteapp?matchOnUriPrefix=true")
.log("remoteapp: httpPath = ${header.CamelHttpPath}")
.setBody(simple("${header.CamelHttpPath}"));
The HTTP path /hello/world is transfered to the endpoint, as can be seen when the service is invoked with http://localhost:8080/myapp/hello/world. In this case the body /hello/world is returned. And in the log it says:
INFO myapp: httpPath = /hello/world
INFO remoteapp: httpPath = /hello/world

HTTPListener and servlet

We have an servlet which sends messages to a queue.
It gets the message from a request object it got from Paypal.
The servlet is called IPNServlet.
Note that this is a standalone servlet which is not a part of any MDB.
For some reason the following mapping in my web.xml does not work (requests to this servlet bundled in the WAR file on JBoss EAP 5.1 are not handled)
<servlet-name>IPNServlet</servlet-name>
<servlet-class>com.temenos.paypal.servlet.IPNServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<servlet-mapping>IPNServlet</servlet-mapping>
<url-pattern>/IPNServlet</url-pattern>
By the way of this web.xml, shouldnt a request made to https:// HOSTNM:8443/IPNServlet be processed as expected ?
Where HOSTNM is the name of the IP.
Is there a separate HTTP Listener that is needed ?

Thinktecture.IdentityModel.45, Routing, wants to invoke identity controller

I'm trying to use Thinktecture.IdentityModel.45 for authentication in ASP.NET Web API.
I'm trying to get the Basic Authentication to work. And have downloaded the source and got the sample to work. (JsBasicAuth).
We have Web API in the same project as a MVC application. And when the test client calls ~/api/identity all handlers and authorization work. But then the framework (web api) tries to invoke a controller called "identity" and the call fails.
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost/app/api/identity'.","MessageDetail":"No type was found that matches the controller named 'identity'."}
Do I need to exclude /identity /token from the routing? What am I missing?
I now discovered the Common project in the sample solution. There is a IdentityController there. And I didn't have that in my own project. Now it works! :)

Resources