You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by stefan81 <st...@process-relations.com> on 2007/09/05 18:10:27 UTC

JackrabbitOnJBoss - Problems accessing JCA

Hi,

I want to deploy JackRabbit on JBoss and followed the instructions under
http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss.

The startup of my JBoss 4.0.5 server together with the deployment of the
repository seems to be working fine:

17:43:59,444 INFO  [RepositoryImpl] Starting repository...
17:43:59,476 INFO  [LocalFileSystem] LocalFileSystem initialized at path
\temp\jackrabbit\repository
17:43:59,585 INFO  [NodeTypeRegistry] no custom node type definitions found
17:43:59,585 INFO  [LocalFileSystem] LocalFileSystem initialized at path
\temp\jackrabbit\version
17:44:01,288 INFO  [LocalFileSystem] LocalFileSystem initialized at path
\temp\jackrabbit\version\blobs
17:44:01,413 INFO  [RepositoryImpl] initializing workspace 'default'...
17:44:01,413 INFO  [LocalFileSystem] LocalFileSystem initialized at path
\temp\jackrabbit\workspaces\default
17:44:01,663 INFO  [LocalFileSystem] LocalFileSystem initialized at path
\temp\jackrabbit\workspaces\default\blobs
17:44:01,741 INFO  [RepositoryImpl] workspace 'default' initialized
17:44:02,179 INFO  [SearchIndex] Index initialized:
/temp/jackrabbit/repository/index
17:44:02,179 INFO  [SearchIndex] Index initialized:
\temp\jackrabbit\workspaces\default/index
17:44:02,179 INFO  [RepositoryImpl] Repository started


I wrote a client program for testing the access to the repository. According
to JackrabbitOnJBoss I tried a jndi lookup which led to the following
exception:

Code:
InitialContext ctx = new InitialContext() ;
Repository repository = (Repository) ctx.lookup("java:jcr/local") ;

Exception:
Exception in thread "main" javax.naming.NoInitialContextException: Need to
specify class name in environment or system property, or as an applet
parameter, or in an application resource file:  java.naming.factory.initial

After some googling I tried out a lot of other things, for example acessing
via rmi:

Code:
ClientRepositoryFactory factory = new ClientRepositoryFactory();
Repository repository =
factory.getRepository("rmi://localhost:1099/jcrServer");
Credentials cred = new SimpleCredentials("user",new char[]{'p','w','d'}) ;
Session s = repository.login(cred);

Exception:
Exception in thread "main"
org.apache.jackrabbit.rmi.client.RemoteRepositoryException: non-JRMP server
at remote endpoint: non-JRMP server at remote endpoint


Can anyone please give me a clue what is going wrong? Why does neither JNDI
lookup nor RMI access work? Did I do something wrong with the deployment of
JR?

Thx a lot!
-- 
View this message in context: http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf4386029.html#a12503786
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: JackrabbitOnJBoss - Problems accessing JCA

Posted by Dominique Pfister <do...@day.com>.
Hi Stefan,

Do you want to access the datasource remotely, from a distinct Java
VM? There is a section on JBoss wiki called "Configuring a DataSource
for remote usage" on the following page:

http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources

It is not recommended, mainly, because the repository/sessions
produced by Jackrabbit's JCA are not serializable and you will
therefore not get useful objects on the client side.

However, registering a Jackrabbit repository in the RMI registry is
something expected to work: the non-JRMP server you see is JBoss's JNP
naming server, so you might use a different port to register your
Jackrabbit repository in RMI.

Kind regards
Dominique


