users@glassfish.java.net

Injection failure on second .war... what am I missing???

From: <glassfish_at_javadesktop.org>
Date: Fri, 16 Nov 2007 01:27:22 PST

I have an enterprise application, in my .ear I have 1 ejb .jar and 1 .war. My .war has one ServletContextListener that takes injection of a couple remote ejb's. Everything is fine so far...

But I added a second .war (jForum, actually), and I added a ServletContextListener to that .war. The code in the new listener is very similar to the listener in the first .war, and attempts to inject the same ejb classes as the first listener. I added all necessary libraries to the second war as well. I also thoroughly cleaned out my build and rebuilt from scratch. However:

Resource injection works fine in the original ServletContextListener, and not at all in the new one. I'm getting no errors from glassfish, other than the ones generated by my code due to missing resources. Everything in the new .war behaves as if it weren't even a managed class.

For reference, I'm running Sun Java System Application Server 9.1 (build b50g-beta3) - (Glassfish) ... I realize there is a newer version, but there's a very high likelihood that this is my problem.

Here's relevant parts of the code from the context listeners -

Original

package VCMarkWeb;
 
import java.util.concurrent.*;
import javax.annotation.Resource;
import javax.ejb.*;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContext;
 
import vyper.log.Log;
import VCMarkWeb.log.LogEJB;
import vyper.log.LogSysout;
 
public class Startup implements ServletContextListener {
        
    private Log log;
    private int logLevel;
    
    @EJB
    private LogEJB logEJB;
    
    @Resource (name="SystemID")
    private String _systemID = "SystemID not set";
    
    public void
    logout(
            String sOut
    ){
        log.out("Startup." + sOut, logLevel);
    }
    
    public void contextInitialized(ServletContextEvent evt) {
                
        final ServletContext servletContext = evt.getServletContext();
        Runnable runnable = new Runnable(){
            public void run(){
                    doInit(servletContext);
            }
        };
        
        Thread initThread = new Thread(runnable);
        initThread.start();
        
    }
    
    private void
    doInit(
            ServletContext servletContext
    )
    {
        if (servletContext == null)
            throw new NullPointerException("Startup.doInit(): null servlet context.");
        
        log = new LogSysout();
            logout("doInit(): Init begins.");
        
        if (logEJB != null){
            logout("doInit(): Attached to LogServer. Further messages will be directed to LogServer.");
            log = logEJB;
        }
        else {
            logout("doInit(): Error configuring log output.");
        }
        log.setID(_systemID);
        servletContext.setAttribute("log", log);
                
        logout("doInit(): Logging begins.");
        //...
        logout("doInit(): Done.");
    }
}



the second ServletContextListener includes the same libraries, and does basically the same thing. Injection that works in the first fails for the second, even with the same ejbs.

Any and all assistance is greatly appreciated. Thanks!
[Message sent by forum member 'dcaudell' (dcaudell)]

http://forums.java.net/jive/thread.jspa?messageID=245775