You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Vidar Ramdal <vi...@idium.no> on 2008/03/10 11:27:12 UTC

Running over RMI and registering nodetypes

I'm trying to set up sling to use a remote JCR repository, by using
the sling.repository.url system property.

Sling is able to locate and connect to the repository, but fails
org.apache.sling.jcr.base.internal.loader.Loader#registerBundleInternal,
line #165, while attempting to register node types. The error reported
on the RMI server side is
java.lang.NoClassDefFoundError
	at org.apache.jackrabbit.core.RepositoryImpl.getSystemSearchManager(RepositoryImpl.java:625)
	at org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.getSearchManager(RepositoryImpl.java:1613)
	at org.apache.jackrabbit.core.RepositoryImpl.initWorkspace(RepositoryImpl.java:606)
	at org.apache.jackrabbit.core.RepositoryImpl.initStartupWorkspaces(RepositoryImpl.java:415)
	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:305)
	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:557)
	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:245)
	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:265)
	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:333)
	at org.apache.jackrabbit.rmi.server.ServerRepository.login(ServerRepository.java:104)

RepositoryImpl#625 is where Jackrabbit attempts to create a
SearchManager, using a NodeTypeRegistry as one of the parameters. This
leads me to suspect that the error has to do with
http://issues.apache.org/jira/browse/JCR-585 - that the
NodeTypeRegistry is not available via the "normal" RMI interfaces.

What would be the easisest way to get Sling running on a remote JCR?

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway

Re: Running over RMI and registering nodetypes

Posted by Vidar Ramdal <vi...@idium.no>.
On 3/12/08, Felix Meschberger <fm...@gmail.com> wrote:

>  After looking at your stack trace again, I think this is not an RMI
>  problem (we have the RMI problem discussed here, though) but a problem
>  of starting up the TransientRepository on the server side. So this, IMHO
>  has nothing to do with RMI and Sling but rather with some potentially
>  missing libraries on the server side...

Ah, you're probably right. I copied the entire
NodeTypeLoader.registerNodeType method over to the RMI server, and ran
it there. It still fails, but now it gives me the *name* of the class
that is NotFound. Jeez, I hate debugging RMI servers ... :(

Anyway, glad the *real* RMI stuff is getting fixed. Thanks!

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway

Re: Running over RMI and registering nodetypes

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

oops, sorry about my previous post, I clicked send too early ...

After looking at your stack trace again, I think this is not an RMI
problem (we have the RMI problem discussed here, though) but a problem
of starting up the TransientRepository on the server side. So this, IMHO
has nothing to do with RMI and Sling but rather with some potentially
missing libraries on the server side...

Maybe this would be something for the Jackrabbit list ?

WDYT ?

Regards
Felix

Am Montag, den 10.03.2008, 11:27 +0100 schrieb Vidar Ramdal:
> I'm trying to set up sling to use a remote JCR repository, by using
> the sling.repository.url system property.
> 
> Sling is able to locate and connect to the repository, but fails
> org.apache.sling.jcr.base.internal.loader.Loader#registerBundleInternal,
> line #165, while attempting to register node types. The error reported
> on the RMI server side is
> java.lang.NoClassDefFoundError
> 	at org.apache.jackrabbit.core.RepositoryImpl.getSystemSearchManager(RepositoryImpl.java:625)
> 	at org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.getSearchManager(RepositoryImpl.java:1613)
> 	at org.apache.jackrabbit.core.RepositoryImpl.initWorkspace(RepositoryImpl.java:606)
> 	at org.apache.jackrabbit.core.RepositoryImpl.initStartupWorkspaces(RepositoryImpl.java:415)
> 	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:305)
> 	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:557)
> 	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:245)
> 	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:265)
> 	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:333)
> 	at org.apache.jackrabbit.rmi.server.ServerRepository.login(ServerRepository.java:104)
> 
> RepositoryImpl#625 is where Jackrabbit attempts to create a
> SearchManager, using a NodeTypeRegistry as one of the parameters. This
> leads me to suspect that the error has to do with
> http://issues.apache.org/jira/browse/JCR-585 - that the
> NodeTypeRegistry is not available via the "normal" RMI interfaces.
> 
> What would be the easisest way to get Sling running on a remote JCR?
> 