On 05/09/07, stefan81 <st...@process-relations.com> wrote:
>
> Hi,
>
> I want to deploy JackRabbit on JBoss and followed the instructions under
> http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss.
>
> The startup of my JBoss 4.0.5 server together with the deployment of the
> repository seems to be working fine:
>
> 17:43:59,444 INFO  [RepositoryImpl] Starting repository...
> 17:43:59,476 INFO  [LocalFileSystem] LocalFileSystem initialized at path
> \temp\jackrabbit\repository
> 17:43:59,585 INFO  [NodeTypeRegistry] no custom node type definitions found
> 17:43:59,585 INFO  [LocalFileSystem] LocalFileSystem initialized at path
> \temp\jackrabbit\version
> 17:44:01,288 INFO  [LocalFileSystem] LocalFileSystem initialized at path
> \temp\jackrabbit\version\blobs
> 17:44:01,413 INFO  [RepositoryImpl] initializing workspace 'default'...
> 17:44:01,413 INFO  [LocalFileSystem] LocalFileSystem initialized at path
> \temp\jackrabbit\workspaces\default
> 17:44:01,663 INFO  [LocalFileSystem] LocalFileSystem initialized at path
> \temp\jackrabbit\workspaces\default\blobs
> 17:44:01,741 INFO  [RepositoryImpl] workspace 'default' initialized
> 17:44:02,179 INFO  [SearchIndex] Index initialized:
> /temp/jackrabbit/repository/index
> 17:44:02,179 INFO  [SearchIndex] Index initialized:
> \temp\jackrabbit\workspaces\default/index
> 17:44:02,179 INFO  [RepositoryImpl] Repository started
>
>
> I wrote a client program for testing the access to the repository. According
> to JackrabbitOnJBoss I tried a jndi lookup which led to the following
> exception:
>
> Code:
> InitialContext ctx = new InitialContext() ;
> Repository repository = (Repository) ctx.lookup("java:jcr/local") ;
>
> Exception:
> Exception in thread "main" javax.naming.NoInitialContextException: Need to
> specify class name in environment or system property, or as an applet
> parameter, or in an application resource file:  java.naming.factory.initial
>
> After some googling I tried out a lot of other things, for example acessing
> via rmi:
>
> Code:
> ClientRepositoryFactory factory = new ClientRepositoryFactory();
> Repository repository =
> factory.getRepository("rmi://localhost:1099/jcrServer");
> Credentials cred = new SimpleCredentials("user",new char[]{'p','w','d'}) ;
> Session s = repository.login(cred);
>
> Exception:
> Exception in thread "main"
> org.apache.jackrabbit.rmi.client.RemoteRepositoryException: non-JRMP server
> at remote endpoint: non-JRMP server at remote endpoint
>
>
> Can anyone please give me a clue what is going wrong? Why does neither JNDI
> lookup nor RMI access work? Did I do something wrong with the deployment of
> JR?
>
> Thx a lot!
> --
> View this message in context: http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf4386029.html#a12503786
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>

Re: JackrabbitOnJBoss - Problems accessing JCA

Posted by Dominique Pfister <do...@day.com>.
Hi Stefan,

got the same exception when I tried that. If you look at the wiki page
I referred to above, it tells that datasources are only visible to
JBoss's own VM, unless you additionally specify

<use-java-context>false</use-java-context>

inside the jcr-ds.xml. If you do that, the name lookup for "jcr/local"
in your client will not fail but return "null" because the Repository
exposed by the Resource Adapter is not serializable.

Dominique

