jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: createWorkspace throws PathNotFoundException
Date Thu, 05 Aug 2010 16:19:30 GMT
On Thu, Aug 5, 2010 at 13:57, Cory Prowse <cory@prowse.com> wrote:
> Sorry, I should have given a full example of the problem code.
> The following code fails on a fresh setup.
>
> @Startup
> @Singleton
> public class JcrStartupSingleton {
>
>    @Resource(name = "jcr/repository", type = javax.jcr.Repository.class)
>    private Repository repository;
>
>    @PostConstruct
>    public void setupWorkspaces() throws RepositoryException {
>        final Session session = repository.login(new SimpleCredentials("admin1", "".toCharArray()),
"production");
>        try {
>            session.getRootNode().addNode("example");
>            session.save();
>
>            session.getWorkspace().createWorkspace("staging", "production");
>        } finally {
>            session.logout();
>        }
>    }
> }
>
> Gives an exception with a root cause of:
> Caused by: javax.jcr.PathNotFoundException: /example
>        at org.apache.jackrabbit.core.BatchedItemOperations.getNodeState(BatchedItemOperations.java:1456)
>        at org.apache.jackrabbit.core.BatchedItemOperations.copy(BatchedItemOperations.java:387)
>        at org.apache.jackrabbit.core.WorkspaceImpl.internalCopy(WorkspaceImpl.java:404)
>        at org.apache.jackrabbit.core.WorkspaceImpl.clone(WorkspaceImpl.java:606)
>        at org.apache.jackrabbit.core.WorkspaceImpl.createWorkspace(WorkspaceImpl.java:221)
>        at au.projectx.jcr.JcrStartupSingleton.setupWorkspaces(JcrStartupSingleton.java:49)
>
> Where line 49 is:
> session.getWorkspace().createWorkspace("staging", "production");

Hmm, looks like a bug. Could you report it on Jira? See
http://jackrabbit.apache.org/issue-tracker.html

As a workaround, it might work if you use a freshly created session
for the createWorkspace() method:

    Session session = repository.login(...);
    session.getWorkspace().createWorkspace("staging", "production");

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message