On Thu, Feb 12, 2009 at 8:06 AM, Thomas Fromm <[email protected]> wrote: > On Thursday 12 February 2009 05:14, ken.p wrote: >> I ran to issue: >> Exception in thread "main" javax.jcr.NamespaceException: : is not a >> registered namespace >> >> when using IBM jdk, it works fine on Sun jdk. Any work around available as >> deployment environment will be on IBM jdk. > > The problem is, that the IBM JDK allow no empty keys inside their property > files. > > There exists a issue for Jackrabbit, but ATM nobody wants to fix it.
here's the issue: http://issues.apache.org/jira/browse/JCR-888 i agree that there hasn't been a lot of enthousiasm to fix this issue. i would argue that this is a rather exotic issue which doesn't affect the majority of the users. it only occurs with the ibm jvm and the workaround is to use another jvm (e.g. sun's). OTOH i agree that it should be fixed eventually. feel free to contribute a patch which doesn't break compatibility. see my related comment on the issue. > I wrote an ugly workaround, which works for me. > (Normally you need also to extend/modify > org.apache.jackrabbit.core.query.lucene.FileBasedNamespaceMappings.java, but > thats not nessesary for me.) > Unfortunality the jackrabbit creators likes to use of private methods/members. > So extending their code is mostly impossible. i would argue that access modifiers in jackrabbit core have been chosen thoughtfully in general. the jackrabbit core classes are not primarily designed to be extensible. there are specific APIs that can be implemented. if a member or method has been declared private there's probably a good reason for it (e.g. the implementation might change in the future and therefore potentially break subclasses etc). cheers stefan > > public static class DefaultRepository extends RepositoryImpl implements > Repository { > > public DefaultRepository(RepositoryConfig config) throws Exception { > super(config); > } > > protected NamespaceRegistryImpl createNamespaceRegistry(FileSystem fs) > throws RepositoryException { > return new MyNamespaceRegistryImpl(fs); > } > } > > public class MyNamespaceRegistryImpl extends NamespaceRegistryImpl { > > > protected MyNamespaceRegistryImpl(FileSystem nsRegStore) > throws RepositoryException { > super(nsRegStore); > } > > public void unregisterNamespace(String prefix) > throws NamespaceException, > UnsupportedRepositoryOperationException, > AccessDeniedException, RepositoryException { > if("".equals(prefix)){ > return; > } > super.unregisterNamespace(prefix); > } > > public String[] getPrefixes() throws RepositoryException { > List<String> prefixList=new ArrayList<String>(); > for(String prefix : super.getPrefixes()){ > prefixList.add(prefix); > } > if(!prefixList.contains("")){ > prefixList.add(""); > } > return prefixList.toArray(new String[0]); > } > > public String[] getURIs() throws RepositoryException { > List<String> uriList=new ArrayList<String>(); > for(String uri : super.getPrefixes()){ > uriList.add(uri); > } > if(!uriList.contains("")){ > uriList.add(""); > } > return uriList.toArray(new String[0]); > } > > public String getURI(String prefix) throws NamespaceException { > if("".equals(prefix)){ > return ""; > } > return super.getURI(prefix); > } > > public String getPrefix(String uri) throws NamespaceException { > if("".equals(uri)){ > return ""; > } > return super.getPrefix(uri); > } > } > > >
