AnsweredAssumed Answered

Accessing Aflresco from Different VM using JNDI

Question asked by sanatmastan on Feb 4, 2010
Hi

I want alfresco repository to access from different java program which is running different vm, here is what i did.

1) In stalled Alfresco 3.2Ent trail version and it is up and running,
2) I downloaded 3.2Community sdk set it up in eclipse, without starting tomcat from step 1 i am able to run sample program provided by sdk through eclipse.
3) Now i downloaded jcr-jndi adaptor and configured it in Alfresco 3.2Ent setup and the test webapp is running perfectly. Since testwebapp jcrJndiTest and alfresco are in same jvm (under tomcat) JNDI worked perfectly.

now what i am trying is to access the repository present in Alfresco 3.2 Ent into Alfresci 3.2 sdk from eclipse using JNDI. I included alfresco-jcr-jndi-bridge.jar in "SDK AlfrescoEmbedded" project and trying to access jcr repository "jcr/baseRepository " using the factory "org.alfresco.jcr.jndi.JndiJcrObjectFactory" as follows, i also tried removing jcr api from "SDK AlfrescoEmbedded" (ofcourse which is dump thing). I didnt succeed.

          Hashtable env = new Hashtable(11);
       env.put(Context.INITIAL_CONTEXT_FACTORY,"org.alfresco.jcr.jndi.JndiJcrObjectFactory");
         
          //Context ctx = new InitialContext(env);
          vNamingContext = new InitialContext(env);
          vNamingContext = (Context)vNamingContext.lookup("java:comp/env");

i am getting following exception

error during JNDI lookup for [jcr/baseRepository] [javax.naming.NoInitialContextException: Cannot instantiate class: org.alfresco.jcr.jndi.JndiJcrObjectFactory [Root exception is java.lang.ClassCastException: org.alfresco.jcr.jndi.JndiJcrObjectFactory]]
javax.naming.NoInitialContextException: Cannot instantiate class: org.alfresco.jcr.jndi.JndiJcrObjectFactory [Root exception is java.lang.ClassCastException: org.alfresco.jcr.jndi.JndiJcrObjectFactory]
   at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
   at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
   at javax.naming.InitialContext.init(InitialContext.java:223)
   at javax.naming.InitialContext.<init>(InitialContext.java:197)
   at org.alfresco.sample.jcr.JNDITest.lookupJndiJcr(JNDITest.java:118)
   at org.alfresco.sample.jcr.JNDITest.main(JNDITest.java:61)
Caused by: java.lang.ClassCastException: org.alfresco.jcr.jndi.JndiJcrObjectFactory
   at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
   … 5 more
Exception in thread "main" java.lang.NullPointerException
   at org.alfresco.sample.jcr.JNDITest.main(JNDITest.java:69)

Please help…

Thanks
Sanat.

Outcomes