Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Spring Hibernate JNDI look up question?

 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends
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)



Please can you comment your thaughts in it?
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't figure out what the question is.

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.

Mark
 
Mohamed Farouk
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mark
Thanks for your reply on this.

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?

Regards
Mohamed
 
Ranch Hand
Posts: 88
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well spring doesn't bothers about entry in web.xml
It only bothers that container (webserver) should have that jndi.

Also, even in a simple servlet, you can refer a datasouce via jndi name without declaring into web.xml
 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Mark
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic