Hi Christophe, Thanks for your reply. I figured out the problem. There was something with my code. The problem was that I was logging out of the session I had to Jackrabbit and then was trying to insert my object into ocm. I believe the error message could have been constructed slightly better.
Instead of getting something like "Cannot insert item <xyz>" maybe it would help to see something "A session to Jackrabbit is required to insert an object into Jackrabbit". But anyway thanks a bunch for all your help. Rokham Christophe Lombart wrote: > > Did you review this page : > http://jackrabbit.apache.org/a-simple-ocm-project-with-maven-eclipse.html > > From here, you can download a simple OCM code demo. > > br, > Christophe > > On Thu, Apr 10, 2008 at 1:02 AM, rokham <[EMAIL PROTECTED]> wrote: >> >> Hi Christophe, >> >> Thanks for your reply. I was initially running jackrabbit-core-1.4.jar >> but I >> followed your suggestion and upgraded to jackrabbit-core-1.5-SNAPSHOT. >> Unfortunately I'm still getting the same error. >> >> I'm sort of under a tight deadline and I'm totally new to Jackrabbit. >> Are >> there other things I might be able to try? Any documents I can read? >> >> Thanks in advance, >> >> Rokham >> >> >> >> Christophe Lombart wrote: >> > >> > Hi, >> > >> > It works for me with Jackrabbit 1.5-SNAPSHOT. Are you using the same >> > jackrabbit version ? >> > >> > br, >> > Christophe >> > >> > >> > On Wed, Apr 9, 2008 at 6:19 PM, rokham <[EMAIL PROTECTED]> >> wrote: >> >> >> >> Hi, >> >> >> >> I'm trying to post a problem I'm facing with inserting a very very >> >> simple >> >> object into jackrabbit using the OCM api. I'm trying to find out how >> I >> >> can >> >> post a new message but I cannot figure out how. >> >> >> >> My problem with OCM is basically this: (Note: I have followed the >> >> instructions on >> http://jackrabbit.apache.org/5-with-jackrabbit-ocm.html) >> >> >> >> 1. I have created a very simple persistent class as follows: >> >> @Node >> >> public class CurnitOtmlImpl{ >> >> >> >> // Unique number defining each curnit >> >> @Field(path=true) String number; >> >> >> >> // Name given to the curnit by the author >> >> @Field String name; >> >> >> >> // getter and setter methods >> >> } >> >> >> >> 2. Then I try the following and I fail at ocm.insert(curnit) >> >> CurnitOtmlImpl cur = new CurnitOtmlImpl(); >> >> cur.setNumber("/123curnit"); >> >> cur.setName("name"); >> >> >> >> repository = new TransientRepository(); >> >> session = repository.login(new SimpleCredentials("username", >> >> "password".toCharArray())); >> >> >> >> >> >> List<Class> classes = new ArrayList<Class>(); >> >> classes.add(CurnitOtmlImpl.class); // Call this method for each >> >> persistent class >> >> >> >> Mapper mapper = new AnnotationMapperImpl(classes); >> >> ocm = new ObjectContentManagerImpl(session, mapper); >> >> >> >> ocm.insert(curnit); >> >> ocm.save(); >> >> >> >> This is the error I get: >> >> >> >> 1957 [main] INFO org.apache.jackrabbit.core.TransientRepository - >> >> Transient >> >> repository shut down >> >> Exception in thread "main" >> >> org.apache.jackrabbit.ocm.exception.RepositoryException: Impossible >> to >> >> insert the object at /123curnit; nested exception is >> >> javax.jcr.RepositoryException: this session has been closed >> >> javax.jcr.RepositoryException: this session has been closed >> >> at >> >> >> org.apache.jackrabbit.core.SessionImpl.sanityCheck(SessionImpl.java:358) >> >> at >> >> >> org.apache.jackrabbit.core.SessionImpl.itemExists(SessionImpl.java:870) >> >> at >> >> >> >> >> org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl.insert(ObjectContentManagerImpl.java:391) >> >> at >> >> >> >> >> net.sf.sail.cms.curnit.CurnitManagementImpl.createCurnit(CurnitManagementImpl.java:33) >> >> at net.sf.sail.cms.curnit.Test.main(Test.java:14) >> >> >> >> Any help is appreciated. >> >> >> >> >> >> Christophe Lombart wrote: >> >> > >> >> > Hi all, >> >> > >> >> > I just added a very small tutorial on Jackrabbit OCM [1]. This is >> >> still a >> >> > draft. Please, give me your comments (sorry for my bad english). >> >> > I plan to write other tutorials. >> >> > >> >> > As you can see, it should be nice to drop the step 2 & 3 (Create >> the >> >> node >> >> > type ocm:discriminator & Initialize the JCR repository). >> >> > >> >> > br, >> >> > Christophe >> >> > >> >> > >> >> > >> >> > [1] http://jackrabbit.apache.org/JCR/5-with-jackrabbit-ocm.html. >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/5%27-with-Jackrabbit-OCM-tp15329247p16590218.html >> >> Sent from the Jackrabbit - Users mailing list archive at Nabble.com. >> >> >> >> >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/5%27-with-Jackrabbit-OCM-tp15329247p16598804.html >> >> >> Sent from the Jackrabbit - Users mailing list archive at Nabble.com. >> >> > > -- View this message in context: http://www.nabble.com/5%27-with-Jackrabbit-OCM-tp15329247p16608589.html Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
