Announcement Announcement Module
No announcement yet.
ApplicationContext initialization with an authenticated user Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ApplicationContext initialization with an authenticated user

    Dear Spring Community

    In one of our current projects, we have the customer requirement, that JNDI resources cannot be accessed anonymously, but only within a servlet that is authenticated against a user defined in the deployment descriptor. As we need to access various JNDI resources during ApplicationContext init, and the ContextLoaderListener (in fact any listener) is not run as a configurable user, we would need to go back to "Spring 2 Style", initializing the ApplicationContext within a Servlet instead of a listener.

    What I would like to know now is if there is a common way to do that in Spring 3. I know the ServletContextLoader was deprecated and I think removed from Spring 3. I would like to write as few lines as code as possible. Probably there is a ready-made class I do not know about, that still does the job of initializing the AC within a servlet, without programmatically doing it myself. Of course I would like to keep the contextConfigLocation context-param intact.

    Ideally, this particular customer would only receive a different web.xml and nothing more.

    Thank you in advance

    ~ Nils

  • #2
    You may want think about using Spring's DispatcherServlet. it runs in its own namespace with its own application context.
    	<servlet-name>jndi resource</servlet-name>
    Hope this helps


    • #3
      So more or less, even if we do not use the Dispatcher Servlets functionality for Spring MVC, use it to load the AC?

      Will that AC be available to other Servlets in the same WAR and web.xml?


      • #4
        @Inject does have the advantage of being a JSR, so it can Sac Longchamp be used without the Spring framework, although how widely is it used or known of? I first saw it used in a GemFire demo not long ago I believe, and then once again at S2GX. I have not used it myself (yet). I think for users new to the Spring framework and DI in general, they'll probably use @Autowired based on what they Sac Longchamp Pas Cher learn in the Spring documentation or tutorials. Would be great to see some kind of blog post comparing the equivalent use of both.