Re: Running over RMI and registering nodetypes

Posted by Vidar Ramdal <vi...@idium.no>.
Hate to be a pain in the ***, but this issue is preventing me from
making use of Sling.

Has anyone successfully set up Sling with a remote JCR lately?

On 3/10/08, Vidar Ramdal <vi...@idium.no> wrote:
> I'm trying to set up sling to use a remote JCR repository, by using
>  the sling.repository.url system property.
>
>  Sling is able to locate and connect to the repository, but fails
>  org.apache.sling.jcr.base.internal.loader.Loader#registerBundleInternal,
>  line #165, while attempting to register node types. The error reported
>  on the RMI server side is
>  java.lang.NoClassDefFoundError
>         at org.apache.jackrabbit.core.RepositoryImpl.getSystemSearchManager(RepositoryImpl.java:625)
>         at org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.getSearchManager(RepositoryImpl.java:1613)
>         at org.apache.jackrabbit.core.RepositoryImpl.initWorkspace(RepositoryImpl.java:606)
>         at org.apache.jackrabbit.core.RepositoryImpl.initStartupWorkspaces(RepositoryImpl.java:415)
>         at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:305)
>         at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:557)
>         at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:245)
>         at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:265)
>         at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:333)
>         at org.apache.jackrabbit.rmi.server.ServerRepository.login(ServerRepository.java:104)
>
>  RepositoryImpl#625 is where Jackrabbit attempts to create a
>  SearchManager, using a NodeTypeRegistry as one of the parameters. This
>  leads me to suspect that the error has to do with
>  http://issues.apache.org/jira/browse/JCR-585 - that the
>  NodeTypeRegistry is not available via the "normal" RMI interfaces.
>
>  What would be the easisest way to get Sling running on a remote JCR?
>
>
>  --
>  Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
>  Akersgata 16, N-0158 Oslo, Norway
>


-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway

Re: Running over RMI and registering nodetypes

Posted by Felix Meschberger <fm...@gmail.com>.
Am Montag, den 10.03.2008, 11:27 +0100 schrieb Vidar Ramdal:
> I'm trying to set up sling to use a remote JCR repository, by using
> the sling.repository.url system property.
> 
> Sling is able to locate and connect to the repository, but fails
> org.apache.sling.jcr.base.internal.loader.Loader#registerBundleInternal,
> line #165, while attempting to register node types. The error reported
> on the RMI server side is
> java.lang.NoClassDefFoundError
> 	at org.apache.jackrabbit.core.RepositoryImpl.getSystemSearchManager(RepositoryImpl.java:625)
> 	at org.apache.jackrabbit.core.RepositoryImpl$WorkspaceInfo.getSearchManager(RepositoryImpl.java:1613)
> 	at org.apache.jackrabbit.core.RepositoryImpl.initWorkspace(RepositoryImpl.java:606)
> 	at org.apache.jackrabbit.core.RepositoryImpl.initStartupWorkspaces(RepositoryImpl.java:415)
> 	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:305)
> 	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:557)
> 	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:245)
> 	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:265)
> 	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:333)
> 	at org.apache.jackrabbit.rmi.server.ServerRepository.login(ServerRepository.java:104)
> 
> RepositoryImpl#625 is where Jackrabbit attempts to create a
> SearchManager, using a NodeTypeRegistry as one of the parameters. This
> leads me to suspect that the error has to do with
> http://issues.apache.org/jira/browse/JCR-585 - that the
> NodeTypeRegistry is not available via the "normal" RMI interfaces.
> 
> What would be the easisest way to get Sling running on a remote JCR?
> 


