I have it running now. And I have also figured out the problem. The JNDI name "jcr/local" is available to applications running in the same VM only. I was trying to lookup "java:jcr/local" from a main class while my Jackrabbit was deployed on JBoss.
Now I have exposed the Jackrabbit repository through an RMI service in the JBoss and lookup "jnp://localhost:1099/jcrServer" as explained in the Wiki. Now I use Spring to fetch the repository instance. Here is my bean configuration (beans.xml) ========================== <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!-- Configuration of the Remote Jackrabbit Repository, deployed in JBoss and exposed as an RMI Service. --> <bean id="remoteRepository" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="jnp://localhost:1099/jcrServer"/> <property name="jndiEnvironment"> <props> <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop> <prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop> <prop key="java.naming.provider.url">jnp://localhost:1099</prop> </props> </property> </bean> <!-- Configuration for the Client Repository Factory. --> <bean id="clientFactory" class="org.apache.jackrabbit.rmi.client.ClientAdapterFactory"/> <!-- The Client Repository. --> <bean id="repository" factory-bean="clientFactory" factory-method="getRepository"> <constructor-arg ref="remoteRepository"/> </bean> <!--bean id="repository" class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean"> <property name="configuration" value="file:E:/JCR-REPO/testrepo/repository.xml"/> <property name="homeDir" value="E:/JCR-REPO"/> /bean--> <!-- The JCR Session Factory, of the Spring Modules. --> <bean id="jcrSessionFactory" class="org.springmodules.jcr.JcrSessionFactory"> <property name="repository" ref="repository"/> <property name="credentials"> <bean class="javax.jcr.SimpleCredentials"> <constructor-arg index="0" value="bogus"/> <!-- create the credentials using a bean factory --> <constructor-arg index="1"> <bean factory-bean="password" factory-method="toCharArray"/> </constructor-arg> </bean> </property> </bean> <!-- create the password to return it as a char[] --> <bean id="password" class="java.lang.String"> <constructor-arg index="0" value="pass"/> </bean> <!-- The JCR Template. --> <bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate"> <property name="sessionFactory" ref="jcrSessionFactory"/> <property name="allowCreate" value="true"/> </bean> </beans> My code ======== FileSystemResource resource = new FileSystemResource("beans.xml"); BeanFactory factory = new XmlBeanFactory(resource); JcrTemplate template = (JcrTemplate) factory.getBean("jcrTemplate"); Node root = template.getRootNode(); ---- ---- Thank you for your responses. Regards, Kalyan Sarkar José Blas Camacho Taboada wrote: > > I have no explain about that. I have problems with my jcr (it happened as > well with another jndi access) y chagned it, and it worked well. > > regards > > 2007/4/4, Kalyan Sarkar <[EMAIL PROTECTED]>: >> >> >> Are you sure? I checked with your suggestion and its still not working. I >> changed jcr/local to jcrlocal both in jcr-ds.xml and in my code. I also >> didn't understand the logic behind your solution. Would you please >> explain. >> >> Thanks and regards, >> Kalyan Sarkar >> >> >> José Blas Camacho Taboada wrote: >> > >> > I had a similar problem with jboss. I put jcrlocal without / and it >> worked >> > properly... >> > >> > >> > regards >> > >> > 2007/4/4, kalyansarkar108 <[EMAIL PROTECTED]>: >> >> >> >> >> >> I am trying the wiki article >> >> http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss Jackrabbit on >> >> JBoss and >> >> getting a javax.naming.NameNotFoundException: jcr not bound. >> >> >> >> jcr-ds.xml >> >> --------------- >> >> <connection-factories> >> >> <tx-connection-factory> >> >> <jndi-name>jcr/local</jndi-name> >> >> <xa-transaction/> >> >> <rar-name>jackrabbit-jca-1.2.3.rar</rar-name> >> >> <connection-definition>javax.jcr.Repository >> >> </connection-definition> >> >> <config-property name="homeDir" >> >> type="java.lang.String">E:/JCR-REPO/testrepo</config-property> >> >> <config-property name="configFile" >> >> type="java.lang.String >> >> ">E:/JCR-REPO/testrepo/repository.xml</config-property> >> >> <config-property name="bindSessionToTrasaction" >> >> type="java.lang.Boolean">true</config-property> >> >> </tx-connection-factory> >> >> </connection-factories> >> >> >> >> jboss console >> >> ----------------- >> >> 11:50:39,593 INFO [RepositoryImpl] Starting repository... >> >> 11:50:39,625 INFO [LocalFileSystem] LocalFileSystem initialized at >> path >> >> E:\JCR-REPO\testrepo\repository >> >> 11:50:39,812 INFO [NodeTypeRegistry] no custom node type definitions >> >> found >> >> 11:50:39,828 INFO [LocalFileSystem] LocalFileSystem initialized at >> path >> >> E:\JCR-REPO\testrepo\version >> >> 11:50:43,015 INFO [LocalFileSystem] LocalFileSystem initialized at >> path >> >> E:\JCR-REPO\testrepo\version\blobs >> >> 11:50:43,125 INFO [RepositoryImpl] initializing workspace >> 'default'... >> >> 11:50:43,125 INFO [LocalFileSystem] LocalFileSystem initialized at >> path >> >> E:\JCR-REPO\testrepo\workspaces\defaul >> >> t >> >> 11:50:46,765 INFO [LocalFileSystem] LocalFileSystem initialized at >> path >> >> E:\JCR-REPO\testrepo\workspaces\defaul >> >> t\blobs >> >> 11:50:47,015 INFO [RepositoryImpl] workspace 'default' initialized >> >> 11:50:47,375 INFO [SearchIndex] Index initialized: >> >> E:/JCR-REPO/testrepo/repository/index >> >> 11:50:47,421 INFO [SearchIndex] Index initialized: >> >> E:\JCR-REPO\testrepo\workspaces\default/index >> >> 11:50:47,421 INFO [RepositoryImpl] Repository started >> >> 11:50:47,421 INFO [jcr/local] Created repository >> >> ([EMAIL PROTECTED]) >> >> 11:50:47,421 INFO [jcr/local] Created repository handle >> >> ([EMAIL PROTECTED] >> >> ) >> >> 11:50:47,437 INFO [ConnectionFactoryBindingService] Bound >> >> ConnectionManager >> >> 'jboss.jca:service=ConnectionFacto >> >> ryBinding,name=jcr/local' to JNDI name 'java:jcr/local' >> >> >> >> My code to lookup the repository >> >> ----------------------------------------- >> >> Hashtable env = new Hashtable(); >> >> 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 >> "); >> >> Context ctx = new InitialContext(env); >> >> Repository repository = (Repository) ctx.lookup("java:jcr/local"); >> >> >> >> And I get >> >> ------------ >> >> Exception in thread "main" javax.naming.NameNotFoundException: jcr not >> >> bound >> >> at org.jnp.server.NamingServer.getBinding(NamingServer.java >> :529) >> >> at org.jnp.server.NamingServer.getBinding(NamingServer.java >> :537) >> >> at >> org.jnp.server.NamingServer.getObject(NamingServer.java:543) >> >> at org.jnp.server.NamingServer.lookup(NamingServer.java:267) >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> >> at >> >> sun.reflect.NativeMethodAccessorImpl.invoke( >> NativeMethodAccessorImpl.java >> >> :39) >> >> at >> >> sun.reflect.DelegatingMethodAccessorImpl.invoke( >> >> DelegatingMethodAccessorImpl.java:25) >> >> at java.lang.reflect.Method.invoke(Method.java:585) >> >> at >> >> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294) >> >> at sun.rmi.transport.Transport$1.run(Transport.java:153) >> >> at java.security.AccessController.doPrivileged(Native Method) >> >> at sun.rmi.transport.Transport.serviceCall(Transport.java:149) >> >> at >> >> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java >> :460) >> >> at >> >> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run( >> TCPTransport.java >> >> :701) >> >> at java.lang.Thread.run(Thread.java:595) >> >> at >> >> sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown >> >> Source) >> >> at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown >> Source) >> >> at sun.rmi.server.UnicastRef.invoke(Unknown Source) >> >> at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) >> >> at >> >> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625) >> >> at >> >> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587) >> >> at javax.naming.InitialContext.lookup(Unknown Source) >> >> at MyHop.main(MyHop.java:46) >> >> >> >> Can anybody figure out what I am missing? >> >> >> >> Thanks in advance >> >> ~ Kalyan Sarkar >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/Jackrabbit-1.2.3-on-JBoss-4.0.4-GA-tf3524371.html#a9832523 >> >> Sent from the Jackrabbit - Users mailing list archive at Nabble.com. >> >> >> >> >> > >> > >> > -- >> > >> > José B. Camacho Taboada >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Jackrabbit-1.2.3-on-JBoss-4.0.4-GA-tf3524371.html#a9835503 >> Sent from the Jackrabbit - Users mailing list archive at Nabble.com. >> >> > > > -- > > José B. Camacho Taboada > > -- View this message in context: http://www.nabble.com/Jackrabbit-1.2.3-on-JBoss-4.0.4-GA-tf3524371.html#a9917160 Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
