You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by "Pill, Juergen" <Ju...@softwareag.com> on 2001/01/11 19:12:23 UTC

StandardStore init (AbstractStore.java)

Hello,

I found following problem in the init phase of Slide:

1) If Slide is initialized with following snipplet in the domain.ini file
      <store name="memory">
        <!--nodestore name="jdbc"
         classname="slidestore.reference.MemoryDescriptorsStore">
        </nodestore>
        <securitystore>
          <reference store="nodestore" />
        </securitystore>
        <lockstore>
          <reference store="nodestore" />
        </lockstore>
        <revisiondescriptorsstore>
          <reference store="nodestore" />
        </revisiondescriptorsstore>
        <revisiondescriptorstore>
          <reference store="nodestore" />
        </revisiondescriptorstore-->
        <contentstore name="file"
         classname="slidestore.reference.FileContentStore">
          <parameter name="rootpath">files</parameter>
        </contentstore>
      </store>
Following exception is raised:
	java.lang.NullPointerException
	at
org.apache.slide.store.AbstractStore.addResourceManager(AbstractStore.java:8
90)
	at
org.apache.slide.store.AbstractStore.setSecurityStore(AbstractStore.java:423
)
	at
org.apache.slide.common.Namespace.registerStore(Namespace.java:260)
	at
org.apache.slide.common.Namespace.loadScopeDefinition(Namespace.java:920)
	at
org.apache.slide.common.Namespace.loadDefinition(Namespace.java:555)
	at org.apache.slide.common.Domain.initNamespace(Domain.java:464)
	at org.apache.slide.common.Domain.init(Domain.java:228)
	at
org.apache.slide.webdav.WebdavServlet.init(WebdavServlet.java:348)
	at javax.servlet.GenericServlet.init(GenericServlet.java:258)
	at
org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
	at org.apache.tomcat.core.Handler.init(Handler.java:215)
	at
org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296)
	at
org.apache.tomcat.context.LoadOnStartupInterceptor.contextInit(LoadOnStartup
Interceptor.java:130)
	at
org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:443)
	at
org.apache.tomcat.core.ContextManager.init(ContextManager.java:403)
	at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:197)
This is caused because the method Namespace.registerStore gets a null
pointer from the HashTable and sets this null pointer into the AbstractStore
(as the securityStore). This works fine for the very first store, but not
for the second call of addResourceManager


2) The method  AbstractStore.initialize loads the defaultStore, independent
if that class is needed or not.

I suggest following changes:

1) add a set of private void setXXXStore(String) methods with following
body:
	private void setNodeStore(String nodeStore) {
		setNodeStore((NodeStore)getDefaultStoreInstance(nodeStore));
    }
2) if in the original setXXXStore method the pointer is null, call the new
setXXXStore method.
    public void setSecurityStore(SecurityStore securityStore) {
        this.securityStore = (securityStore!=null) ? 
        	(securityStore) : 
        	((SecurityStore)getDefaultStoreInstance(defaultStore));
        addResourceManager(securityStore);
    }
3) the method getDefaultStoreInstance would look like this:
	private Service getDefaultStoreInstance(String defaultStore) {
		
		if (defaultStoreInstance != null) return
defaultStoreInstance;
		
		try {
            defaultStoreInstance =
                (Service) Class.forName(defaultStore).newInstance();
            defaultStoreInstance.initialize(token);
        } catch (Throwable t) {
            // Should never happen ...
            t.printStackTrace();
        }
		
		return defaultStoreInstance;
	}


This will solve both problems (to my opinion).

Remy, could you please verify this, if I have not introduced any side
effects? 

I have not checked in the changes, because there is still an error which I
can not resolve. During the old setXXXStore methods no token is available,
which is needed to initialize the default store. Do you have a solution for
this. I have attached the changed file to this mail. Hope it helps.


Thanks in advance

Juergen Pill


 <<AbstractStore.java>>