[jira] [Commented] (JCR-3694) Exception on shutdown when using BindableRepository

2013-12-08 Thread Bruno CORNOUILLER (JIRA)

[ 
https://issues.apache.org/jira/browse/JCR-3694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13842715#comment-13842715
 ] 

Bruno CORNOUILLER commented on JCR-3694:


When the shutdown hook is called, the logger is not accessible (is null).
So, i rewrite BindableRepositoryFactory which call directly 
RepositoryImpl.create(config).
And in Resource tag, i add parameter closeMethod with the value shutdown. 
So when tomcat stop, the method shutdown() is automatically called on 
repository object. It's a new functionnality in tomcat7.


 Exception on shutdown when using BindableRepository
 ---

 Key: JCR-3694
 URL: https://issues.apache.org/jira/browse/JCR-3694
 Project: Jackrabbit Content Repository
  Issue Type: Bug
  Components: jackrabbit-core
Affects Versions: 2.6.4
Reporter: Bruno CORNOUILLER

 I declare a resource in context.xml (of my app) :
 Resource name=jcr/myRepository auth=Container
 type=javax.jcr.Repository
 factory=org.apache.jackrabbit.core.jndi.BindableRepositoryFactory
 configFilePath=C:\myapp\conf\repository.xml
 repHomeDir=C:\myapp\repository /
 And then, i call the repository like that :
 InitialContext context = new InitialContext();
 Repository repository = (Repository) 
 context.lookup(java:comp/env/jcr/myRepository);
 I do anything else. And I stop tomcat, and i have this exception :
 Exception in thread Thread-3 java.lang.NullPointerException
   at 
 org.apache.jackrabbit.core.RepositoryImpl.doShutdown(RepositoryImpl.java:1060)
   at 
 org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:1048)
   at 
 org.apache.jackrabbit.core.jndi.BindableRepository.shutdown(BindableRepository.java:259)
   at 
 org.apache.jackrabbit.core.jndi.BindableRepository$1.run(BindableRepository.java:120)
 The NullPointerException is on this line :
  log.info(Shutting down repository...);



--
This message was sent by Atlassian JIRA
(v6.1#6144)


Question on Activity

2013-12-08 Thread Young Li
Dear All,

I am confused on the concept Activity in JCR.  By the introduction of it, it 
uses to record some changes on the session and that could be used to reused in 
other workspaces.

I try to build a simple demo to check the function of Activity, but it failed.  
 Attaching my code here, please give me some guide.  Thanks.

 //create a Activity node
Node activity = vm.getActivity();
if (null == activity) {
activity = vm.createActivity(test_act_default_);
}
System.out.println(activity.getUUID());
Node root = adminSession.getRootNode();
Node testNode = root.addNode(test);

testNode.addMixin(mix:versionable);
adminSession.save();

vm.setActivity(activity);//set activity and begin to record the changes
vm.checkout(/test);
testNode.addNode(test_sub1);
testNode.addNode(test_sub2);
adminSession.save();
vm.setActivity(null);// stop the activity and the activity should 
contains the addition of two child nodes.
vm.checkin(/test);

After above code, I try to reuse the activity in another workspace 'test'.

Session test_session = rep.login(new SimpleCredentials(admin,
admin.toCharArray()), test);
 //Create a similar root node here
 Node root = test_session.getRootNode();
Node testNode = root.addNode(test);
testNode.addMixin(mix:versionable);
test_session.save();

VersionManagerImpl vm = 
(VersionManagerImpl)adminSession.getWorkspace().getVersionManager();
String uuid_act = 6047919f-2740-426c-ba91-94c1cc60e4bd;//this is UUID 
of activity node previously created.
Node activity_node = test_session.getNodeByUUID(uuid_act);
 NodeIterator nit = vm.merge(activity_node);//merge, but there is no 
anything changes to be taken effect.

It is really appreciated if any suggestion is received.  Thanks.

Best regards,

Young