users@jax-rpc.java.net

[REPOST] ServletContextListener and WS (Servlet) initialization (JAXRPC runtime initialization)

From: Kresimir Kers (ZG/ETK) <"Kresimir>
Date: Thu, 16 Dec 2004 09:01:57 +0100

Hello all again,
 
sorry for reposting but this is very important to me.
 
If I was not clear enough in previous mail the problem is (I presume) in implementation of JAX-RPC. I look at the source and see that some of properties of JAX-RPC (like endpoint info for example) are set in class JAXRPCContextListener. Those properties are used in class JAXRPCServletDelegate (in its init(...) method that is called from JAXRPCServlet init(..) method).
When I integrate JWSDP with Sun JES App Server it works fine but when I try to use it with BEA Web Logic it seems that contextInitialized(...) method of JAXRPCContextListener class is called when init(...) method JAXRPCServlet returns (in case of BEA, in case of Sun it is called while method is executing). This cause problems because some parameters set in JAXRPCContextListener are used in JAXRPCServlet (JAXRPCServletDelegate ) before they are initialized.
 
I know that you only support Tomcat and Sun containers but as a reference implementation JAX-RPC should be some kind of proof of the concept for any container (at least for leading containers on the market).
So my question is when Context Listener should be invoked. If it is strictly defined and it should work as it work in Sun JES App Server and Tomcat then JAX-RPC can rely on Context Listeners but if it is not true or it is not strictly defined then you should consider rework because it will not work on some containers.
I am also passing code snippets of JAX-RPC implementation where I saw problems.
 
 
JAXRPCServlet class
 
 
public void init(ServletConfig servletConfig) throws ServletException {
         //KRESIMIR comment
        //In case of Sun App server and Tomcat it seems that JAXRPCContextListener
        //contextInitialized(...) method is invoked when following line returns.
        super.init(servletConfig);
 
        
       try{
            .....................
            //KRESIMIR comment
            //All starts Here by calling JAXRPCServletDelegate class init method
            delegate.init(servletConfig);
 
        } catch (ServletException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            throw e;
        } catch (Throwable e) {
            String message =
                localizer.localize(
                    messageFactory.getMessage(
                        "error.servlet.caughtThrowableInInit",
                        new Object[] { e }));
            logger.log(Level.SEVERE, message, e);
            throw new ServletException(message);
        }
    }
 
JAXRPCServletDelegate class
 
public void init(ServletConfig servletConfig, SOAPVersion ver)
        throws ServletException {
        ......................
        //KRESIMIR comment
        //Attributes of JAXRPC runtime are read here
        //Some of those attributes are set in contextInitialized(...) method
        //of JAXRPCContextListener class.
        //In case of BEA container contextInitialized(...) method is not yet invoked so
        //method returns null and in following line initialization
        //fails.
        jaxrpcInfo =
            (JAXRPCRuntimeInfo) servletContext.getAttribute(
                JAXRPCServlet.JAXRPC_RI_RUNTIME_INFO);
        if (jaxrpcInfo == null) {
            warnMissingContextInformation();
        } else {
           ...............................
                }
            }
        }
 
     ...................................
   }
}
 
JAXRPCContextListener class
 
public void contextInitialized(ServletContextEvent event) {
        context = event.getServletContext();
 
        .............................
 
        try {
            JAXRPCRuntimeInfoParser parser =
                new JAXRPCRuntimeInfoParser(classLoader);
            InputStream is = context.getResourceAsStream(JAXRPC_RI_RUNTIME);
            JAXRPCRuntimeInfo info = parser.parse(is);
 
            
            //KRESIMIR comment
            //Attributes of JAXRPC runtime are set here. In case of BEA too late :-).
            context.setAttribute(JAXRPCServlet.JAXRPC_RI_RUNTIME_INFO, info);
        } catch (JAXRPCServletException e) {
            ..........................
        }
    }