Re: Running over RMI and registering nodetypes

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Mittwoch, den 12.03.2008, 07:56 +0100 schrieb Bertrand Delacretaz:
> On Tue, Mar 11, 2008 at 7:59 PM, Vidar Ramdal <vi...@idium.no> wrote:
> 
> >  ...It seems Sling attempts to register nodetypes on every startup, even
> >  though they're already be registered - and when registering fails,
> >  Sling gives up on trying to connect to the repository. This is a bit
> >  odd, right?...
> 
> I agree, to be usable with any JCR repository (and that might improve
> the situation when using Jackrabbit over RMI), Sling should IMHO use
> the following rules to define a node type
> 
> a) Test if the nodetype is already defined, using the JCR APIs
> 
> b) If not defined, try to define it. Currently this requires using
> Jackrabbit-specific APIs as JSR 170 does not provide this.
> 
> c) If that fails, log a warning but do not prevent connecting to the
> JCR repository. People should manually register the required nodetypes
> if Sling cannot do that automatically, so the warning message must
> include precise info on what needs to be registered.
> 
> What do people think?

SLING-7 ;-) This is in fact one of our oldest unfixed issues ...

Regards
Felix


Re: Running over RMI and registering nodetypes

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, Mar 11, 2008 at 7:59 PM, Vidar Ramdal <vi...@idium.no> wrote:

>  ...It seems Sling attempts to register nodetypes on every startup, even
>  though they're already be registered - and when registering fails,
>  Sling gives up on trying to connect to the repository. This is a bit
>  odd, right?...

I agree, to be usable with any JCR repository (and that might improve
the situation when using Jackrabbit over RMI), Sling should IMHO use
the following rules to define a node type

a) Test if the nodetype is already defined, using the JCR APIs

b) If not defined, try to define it. Currently this requires using
Jackrabbit-specific APIs as JSR 170 does not provide this.

c) If that fails, log a warning but do not prevent connecting to the
JCR repository. People should manually register the required nodetypes
if Sling cannot do that automatically, so the warning message must
include precise info on what needs to be registered.

What do people think?

-Bertrand

Re: Running over RMI and registering nodetypes

Posted by Vidar Ramdal <vi...@idium.no>.
On 3/11/08, Bertrand Delacretaz <bd...@apache.org> wrote:
> On Mon, Mar 10, 2008 at 11:27 AM, Vidar Ramdal <vi...@idium.no> wrote:
>
>  > ...This
> >  leads me to suspect that the error has to do with
>  >  http://issues.apache.org/jira/browse/JCR-585 - that the
> >  NodeTypeRegistry is not available via the "normal" RMI interfaces....
>
>  I think you're right, does anyone know about a workaround?
>
>  >  ...What would be the easisest way to get Sling running on a remote JCR?...
>
>  If there's no workaround that allows the nodetypes to be registered
>  over RMI, you might have to register them in another way in that
>  repository, and we would have to modify Sling so that a failure to
>  register the node types only triggers warnings, not a fatal error.
>
>  I think we'll need that anyway if people want to run Sling on other
>  JCR repositories than Jackrabbit, as registering nodetypes is not part
>  of the JCR API.
>
>  What do people think?

Yep, it would be perfectly acceptable for us to register the nodetypes
once, locally, on the JCR.

It seems Sling attempts to register nodetypes on every startup, even
though they're already be registered - and when registering fails,
Sling gives up on trying to connect to the repository. This is a bit
odd, right?

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway

Re: Running over RMI and registering nodetypes

Posted by Tobias Bocanegra <to...@day.com>.
> yes. in jackrabbit 1.4 the api exposes the import nodetypes
>  capabilities of the nodetype manager. this is also available in
>  jackrabbit:
should read: this is also available over RMI :-)
-- 
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Re: Running over RMI and registering nodetypes

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Mittwoch, den 12.03.2008, 00:52 -0700 schrieb Tobias Bocanegra:
> > We don't check, because we don't parse the CND files and don't know
> >  which node types to check for ...
> this is a big problem of the nt registering in jackrabbit. i would
> like to have 2 flags. one that
> automatically reregisters existing nodetypes if they differ, and
> another that ignores existing nodetypes in the CND.

That would be great. Even better exceptions would help alot: Currently I
parse the message to get at failure reason and to not log exceptions due
to duplicate node type definitions....

> another option would be to expose the internal nodetype def builder
> and decouple the CND parsing completely from registration. afaik this
> is more or less what JSR283 suggests.

That would even be better ... But still I would have some node type
definition files, which would have to be parsed.

> ps: i've rewritten/copied the CND parser now a couple of times, so
> maybe i can provide at least a reassembler that cuts out those
> nodetypes that are already registered in the repository.

