What I would like to find out is if we have a global datasource resource defined in the server as jdbc/datasource1 and if in the bean definition we have java:comp/env/jdbc/datasource1 as the jndiname will the web.xml resource ref USED or NOT. Will there be direct look up to JNDI or not? As the code seems to work without it even if i comment the web.xml resource references if we have a jndi name used in bean definition?
Also I think this should be the right bean definition and web.xml entries which will make use of web.xml references (Note: jdbc removed to avoid direct Jndi lookup)
The two are unrelated to each other. In the <bean> tag you are creating a Spring bean in the Spring container to be your DataSource that you looked up in JNDI. The web.xml entry has nothing to do with the Spring part. That is just something in the web.xml, not sure what you are using that for.
My question is if there is a global JNDI resource defined say jdbc/datasource and from bean definition if we have jndiname as java/comp/env/jdbc/datasource do we really need to have web.xml resource reference.
What is the use of resource reference in web.xml if entered?
Yeah, I don't see any purpose of having such an entry in the web.xml a DataSource shouldn't be accessed directly in any Web Layer, only in the DAO/Repository Layer which is responsible for querying should have access to a DataSource. Otherwise you have a brittle architecture and will take more time and money to maintain, change, and be scalable.