How can I prevent local caching of JCR nodes when querying a remote server?

I've got some test code that checks the value of a property on a JCR node, performs an outside action with the system under test, and then checks the value of the same property on the same JCR node to check that it was actually changed.

The problem I'm having is that all subsequent queries after the first are returning the original value, as though that value is cached locally. I can manually check the JCR node and see that the value is actually changed, but the code isn't returning that value when querying.

To fix this, I've found that re-creating the JCR Session every time returns the updated values, but it seems like this isn't the best solution. So my question is: How do I prevent local caching (or whatever is happening) of JCR nodes and property values?

Here's the Groovy function that does the querying:

def getPropertyValueOnNode(propName, nodePath) {
    session = repo.login(new SimpleCredentials(username, password.toCharArray()))

    def jcrContent = "${nodePath}/jcr:content"      
    if (session.nodeExists(jcrContent)) {
        Node n = session.getNode(jcrContent)
        if (n.hasProperty(propName)) {
            return n.getProperty(propName).getString()
    return null


I think that the behavior you see is how it should be.

Sessions should not be kept open for a long time (so closing after getting the property would be correct in your test case) and if so, a session refresh is the correct way. Especially when targeting oak, see

Need Your Help

Wpf/SL charts - Pie tooltip

wpf silverlight charts

I want to set a toolTip on each of the data Points of the pie charts.

How do I upgrade Flash Builder 4.6 to AIR 3.4?

air adobe flash-builder

AIR 3.4 was just released, with features like workers and native APN support.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.