Kiran Tiwari

Greenhorn
+ Follow
since Nov 29, 2017
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kiran Tiwari

[size=12]The core error in the stack trace is
javax.naming.NameNotFoundException: Error looking up DRSCM1, service service jboss.naming.context.java.DRSCM1 is not started

The JNDI lookup of the datasource is failing on the Application Server.
According to your spring+hibernate configuration provided, the datasource is mapped to JNDI name java:/DRSCM1
Check your datasource configuration, specifically the JNDI name configured for the same on the server (looks like its a JBOSS AS from the stack trace).
That JNDI name should match with the datasource JNDI name configured in your spring beans and hibernate file.
Also check if your datasource is started up and up and running. Check the status of the same on the JBOSS server.


Regards
Kiran Tiwari

www.sevenmentor.com
6 years ago
In the code snippet you have provided, there is an inherent link between class A & B since they have a linked base mapping. This indicates that there is some commonality at the base class/interface level . You need to manifest and implement the same in the code as well.
You can have both the classes implement the same Interface/base class and provide base RequestMapping there.
You can then have just the method level RequestMapping in the implementation classes.

@RequestMapping("/base")
public interface BaseRestInterface{
}

@RestController
public class A implements BaseRestInterface{

 @RequestMapping("/first")
  methodA(){
}
}

@RestController
public class B implements BaseRestInterface{

 @RequestMapping("/second")
  methodB(){
}

 @RequestMapping("/third")
  methodC(){
}
}

The org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping would register the URLs while scanning the controller classes. You should see the below messages in the Tomcat console/logs:

INFO: Mapped "{[/base/first]}" onto ...A.methodA()
INFO: Mapped "{[/base/second]}" onto ....B.methodB()
INFO: Mapped "{[/base/first]}" onto ...C.methodC()

Ensure you use latest spring framework jars (Spring 5+ would be best, I think 4.3+ at least)



With Regards
Kiran Tiwari

www.sevenmentor.com
6 years ago
Statelessness is being able to service the request independently without any requirement to remember any previous interactions.

In the example you have provided,

https://localhost:8080/UserManagement/rest/UserService/users/1

The restful service implementation that handles this request does not need to remember or know about any previous interaction with the client invoking the service.
All the information it needs to serve or process the request is provided and available in the request itself. It needs the user id, which it gets from the request URL itself and it is 1, it fetches the user details and returns the XML response.
For stateless services, if you need to change the response you would need to change the request details or the context values you pass in the request (so in addition to the URL it could also be the HTTP request headers like content type or Accepts, etc)
6 years ago