jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller" <thomas.tom.muel...@gmail.com>
Subject Re: jackrabbit first steps problem
Date Tue, 04 Sep 2007 09:30:04 GMT
Hi,

Could you test the following code? It works for me, and is very
similar to the code where you get the problem. If it works for you as
well, we would need to find out what is the difference between your
and this code.

import org.apache.jackrabbit.core.TransientRepository;
import javax.jcr.Node;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
public class TestSimple {
    public static void main(String[] args) throws Exception {
        Session session = new TransientRepository()
                .login(new SimpleCredentials("", new char[0]));
        Node root = session.getRootNode();
        Node hello = root.addNode("hello");
        Node world = hello.addNode("world");
        world.setProperty("message", session.getValueFactory().createValue(
                "Hello, World!"));
        session.save();
        String msg = root.getNode("hello").getNode("world").getProperty(
                "message").getString();
        System.out.println("message: " + msg);
    }
}

Thomas


On 9/4/07, Dumitru CIUBENCO <dciubenco@ascenta.ro> wrote:
>
>
>
>
> Thanks Alex. My code in order to access session is simple, something like:
>
>
>
> [code]
>
>       Session session =rp.getRepository().login(new
> SimpleCredentials("kirpi4ik", "password".toCharArray()));
>
>       {
>
>        Node root =session.getRootNode();
>
>              Node hello = root.addNode("hello");
>
>              Node world = hello.addNode("world");
>
>              world.setProperty("message",new StringValue("Hello, World!"));
>
>              session.save();
>
>
>
>       } catch (Exception ex) {
>
>                   ex.printStackTrace();
>
>             } finally {
>
>                   session.logout();
>
>             }
>
>
>
>  [/code]
>
>
>
> Attached is exception stack trace for another sample application which
> throws the same exception
>
>
>
>
>
>
> -----Original Message-----
>  From: Alexandru Popescu ☀
> [mailto:the.mindstorm.mailinglist@gmail.com]
>  Sent: Tuesday, September 04, 2007 2:05 AM
>  To: users@jackrabbit.apache.org
>  Subject: Re: jackrabbit first steps problem
>
>
>
> On 9/4/07, Dumitru CIUBENCO <dciubenco@ascenta.ro> wrote:
>
> > Hi
>
> > I'm newbie here, and I'm trying to build a sample application using
> jackrabbit(1.3x)+tomcat(5x,6x), I tried many configurations and different
> approach including jcr spring modules, and I have the same Exception every
> time usually on "session.save();" statement after adding a child to root
> node:
>
> >
>
> > [code]
>
> > javax.servlet.ServletException: javax.jcr.RepositoryException: /: unable
> to update item.: Unable to resolve path for item:
> 0eb66ffa-5d88-4095-a012-6a7c45ac7713/{}blogAuthor: Unable
> to resolve path for item:
> 0eb66ffa-5d88-4095-a012-6a7c45ac7713/{}blogAuthor
>
> >
> org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520)
>
> >
> org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427)
>
> >
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
>
> >
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>
> >
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>
> >
>
> > root cause
>
> >
>
> > com.onjava.blog.util.BlogApplicationException:
> javax.jcr.RepositoryException: /: unable to update item.: Unable to resolve
> path for item:
> 0eb66ffa-5d88-4095-a012-6a7c45ac7713/{}blogAuthor: Unable
> to resolve path for item:
> 0eb66ffa-5d88-4095-a012-6a7c45ac7713/{}blogAuthor
>
> >
> com.onjava.blog.data.dao.impl.JackrabbitBlogEntryDAO.insertBlogEntry(JackrabbitBlogEntryDAO.java:81)
>
> >
> com.onjava.blog.ui.action.AddBlogEntryAction.execute(AddBlogEntryAction.java:35)
>
> >
> org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
>
> >
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
>
> >
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>
> >
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>
> >
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>
> >
>
> > [/code]
>
> >
>
> > I'm definitely doing something wrong because it is simple application
> which adds some simple node to repository. Maybe somebody have idea about
> this? It would be very helpful
>
> >
>
> >
>
> >
>
> > Thanks, Dumitru
>
> >
>
>
>
> Is your Session accessed in write mode from multiple threads?
>
>
>
> ./alex
>
> --
>
> .w( the_mindstorm )p.
>
Mime
View raw message