The missing code:

  | public class InitializerContextLoaderListener extends ContextLoaderListener 
{
  | 
  |     @Override
  |     public void contextInitialized(ServletContextEvent event) {
  |         
JndiRootApplicationContextLookup.initialize(event.getServletContext());
  |         super.contextInitialized(event);
  |     }
  | 
  | }
  | 
  | public class JndiRootApplicationContextLookup {
  | 
  |     private static final Log log = 
LogFactory.getLog(JndiRootApplicationContextLookup.class);
  |     public static final String ROOT_JNDI_APP_CONTEXT_KEY = 
"RootJndiApplicationContextKey";
  |     public static final String DEFAULT_ROOT_APP_CONTEXT_JNDI_NAME = 
"RootJndiApplicationContextName";
  | 
  |     private static String JNDI_NAME;
  | 
  |     public static String jndiName() {
  |         return JNDI_NAME;
  |     }
  | 
  |     public static void initialize(ServletContext servletContext) {
  |         String jndiName = DEFAULT_ROOT_APP_CONTEXT_JNDI_NAME;
  |         if (servletContext.getInitParameter(ROOT_JNDI_APP_CONTEXT_KEY) != 
null) {
  |             jndiName = 
servletContext.getInitParameter(ROOT_JNDI_APP_CONTEXT_KEY);
  |         }
  |         if (JNDI_NAME != null && !JNDI_NAME.equals(jndiName)) {
  |             log.warn("Jndi name already initialized with different name: " 
+ JNDI_NAME + " / " + jndiName);
  |         }
  |         JNDI_NAME = jndiName;
  |     }
  | 
  |     public static Object lookup(String beanName) throws Exception {
  |         JndiTemplate jndiTemplate = new JndiTemplate();
  |         ApplicationContext ac = (ApplicationContext) 
jndiTemplate.lookup(JNDI_NAME, ApplicationContext.class);
  |         return ac.getBean(beanName);
  |     }
  | 
  | }
  | 

Try it now, and let me know.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135917#4135917

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135917
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to