jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From behrangsa <behran...@gmail.com>
Subject Re: TransientRepository bug?
Date Tue, 03 Oct 2006 23:04:54 GMT

Oops! I just found how to add Jackrabbit as a favorite :">

-Behi


behrangsa wrote:
> 
> Hi,
> 
> Compile and run the following class:
> 
> /*
>  * Created by Behrang Saeedzadeh
>  *  on Sep 29, 2006 @ 5:30:34 PM
>  */
> package org.behrang.practice.jsr170;
> 
> import org.apache.jackrabbit.core.TransientRepository;
> 
> import javax.jcr.*;
> import java.util.ArrayList;
> import java.util.List;
> 
> /**
>  * @author Behrang Saeedzadeh
>  */
> public class Main {
> 
>     public static void main(String[] args) throws Exception {
> 
>         final int BLOG_COUNT = 100;
> 
>         Repository rep = new TransientRepository();
> 
>         Session s = rep.login(new SimpleCredentials("username",
> "password".toCharArray()));
>         Node blogs = s.getRootNode().addNode("blogs");
>         s.save();
> 
>         for (int i = 0; i < BLOG_COUNT; i++) {
>             Node blog = blogs.addNode("blog" + i);
>             System.out.println(blog.getPath());
>         }
> 
>         s.save();
>         s.logout();
> 
>         List<Session> sessions = new ArrayList<Session>(BLOG_COUNT);
> 
>         for (int i = 0; i < BLOG_COUNT; i++) {
>             Session sess = rep.login(new SimpleCredentials("User " + i,
> "password".toCharArray()));
>             sessions.add(sess);
>             System.out.println(i);
>         }
> 
>         {
>             int id = 0;
>             for (Session sess : sessions) {
>                 new Thread(new UserThread(sess, id++)).start();
>             }
>         }
> 
>     }
> 
> }
> 
> class UserThread implements Runnable {
> 
>     private static final int POST_COUNT = 20;
> 
>     private Session session;
>     private long start;
>     private long end;
>     private String user;
>     private int id;
> 
> 
>     public UserThread(Session session, int id) {
>         this.session = session;
>         this.user = session.getUserID();
>         this.id = id;
>     }
> 
>     public void run() {
>         System.out.println("Started: " + id);
>         start = System.currentTimeMillis();
>         try {
>             Node blogRoot =
> session.getRootNode().getNode("blogs").getNode("blog" + id);
>             for (int i = 0; i < POST_COUNT; i++) {
>                 Node post = blogRoot.addNode("post" + i);
>                 post.setProperty("title", "Title " + i);
>                 post.setProperty("body", "Body" + i);
>             }
> 
>             session.save();
>             session.logout();
>             end = System.currentTimeMillis();
>             System.out.println(user + " finished its job at " + (end -
> start) / 1000d);
>         } catch (RepositoryException re) {
>             re.printStackTrace();
>         }
>     }
> }
> 
> Now, change the value of BLOG_COUNT to 20 and rerun the class. When I do
> this, I get 20 exceptions:
> 
> javax.jcr.PathNotFoundException: blog11
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> javax.jcr.PathNotFoundException: blog10
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> javax.jcr.PathNotFoundException: blog12
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> javax.jcr.PathNotFoundException: blog13
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> javax.jcr.PathNotFoundException: blog14
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> javax.jcr.PathNotFoundException: blog15
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> javax.jcr.PathNotFoundException: blog16
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> javax.jcr.PathNotFoundException: blog17
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> Started: 18
> Started: 19
> javax.jcr.PathNotFoundException: blog18
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> javax.jcr.PathNotFoundException: blog19
> 	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2369)
> 	at org.behrang.practice.jsr170.UserThread.run(Main.java:76)
> 	at java.lang.Thread.run(Thread.java:595)
> 
> If I delete the repository directory and repository.xml and derby.log and
> rerun the program, the exceptions fade away...
> 
> Could someone please confirm this bug?
> 
> Tested against Jackrabbit 1.0.1
> 
> BTW - How can I add Jackrabbitto my Favorite Forums in Nabble.com!?
> 
> -Behi
> 

-- 
View this message in context: http://www.nabble.com/TransientRepository-bug--tf2379243.html#a6630637
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message