Announcement Announcement Module
Collapse
No announcement yet.
Documentation: JcrCallback or standard way with DataAccessException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Documentation: JcrCallback or standard way with DataAccessException

    I'm new with jcr and with se-jcr-0.9.jar.
    I've just tried to follow the documentation (http://se-jcr.sourceforge.net/guide.html).

    package org.springframework.data.jcr;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.springframework.extensions.jcr.support.JcrDaoS upport;
    import org.springframework.extensions.jcr.JcrCallback;
    import javax.jcr.Node;
    import javax.jcr.Session;
    import javax.jcr.RepositoryException;

    public class JcrReadWrite extends JcrDaoSupport {
    protected final Log log = LogFactory.getLog(getClass());
    //First test
    public void saveSmth() throws DataAccessException {
    Session session = getSession();
    try {
    Node root = session.getRootNode();
    log.info("starting from root node " + root);
    Node sample = root.addNode("sample node");
    sample.setProperty("sample property", "bla bla");
    log.info("saved property " + sample);
    session.save();
    }
    catch (RepositoryException ex) {
    throw convertJcrAccessException(ex);
    }
    }
    /*
    // second test
    public void saveSmth() {
    template.execute(new JcrCallback() {

    public Object doInJcr(Session session) throws RepositoryException {
    Node root = session.getRootNode();
    log.info("starting from root node " + root);
    Node sample = root.addNode("sample node");
    sample.setProperty("sample property", "bla bla");
    log.info("saved property " + sample);
    session.save();
    return null;
    }
    });
    }
    */
    }
    For the first test, I have the following error after compiling:
    cannot find symbol : class DataAccessException
    This class is included in the springmodule.jar but not in the se-jcr jar. Should I get the springmodule.jar too ? I was believing that se-jcr jar was used instead of spring-module jar.

    As regards second test with callback, I have the following error after compiling:
    template has private access in org.springframework.extensions.jcr.support.JcrDaoS upport: template.execute(new JcrCallback() {

    Any help would be appreciated.
Working...
X