jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mihai Anescu" <mane...@totalsoft.ro>
Subject RE: JackrabbitOnJBoss - Problems accessing JCA
Date Thu, 06 Sep 2007 15:07:49 GMT
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.


Mime
View raw message