You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "kazim_ssuet@yahoo.com" <ka...@yahoo.com> on 2010/10/13 17:07:57 UTC

Local vs Remote access while creating Namespace and Node Types

I have following code that creates a new namespace:

NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry();
nsReg.registerNamespace("csi", "http://www.csi.com");

I created namespace using local access (creating repository using
repository.xml location and repository folder).

Question 1: This namespace (created as local access) is not visible in
remote access when I run standalone server and use RMI API, why?

I had to register namespace again using remote repository access through
RMI.

Question 2: Why do I have to create namespace in same repository for each
access type? it is same repository no matter how you access it, right?

Then I tried to create new node types using following code:

JackrabbitNodeTypeManager  manager = (JackrabbitNodeTypeManager )
session.getWorkspace().getNodeTypeManager();
manager.registerNodeTypes(new FileInputStream(cndFileName),
JackrabbitNodeTypeManager.TEXT_X_JCR_CND);

Turned out I couldn't register node types using above code through RMI, so
ran it using local access. Nodes types were loaded fine. But still those
node types created through local access are not available remotely.

Question 3: If there is no way to create node types remotely, and node types
created locally are no visible remotely, then how can I create node types
that are available remotely?

I tried creating node (using local access) of newly created node types
locally and was able to create nodes then I tried to browse repository using
http://localhost:8080/ provided by standalone server and there was nothing
in standalone server's repository. I could fetch nodes through API (using
local access), so nodes are there.

Question 4: Why nodes created using local API access are not visible through
standalone server's http access?

Seems like standalone server and locally accessed API are running against
different repositories? Is it possible? I must be doing something wrong

In case I am doing something wrong while getting repositories I am posting
the code that I use to get local and remote repository below.

My repository.xml is at:
C:\JCR\jackrabbit\repository.xml

My standalone server is at:
C:\JCR\jackrabbit-standalone.jar

Standalone server created this folder when ran first time:
C:\JCR\jackrabbit

Here are the two methods that I use to get local and remote repositories:

private static Repository getRemoteRepository() throws MalformedURLException
{
	return (Repository) new URLRemoteRepository("http://localhost:8080/rmi");
}
	
private static Repository getLocalRepository() throws NamingException,
RepositoryException
{
	String configFile = "C:\\JCR\\jackrabbit\\repository.xml";
	String repHomeDir = "C:\\JCR\\jackrabbit\\repository";

	Hashtable env = new Hashtable();

	env.put(Context.INITIAL_CONTEXT_FACTORY,
 		 "org.apache.jackrabbit.core.jndi" +
 		 ".provider.DummyInitialContextFactory");

	env.put(Context.PROVIDER_URL, "localhost");

	InitialContext ctx = new InitialContext(env);

	RegistryHelper.registerRepository(ctx,
			 "repo",
			 configFile,
			 repHomeDir,
			 true);

	return (Repository) ctx.lookup("repo");
}

I am cluless, please help.
-- 
View this message in context: http://jackrabbit.510166.n4.nabble.com/Local-vs-Remote-access-while-creating-Namespace-and-Node-Types-tp2993831p2993831.html
Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.

Re: Local vs Remote access while creating Namespace and Node Types

Posted by "kazim_ssuet@yahoo.com" <ka...@yahoo.com>.
Got it.
The repository home directory I was using when accessing repository locally
was "C:\JCR\jackrabbit\repository" while Standalone server was using
"C:\JCR\jackrabbit". 
-- 
View this message in context: http://jackrabbit.510166.n4.nabble.com/Local-vs-Remote-access-while-creating-Namespace-and-Node-Types-tp2993831p2994210.html
Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.

Re: Local vs Remote access while creating Namespace and Node Types

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Wed, Oct 13, 2010 at 5:07 PM, kazim_ssuet@yahoo.com
<ka...@yahoo.com> wrote:
> Question 1: This namespace (created as local access) is not visible in
> remote access when I run standalone server and use RMI API, why?

It seems likely that your standalone server is not accessing the same
repository as the one you created locally. Please double-check your
configuration.

The RMI layer simply proxies the remote JCR API calls to the server,
so there's no reason why it would behave differently than a local
client as long as you're actually accessing the same repository.

This most likely explains all the other oddities you mentioned.

BR,

Jukka Zitting