On 06/09/07, stefan81 <st...@process-relations.com> wrote:
>
> Client and Jboss run on the same machine. When I try:
>
> Repository repo = (Repository) ctx.lookup("java:jcr/local");
>
> I get such an exception:
>
> javax.naming.NameNotFoundException: jcr not bound
>
> This is strange because my Jboss startup tells me:
>
> 15:43:37,352 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager
> 'jboss.jca:service=ConnectionFactoryBinding,name=jcr/local' to JNDI name
> 'java:jcr/local'
>
>
>
> Mihai Anescu wrote:
> >
> > It's a RMI, because you cast to RemoteRepository (if you do the cast
> > directly to Repository you will get a ClassCastException). You can try the
> > JNDI call also, it should work with this:
> >                 Repository repo = (Repository)
> > ctx.lookup("java:jcr/local");
> >
> > That works if the JBoss & client app are on the same machine.
> >
> > Yes, I forgot to tell you also need some jars in the client application
> > path :(.
> >
> > -----Original Message-----
> > From: stefan81 [mailto:stefan.schlappa@process-relations.com]
> > Sent: Thursday, September 06, 2007 5:57 PM
> > To: users@jackrabbit.apache.org
> > Subject: RE: JackrabbitOnJBoss - Problems accessing JCA
> >
> >
> > Thanks for the replies,
> >
> > it works for me now with this piece of code:
> >
> > Properties env = new Properties();
> > env.put(Context.INITIAL_CONTEXT_FACTORY,
> > "org.jnp.interfaces.NamingContextFactory");
> > env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
> > env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
> > InitialContext ctx = new InitialContext(env);
> >
> > ClientAdapterFactory adapter = new ClientAdapterFactory();
> > RemoteRepository rr = (RemoteRepository)
> > ctx.lookup("jnp://localhost:1099/jcrServer");
> > Repository repository = adapter.getRepository(rr);
> >
> >
> > I already tried setting the properties once. It didn´t work because the
> > JBoss libraries weren´t on my client classpath. Now it works.
> > Although it works now, I even don´t know whether this is a JNDI lookup or
> > an
> > RMI call! With the ctx.lookup I would say that this is JNDI. But my code
> > resembles very much to the one you posted in the RMI thread.
> >
> > Does the difference lie in the url?
> >
> >
> > Mihai Anescu wrote:
> >>
> >> Hi Stefan,
> >>
> >> The exception you get can be solved with this kind of code (the default
> >> port is 1099, if you changed it use your port):
> >>
> >> Properties properties = new Properties();
> >> properties.put(Context.INITIAL_CONTEXT_FACTORY,
> >> "org.jnp.interfaces.NamingContextFactory");
> >> properties.put(Context.URL_PKG_PREFIXES,
> >> "org.jboss.naming:org.jnp.interfaces");
> >> properties.put(Context.PROVIDER_URL, "localhost:1099");
> >> InitialContext ctx = new InitialContext(properties);
> >>
> >> Instead of:
> >>
> >> InitialContext ctx = new InitialContext() ;
> >>
> >> Or, if I recall correctly, you can use a properties file
> >> (naming.properties) inside your application, and there you define the
> >> keys/values as above (the keys being the values stored in the Context
> >> static fields, the values are inside the above code).
> >>
> >> You can't use RMI so easy, I already replied you yesterday how you can
> >> connect via RMI (or at least how I managed to connect).
> >>
> >>
> >> -----Original Message-----
> >> From: stefan81 [mailto:stefan.schlappa@process-relations.com]
> >> Sent: Wednesday, September 05, 2007 7:10 PM
> >> To: users@jackrabbit.apache.org
> >> Subject: JackrabbitOnJBoss - Problems accessing JCA
> >>
> >>
> >> Hi,
> >>
> >> I want to deploy JackRabbit on JBoss and followed the instructions under
> >> http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss.
> >>
> >> I wrote a client program for testing the access to the repository.
> >> According
> >> to JackrabbitOnJBoss I tried a jndi lookup which led to the following
> >> exception:
> >>
> >> Code:
> >> InitialContext ctx = new InitialContext() ;
> >> Repository repository = (Repository) ctx.lookup("java:jcr/local") ;
> >>
> >> Exception:
> >> Exception in thread "main" javax.naming.NoInitialContextException: Need
> >> to
> >> specify class name in environment or system property, or as an applet
> >> parameter, or in an application resource file:
> >> java.naming.factory.initial
> >>
> >> After some googling I tried out a lot of other things, for example
> >> acessing
> >> via rmi:
> >>
> >> Code:
> >> ClientRepositoryFactory factory = new ClientRepositoryFactory();
> >> Repository repository =
> >> factory.getRepository("rmi://localhost:1099/jcrServer");
> >> Credentials cred = new SimpleCredentials("user",new char[]{'p','w','d'})
> >> ;
> >> Session s = repository.login(cred);
> >>
> >> Exception:
> >> Exception in thread "main"
> >> org.apache.jackrabbit.rmi.client.RemoteRepositoryException: non-JRMP
> >> server
> >> at remote endpoint: non-JRMP server at remote endpoint
> >>
> >>
> >> Can anyone please give me a clue what is going wrong? Why does neither
> >> JNDI
> >> lookup nor RMI access work? Did I do something wrong with the deployment
> >> of
> >> JR?
> >>
> >> Thx a lot!
> >> --
> >> View this message in context:
> >> http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf43860
> >> 29.html#a12503786
> >> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
> >>
> >>
> >>
> >
> > --
> > View this message in context:
> > http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf4386029.html#a12524384
> > Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf4386029.html#a12525269
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>

RE: JackrabbitOnJBoss - Problems accessing JCA

Posted by stefan81 <st...@process-relations.com>.
Client and Jboss run on the same machine. When I try:

Repository repo = (Repository) ctx.lookup("java:jcr/local");

I get such an exception:

javax.naming.NameNotFoundException: jcr not bound

This is strange because my Jboss startup tells me:

15:43:37,352 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager
'jboss.jca:service=ConnectionFactoryBinding,name=jcr/local' to JNDI name
'java:jcr/local'



Mihai Anescu wrote:
> 
> It's a RMI, because you cast to RemoteRepository (if you do the cast
> directly to Repository you will get a ClassCastException). You can try the
> JNDI call also, it should work with this:
>                 Repository repo = (Repository)
> ctx.lookup("java:jcr/local");
> 
> That works if the JBoss & client app are on the same machine.
> 
> Yes, I forgot to tell you also need some jars in the client application
> path :(.
> 
> -----Original Message-----
> From: stefan81 [mailto:stefan.schlappa@process-relations.com] 
> Sent: Thursday, September 06, 2007 5:57 PM
> To: users@jackrabbit.apache.org
> Subject: RE: JackrabbitOnJBoss - Problems accessing JCA
> 
> 
> Thanks for the replies,
> 
> it works for me now with this piece of code:
> 
> Properties env = new Properties();
> env.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
> env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
> env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
> InitialContext ctx = new InitialContext(env);
> 
> ClientAdapterFactory adapter = new ClientAdapterFactory();
> RemoteRepository rr = (RemoteRepository)
> ctx.lookup("jnp://localhost:1099/jcrServer");
> Repository repository = adapter.getRepository(rr);
> 
> 
> I already tried setting the properties once. It didn´t work because the
> JBoss libraries weren´t on my client classpath. Now it works.
> Although it works now, I even don´t know whether this is a JNDI lookup or
> an
> RMI call! With the ctx.lookup I would say that this is JNDI. But my code
> resembles very much to the one you posted in the RMI thread.
> 
> Does the difference lie in the url?
> 
> 
> Mihai Anescu wrote:
>> 
>> Hi Stefan,
>> 
>> The exception you get can be solved with this kind of code (the default
>> port is 1099, if you changed it use your port):
>> 
>> Properties properties = new Properties();
>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.jnp.interfaces.NamingContextFactory");
>> properties.put(Context.URL_PKG_PREFIXES,
>> "org.jboss.naming:org.jnp.interfaces");
>> properties.put(Context.PROVIDER_URL, "localhost:1099");
>> InitialContext ctx = new InitialContext(properties);
>> 
>> Instead of:
>> 
>> InitialContext ctx = new InitialContext() ;
>> 
>> Or, if I recall correctly, you can use a properties file
>> (naming.properties) inside your application, and there you define the
>> keys/values as above (the keys being the values stored in the Context
>> static fields, the values are inside the above code).
>> 
>> You can't use RMI so easy, I already replied you yesterday how you can
>> connect via RMI (or at least how I managed to connect).
>> 
>> 
>> -----Original Message-----
>> From: stefan81 [mailto:stefan.schlappa@process-relations.com] 
>> Sent: Wednesday, September 05, 2007 7:10 PM
>> To: users@jackrabbit.apache.org
>> Subject: JackrabbitOnJBoss - Problems accessing JCA
>> 
>> 
>> Hi,
>> 
>> I want to deploy JackRabbit on JBoss and followed the instructions under
>> http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss.
>> 
>> I wrote a client program for testing the access to the repository.
>> According
>> to JackrabbitOnJBoss I tried a jndi lookup which led to the following
>> exception:
>> 
>> Code:
>> InitialContext ctx = new InitialContext() ;
>> Repository repository = (Repository) ctx.lookup("java:jcr/local") ;
>> 
>> Exception:
>> Exception in thread "main" javax.naming.NoInitialContextException: Need
>> to
>> specify class name in environment or system property, or as an applet
>> parameter, or in an application resource file:
>> java.naming.factory.initial
>> 
>> After some googling I tried out a lot of other things, for example
>> acessing
>> via rmi:
>> 
>> Code:
>> ClientRepositoryFactory factory = new ClientRepositoryFactory();
>> Repository repository =
>> factory.getRepository("rmi://localhost:1099/jcrServer");
>> Credentials cred = new SimpleCredentials("user",new char[]{'p','w','d'})
>> ;
>> Session s = repository.login(cred);
>> 
>> Exception:
>> Exception in thread "main"
>> org.apache.jackrabbit.rmi.client.RemoteRepositoryException: non-JRMP
>> server
>> at remote endpoint: non-JRMP server at remote endpoint
>> 
>> 
>> Can anyone please give me a clue what is going wrong? Why does neither
>> JNDI
>> lookup nor RMI access work? Did I do something wrong with the deployment
>> of
>> JR?
>> 
>> Thx a lot!
>> -- 
>> View this message in context:
>> http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf43860
>> 29.html#a12503786
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf4386029.html#a12524384
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf4386029.html#a12525269
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


RE: JackrabbitOnJBoss - Problems accessing JCA

Posted by stefan81 <st...@process-relations.com>.
Thanks for the replies,

it works for me now with this piece of code:

Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
InitialContext ctx = new InitialContext(env);

ClientAdapterFactory adapter = new ClientAdapterFactory();
RemoteRepository rr = (RemoteRepository)
ctx.lookup("jnp://localhost:1099/jcrServer");
Repository repository = adapter.getRepository(rr);


I already tried setting the properties once. It didn´t work because the
JBoss libraries weren´t on my client classpath. Now it works.
Although it works now, I even don´t know whether this is a JNDI lookup or an
RMI call! With the ctx.lookup I would say that this is JNDI. But my code
resembles very much to the one you posted in the RMI thread.

Does the difference lie in the url?


Mihai Anescu wrote:
> 
> Hi Stefan,
> 
> The exception you get can be solved with this kind of code (the default
> port is 1099, if you changed it use your port):
> 
> Properties properties = new Properties();
> properties.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
> properties.put(Context.URL_PKG_PREFIXES,
> "org.jboss.naming:org.jnp.interfaces");
> properties.put(Context.PROVIDER_URL, "localhost:1099");
> InitialContext ctx = new InitialContext(properties);
> 
> Instead of:
> 
> InitialContext ctx = new InitialContext() ;
> 
> Or, if I recall correctly, you can use a properties file
> (naming.properties) inside your application, and there you define the
> keys/values as above (the keys being the values stored in the Context
> static fields, the values are inside the above code).
> 
> You can't use RMI so easy, I already replied you yesterday how you can
> connect via RMI (or at least how I managed to connect).
> 
> 
> -----Original Message-----
> From: stefan81 [mailto:stefan.schlappa@process-relations.com] 
> Sent: Wednesday, September 05, 2007 7:10 PM
> To: users@jackrabbit.apache.org
> Subject: JackrabbitOnJBoss - Problems accessing JCA
> 
> 
> Hi,
> 
> I want to deploy JackRabbit on JBoss and followed the instructions under
> http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss.
> 
> I wrote a client program for testing the access to the repository.
> According
> to JackrabbitOnJBoss I tried a jndi lookup which led to the following
> exception:
> 
> Code:
> InitialContext ctx = new InitialContext() ;
> Repository repository = (Repository) ctx.lookup("java:jcr/local") ;
> 
> Exception:
> Exception in thread "main" javax.naming.NoInitialContextException: Need
> to
> specify class name in environment or system property, or as an applet
> parameter, or in an application resource file:
> java.naming.factory.initial
> 
> After some googling I tried out a lot of other things, for example
> acessing
> via rmi:
> 
> Code:
> ClientRepositoryFactory factory = new ClientRepositoryFactory();
> Repository repository =
> factory.getRepository("rmi://localhost:1099/jcrServer");
> Credentials cred = new SimpleCredentials("user",new char[]{'p','w','d'})
> ;
> Session s = repository.login(cred);
> 
> Exception:
> Exception in thread "main"
> org.apache.jackrabbit.rmi.client.RemoteRepositoryException: non-JRMP
> server
> at remote endpoint: non-JRMP server at remote endpoint
> 
> 
> Can anyone please give me a clue what is going wrong? Why does neither
> JNDI
> lookup nor RMI access work? Did I do something wrong with the deployment
> of
> JR?
> 
> Thx a lot!
> -- 
> View this message in context:
> http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf43860
> 29.html#a12503786
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JackrabbitOnJBoss---Problems-accessing-JCA-tf4386029.html#a12524384
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.