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.
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.
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);
}
}