You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by astra123 <sa...@tcs.com> on 2009/05/05 06:20:18 UTC
getting exception while trying to register repository with jndi
Hi,
I have created one Web application project in NetBeans IDE.
To that lib folder i have added the jackrabbit-standalone-1.5.4.jar file.
Then i have created one java file and placed the sample code which is given
in below link.
http://www.ibm.com/developerworks/java/library/j-jcr/
by running that java file ,im able to add/retrieve contents in repository.
Now i need to view the repository nodes using JCR browser.
For that i have downloaded the WAR file jcr-explorer.war from net.
Deployed it in tomcat 6 and imported that war project inside NetBeans IDE.
now im able to launch the Login page of it.
It is asking for JNDI name,username and pwd.
so i tried registering the repository with JNDI by refering the below link
http://jackrabbit.apache.org/jcr-client-application-howto.html
To my Web application's (where sample code resides) web.xml and the java
file i have added the code snippets as given in above link.When i run that
java file.
Im getting below exception:
May 5, 2009 9:39:19 AM NewClass1 main
SEVERE: null
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
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.rebind(InitialContext.java:408)
at
org.apache.jackrabbit.core.jndi.RegistryHelper.registerRepository(RegistryHelper.java:77)
at NewClass1.main(NewClass1.java:41)
Please help me to resolve this.(i'm new to JCR ,please tell me whether im in
rite path)
Thanks in advance,
--
View this message in context: http://www.nabble.com/getting-exception-while-trying-to-register-repository-with-jndi-tp23380779p23380779.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: getting exception while trying to register repository with jndi
Posted by astra123 <sa...@tcs.com>.
Hi,
Even after changing the code using lookup...getting same error as before.
InitialContext ctx = new InitialContext();
Context environment = (Context) ctx.lookup("java:comp/env");
Repository r = (Repository)
environment.lookup("jcr/repository");
SimpleCredentials cred = new SimpleCredentials("userid",
"".toCharArray());
Session session = r.login(cred, null);
Workspace ws = session.getWorkspace();
Node rn = session.getRootNode();
//print the root node name
System.out.println("Name of the
RootNode"+rn.getPrimaryNodeType().getName());
getting error like
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
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at NewClass1.main(NewClass1.java:53)
In web.xml also i have added the tag as given in the
http://jackrabbit.apache.org/jcr-client-application-howto.html link
What else i need to change to access the repository via jndi.
Please help us to resolve.
Thanks.
Alexander Klimetschek wrote:
>
> On Tue, May 5, 2009 at 6:20 AM, astra123 <sa...@tcs.com>
> wrote:
>>
>> Hi,
>>
>> I have created one Web application project in NetBeans IDE.
>> To that lib folder i have added the jackrabbit-standalone-1.5.4.jar file.
>> Then i have created one java file and placed the sample code which is
>> given
>> in below link.
>>
>> http://www.ibm.com/developerworks/java/library/j-jcr/
>>
>> by running that java file ,im able to add/retrieve contents in
>> repository.
>>
>> Now i need to view the repository nodes using JCR browser.
>> For that i have downloaded the WAR file jcr-explorer.war from net.
>> Deployed it in tomcat 6 and imported that war project inside NetBeans
>> IDE.
>> now im able to launch the Login page of it.
>> It is asking for JNDI name,username and pwd.
>>
>> so i tried registering the repository with JNDI by refering the below
>> link
>>
>> http://jackrabbit.apache.org/jcr-client-application-howto.html
>>
>> To my Web application's (where sample code resides) web.xml and the java
>> file i have added the code snippets as given in above link.When i run
>> that
>> java file.
>>
>> Im getting below exception:
>>
>> May 5, 2009 9:39:19 AM NewClass1 main
>> SEVERE: null
>> 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
>> at
>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
>> at
>> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>> at
>> javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
>> at javax.naming.InitialContext.rebind(InitialContext.java:408)
>> at
>> org.apache.jackrabbit.core.jndi.RegistryHelper.registerRepository(RegistryHelper.java:77)
>> at NewClass1.main(NewClass1.java:41)
>
> If NewClass1 is your client, you should retrieve the repository from
> JNDI there, and not register it (RegistryHelper.registerRepository()).
> The lookup code is the one on
> http://jackrabbit.apache.org/jcr-client-application-howto.html
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
>
--
View this message in context: http://www.nabble.com/getting-exception-while-trying-to-register-repository-with-jndi-tp23380779p23383311.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: getting exception while trying to register repository with jndi
Posted by Alexander Klimetschek <ak...@day.com>.
On Tue, May 5, 2009 at 6:20 AM, astra123 <sa...@tcs.com> wrote:
>
> Hi,
>
> I have created one Web application project in NetBeans IDE.
> To that lib folder i have added the jackrabbit-standalone-1.5.4.jar file.
> Then i have created one java file and placed the sample code which is given
> in below link.
>
> http://www.ibm.com/developerworks/java/library/j-jcr/
>
> by running that java file ,im able to add/retrieve contents in repository.
>
> Now i need to view the repository nodes using JCR browser.
> For that i have downloaded the WAR file jcr-explorer.war from net.
> Deployed it in tomcat 6 and imported that war project inside NetBeans IDE.
> now im able to launch the Login page of it.
> It is asking for JNDI name,username and pwd.
>
> so i tried registering the repository with JNDI by refering the below link
>
> http://jackrabbit.apache.org/jcr-client-application-howto.html
>
> To my Web application's (where sample code resides) web.xml and the java
> file i have added the code snippets as given in above link.When i run that
> java file.
>
> Im getting below exception:
>
> May 5, 2009 9:39:19 AM NewClass1 main
> SEVERE: null
> 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
> at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
> at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
> at
> javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
> at javax.naming.InitialContext.rebind(InitialContext.java:408)
> at
> org.apache.jackrabbit.core.jndi.RegistryHelper.registerRepository(RegistryHelper.java:77)
> at NewClass1.main(NewClass1.java:41)
If NewClass1 is your client, you should retrieve the repository from
JNDI there, and not register it (RegistryHelper.registerRepository()).
The lookup code is the one on
http://jackrabbit.apache.org/jcr-client-application-howto.html
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com