In a first attempt at approaching SLING-7 I tried to extract the CND
parser out of the Jackrabbit code - but as there where so many core
dependencies it just was not possible in a reasonable time frame ...

Regards
Felix


Re: Running over RMI and registering nodetypes

Posted by Tobias Bocanegra <to...@day.com>.
> We don't check, because we don't parse the CND files and don't know
>  which node types to check for ...
this is a big problem of the nt registering in jackrabbit. i would
like to have 2 flags. one that
automatically reregisters existing nodetypes if they differ, and
another that ignores existing nodetypes in the CND.
another option would be to expose the internal nodetype def builder
and decouple the CND parsing completely from registration. afaik this
is more or less what JSR283 suggests.

regards, toby

ps: i've rewritten/copied the CND parser now a couple of times, so
maybe i can provide at least a reassembler that cuts out those
nodetypes that are already registered in the repository.
-- 
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Re: Running over RMI and registering nodetypes

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Mittwoch, den 12.03.2008, 08:01 +0100 schrieb Bertrand Delacretaz:
> On Tue, Mar 11, 2008 at 7:12 PM, Tobias Bocanegra
> <to...@day.com> wrote:
> > ...yes. in jackrabbit 1.4 the api exposes the import nodetypes
> >  capabilities of the nodetype manager. this is also available in
> >  jackrabbit:...(over RMI)...
> 
> Thanks Toby, the code that you suggest is very similar to our current
> NodeTypeLoader.registerNodeType(), except that we don't check first if
> the nodetype is already defined.

We don't check, because we don't parse the CND files and don't know
which node types to check for ...

> So I'm not sure why that fails over RMI in Vidar's case (haven't tried
> it myself yet).

