Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

FactoryFinder.getFactory() returns null

843842May 21 2004 — edited May 24 2004
I'm trying to make a ServletContextListener that will add my custom lifecycle to the default lifecycle factory with a specified key. However, when I try to get the LifecycleFactory from within the ServletContextListener, the FactoryFinder returns null. I didn't think this was supposed to happen, but I consulted the source and discovered that that would probably be the case. However, another quandry came about after looking at the source. I don't really understand where in the FactoryFinder it gets the default implementations. It seems that unless there is some initialization going on outside the FactoryFinder class, the FactoryFinder should always return null no matter what. What's the deal?


Here is the code below:
public void contextInitialized(ServletContextEvent event) {
	try	{
	
	
	// get this application's LifecycleFactory
                     // lifecycleFactory will be null
	LifecycleFactory lifecycleFactory = (LifecycleFactory)
        FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    
    // get the default Lifecycle
    // throws NullPointerException
    Lifecycle lifecycle =
        lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
        
    // create a new ApplicationLifecycle from the default Lifecycle
	ApplicationLifecycle appLifecycle = new ApplicationLifecycle(lifecycle);
	
	// add the ApplicationLifecycle to the LifecycleFactory with an id
	// corresponding to the ApplicationLifecycle's fully qualified name.
	lifecycleFactory.addLifecycle(ApplicationLifecycle.class.getName(), appLifecycle);
	} catch (Throwable t) {
		System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
		t.printStackTrace(System.out);
		throw new RuntimeException(t.getMessage());
	}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 21 2004
Added on May 21 2004
2 comments
127 views