You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Chris Clarke <Ch...@talis.com> on 2006/04/10 15:14:02 UTC

[Chain] re: Problem with CatalogFactory - getCatalog() returns null

Hi all,

I'm having an issue with getting a Catalog from the CatalogFactory with Commons Chain. I've defined my own XML configuration file as follows:

<?xml version="1.0" ?>
<chains>
  <chain name="logon">
      <command name="CheckCredentials" className="com.talis.springbok.jsfspike.manager.logon.commands.CheckCredentials"/>
      <command name="RetrievePermissions" className="com.talis.springbok.jsfspike.manager.logon.commands.RetrievePermissions"/>
  </chain>
</chains>

I have some initialisation code that is in a ContextListener which is called when Tomcat starts up the web app:

public class ChainListener implements ServletContextListener
{
    public void contextInitialized(ServletContextEvent servletContextEvent)
    {
        String resource = servletContextEvent.getServletContext().getInitParameter("org.apache.commons.chain.CONFIG_CLASS_RESOURCE");
        try
        {
            ChainHelper ch = new ChainHelper();
            ch.init(resource);
        }
        catch (Exception e)
        {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}

which calls....

01    public void init(String resource) throws Exception
02    {
03       CatalogFactory cf = CatalogFactoryBase.getInstance();
04        ConfigParser parser = new ConfigParser();
05        parser.parse(this.getClass().getClassLoader().getResource(resource));
06        catalog = cf.getCatalog();
07    }

When I debug the code above with breakpoints:

line 05: The resource is correctly retrieved and the parser parses it without throwing an Exception. If I look into the ConfigParser object after this line has executed I can see that it has loaded in the class names of the commands defined in my XML file

line 06: This returns null! If I look inside the context factory it has a list of catalogs of size zero so the parser hasn't initialised the catalog into the factory!

Is there anything I am missing from my code and/or XML config file?

Thanks,

Chris
 

Reunite with Talis at the Library and Information Show, April 26th - 27th 

As a major sponsor of LiS, we are delighted to announce that we will be exhibiting and sponsoring the Reunion Bar at the centre of the exhibition hall. At booth 708, we will be unveiling details of Talis Source, our next generation community based service for resource discovery and resource sharing. At LiS, we will also showcase a range of new services powered by the Talis Platform including a directory service, data aggregation, enrichments and transaction services. 

Speaker Session 

Ken Chad, Executive Director will be presenting on Web 2.0 and the impact on libraries on Wednesday 10:20 in Theatre 1. This session is an ideal opportunity to find out more about library 2.0. For additional information view the conference programme. 

If you have not yet registered to attend LiS 2006, click here  and register online. 

Any views or personal opinions expressed within this email may not be those of Talis Information Ltd. The content of this email message and any files that may be attached are confidential, and for the usage of the intended recipient only. If you are not the intended recipient, then please return this message to the sender and delete it. Any use of this e-mail by an unauthorised recipient is prohibited.

Re: [Chain] re: Problem with CatalogFactory - getCatalog() returns null

Posted by Craig McClanahan <cr...@apache.org>.
On 4/10/06, Chris Clarke <Ch...@talis.com> wrote:
>
> Hi all,
>
> I'm having an issue with getting a Catalog from the CatalogFactory with
> Commons Chain. I've defined my own XML configuration file as follows:
>
> <?xml version="1.0" ?>
> <chains>
>   <chain name="logon">
>       <command name="CheckCredentials" className="
> com.talis.springbok.jsfspike.manager.logon.commands.CheckCredentials"/>
>       <command name="RetrievePermissions" className="
> com.talis.springbok.jsfspike.manager.logon.commands.RetrievePermissions"/>
>   </chain>
> </chains>


This configuration file is not creating any catalog names.  Try doing
something like this:

  <?xml version="1.0" ?>
  <chains>
    <catalog name="My Catalog">
      <chain name="logon">
        <command name="CheckCredentials"
                 className="
com.talis.springbok.jsfspike.manager.logon.commands.CheckCredentials"/>
        <command name="RetrievePermissions"
                 className="
com.talis.springbok.jsfspike.manager.logon.commands.RetrievePermissions"/>
      </chain>
    </catalog>
  </chains>

and you'll be able to call getCatalog("My Catalog") to pick up the entire
catalog (with only one chain in this case).

Craig