Looking at the jackrabbit-jcr-rmi, it seems that we are using the RMI
integration incorrectly in Sling :-( We just use the
ClientAdapterFactory and ServerAdapterFactory classes where we should
use the JackrabbitAdapterFactory and JackrabbitServerAdapterFactory
instead to really be able to support the Jackrabbit API.

Will fix this !

Regards
Felix

> 
> -Bertrand
> 
> 
> >
> >     private void initNodeTypes() throws RepositoryException {
> >         // check if node types are registered
> >         try {
> >             session.getWorkspace().getNodeTypeManager().getNodeType("my:HierarchyNode");
> >             return;
> >         } catch (RepositoryException e) {
> >             // ignore
> >         }
> >         NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
> >         if (ntMgr instanceof JackrabbitNodeTypeManager) {
> >             InputStream in = getClass().getResourceAsStream(DEFAULT_NODETYPES);
> >             try {
> >                 ((JackrabbitNodeTypeManager)
> >  ntMgr).registerNodeTypes(in,
> >  JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
> >                 in.close();
> >             } catch (IOException e) {
> >                 throw new RepositoryException("Error while importing
> >  nodetypes.", e);
> >             }
> >         }
> >     }
> >
> >  regards, toby


Re: Running over RMI and registering nodetypes

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, Mar 11, 2008 at 7:12 PM, Tobias Bocanegra
<to...@day.com> wrote:
> ...yes. in jackrabbit 1.4 the api exposes the import nodetypes
>  capabilities of the nodetype manager. this is also available in
>  jackrabbit:...(over RMI)...

Thanks Toby, the code that you suggest is very similar to our current
NodeTypeLoader.registerNodeType(), except that we don't check first if
the nodetype is already defined.

So I'm not sure why that fails over RMI in Vidar's case (haven't tried
it myself yet).

-Bertrand


>
>     private void initNodeTypes() throws RepositoryException {
>         // check if node types are registered
>         try {
>             session.getWorkspace().getNodeTypeManager().getNodeType("my:HierarchyNode");
>             return;
>         } catch (RepositoryException e) {
>             // ignore
>         }
>         NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
>         if (ntMgr instanceof JackrabbitNodeTypeManager) {
>             InputStream in = getClass().getResourceAsStream(DEFAULT_NODETYPES);
>             try {
>                 ((JackrabbitNodeTypeManager)
>  ntMgr).registerNodeTypes(in,
>  JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
>                 in.close();
>             } catch (IOException e) {
>                 throw new RepositoryException("Error while importing
>  nodetypes.", e);
>             }
>         }
>     }
>
>  regards, toby

Re: Running over RMI and registering nodetypes

Posted by Vidar Ramdal <vi...@idium.no>.
On 3/11/08, Tobias Bocanegra <to...@day.com> wrote:
> yes. in jackrabbit 1.4 the api exposes the import nodetypes
>  capabilities of the nodetype manager. this is also available in
>  jackrabbit:
>
>     private void initNodeTypes() throws RepositoryException {
>         // check if node types are registered
>         try {
>             session.getWorkspace().getNodeTypeManager().getNodeType("my:HierarchyNode");
>             return;
>         } catch (RepositoryException e) {
>             // ignore
>         }
>         NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
>         if (ntMgr instanceof JackrabbitNodeTypeManager) {
>             InputStream in = getClass().getResourceAsStream(DEFAULT_NODETYPES);
>             try {
>                 ((JackrabbitNodeTypeManager)
>  ntMgr).registerNodeTypes(in,
>  JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
>                 in.close();
>             } catch (IOException e) {
>                 throw new RepositoryException("Error while importing
>  nodetypes.", e);
>             }
>         }
>     }


This looks great. Should I file a request for this improvement in JIRA?

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway

Re: Running over RMI and registering nodetypes

Posted by Tobias Bocanegra <to...@day.com>.
yes. in jackrabbit 1.4 the api exposes the import nodetypes
capabilities of the nodetype manager. this is also available in
jackrabbit:

    private void initNodeTypes() throws RepositoryException {
        // check if node types are registered
        try {
            session.getWorkspace().getNodeTypeManager().getNodeType("my:HierarchyNode");
            return;
        } catch (RepositoryException e) {
            // ignore
        }
        NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
        if (ntMgr instanceof JackrabbitNodeTypeManager) {
            InputStream in = getClass().getResourceAsStream(DEFAULT_NODETYPES);
            try {
                ((JackrabbitNodeTypeManager)
ntMgr).registerNodeTypes(in,
JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
                in.close();
            } catch (IOException e) {
                throw new RepositoryException("Error while importing
nodetypes.", e);
            }
        }
    }

regards, toby

On 3/11/08, Bertrand Delacretaz <bd...@apache.org> wrote:
> On Mon, Mar 10, 2008 at 11:27 AM, Vidar Ramdal <vi...@idium.no> wrote:
>
>  > ...This
>
> >  leads me to suspect that the error has to do with
>  >  http://issues.apache.org/jira/browse/JCR-585 - that the
>
> >  NodeTypeRegistry is not available via the "normal" RMI interfaces....
>
>  I think you're right, does anyone know about a workaround?
>
>  >  ...What would be the easisest way to get Sling running on a remote JCR?...
>
>  If there's no workaround that allows the nodetypes to be registered
>  over RMI, you might have to register them in another way in that
>  repository, and we would have to modify Sling so that a failure to
>  register the node types only triggers warnings, not a fatal error.
>
>  I think we'll need that anyway if people want to run Sling on other
>  JCR repositories than Jackrabbit, as registering nodetypes is not part
>  of the JCR API.
>
>  What do people think?
>
>
>  -Bertrand
>


-- 
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Re: Running over RMI and registering nodetypes

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Mar 10, 2008 at 11:27 AM, Vidar Ramdal <vi...@idium.no> wrote:

> ...This
>  leads me to suspect that the error has to do with
>  http://issues.apache.org/jira/browse/JCR-585 - that the
>  NodeTypeRegistry is not available via the "normal" RMI interfaces....

I think you're right, does anyone know about a workaround?

>  ...What would be the easisest way to get Sling running on a remote JCR?...

If there's no workaround that allows the nodetypes to be registered
over RMI, you might have to register them in another way in that
repository, and we would have to modify Sling so that a failure to
register the node types only triggers warnings, not a fatal error.

I think we'll need that anyway if people want to run Sling on other
JCR repositories than Jackrabbit, as registering nodetypes is not part
of the JCR API.

What do people think?

-Bertrand