Do your web applications each instantiate a ModeShape engine, or do they both look up and use the same JcrEngine instance? Based upon the behavior you are seeing, I suspect they are using different engines.
When two (or more) engines are used, and a change is made to the persisted stored via one engine, the other engine does not receive a notification of that change, and it does not update its local indexes. (The content is persisted in JPA in your case, so that's why navigating via the JCR API does see the updated content.) A workaround is to periodically rebuild the indexes in the admin web application. (There is a "
reindexContent()" method on JcrSession.)
That's obviously a non-ideal solution. The real solution with ModeShape 1.x is to use the same engine instance. This likely means creating the JcrEngine and placing it in JNDI, where both web applications can access and use it. Because only one engine will be used, it will remain consistent with all changes, and your queries will work.
If you're using ModeShape 2.0 and JCR 2.0, you could use the RepositoryFactory approach to look up the desired repository, and our RepositoryFactory implementation manages the JcrEngine instances automatically. For details, see http://docs.jboss.org/modeshape/latest/manuals/reference/html_single/reference-guide-en.html#obtainining_jcr_repository
Our next release will introduce support for clustering multiple engines so that they all are aware of changes made in other engines in the cluster. We've already implemented this feature in the trunk of our SVN, and we plan to issue a ModeShape 2.1 candidate release within the next two weeks. Feel free to download the latest from SVN and build it yourself. (The Reference Guide and Getting Started documents have already been updated in trunk, too, and describe how to set up clustering. So doing "mvn clean install -Pintegration -DskipTests=true" will build everything, including the local docs. Note that if any of the clustering tests fail, you may be using IPv6 locally, so try "mvn clean install -Pintegration,preferIpv6 -DskipTests=true".)
Thanks for the quick response! Each application uses its own ModeShape engine, so your analysis matches the problem exactly. We will be eagerly awaiting ModeShape 2.1 since we definitely need the clustering support you mentioned.
Good to hear. Stay tuned to our forum, watch us on Twitter, or subscribe to the mailing lists -- we send out news on all of these fronts.
And if you are feeling adventurous, we'd love feedback on the feature before we release! I can walk you through building it locally if you need help. If you don't have time or desire, that's fine, too.