jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marlis Lamp <marlis.l...@meinestadt.de>
Subject NPE on checkin when using transactions
Date Wed, 02 Mar 2011 15:45:45 GMT
Hi,

 

I have got a problem when using jackrabbit with transactions. The following code works if
the session is closed after the first commit or when doing the second checkin within the same
transaction.

 

        /** begin code **/

        Session session = repository.login(credentials);

 

        JackRabbitUserTransaction ut = new JackRabbitUserTransaction(session);

        ut.begin();

 

        // insert new versionable node

        String name = "test"+ new Date().getTime();

        Node child = session.getRootNode().addNode(name);

        child.addMixin(JcrConstants.MIX_VERSIONABLE);

        session.save();

        VersionManager vm = session.getWorkspace().getVersionManager();

        vm.checkin(child.getPath());

 

        // commit the transaction

        ut.commit();

 

        // start new transaction

        ut = new JackRabbitUserTransaction(session);

        ut.begin();

 

        vm = session.getWorkspace().getVersionManager();

        child = session.getNode("/"+name);

        vm.checkout(child.getPath());

        child.setProperty("foo", "fooValue");

        session.save();

        vm.checkin(child.getPath());   // this line causes the NPE    

 

        ut.commit();

        session.logout();

        /** end code **/

 

I get the following stacktrace:

 

java.lang.NullPointerException

         at org.apache.jackrabbit.core.ItemManager.getDefinition(ItemManager.java:206)

         at org.apache.jackrabbit.core.ItemData.getDefinition(ItemData.java:99)

         at org.apache.jackrabbit.core.ItemManager.canRead(ItemManager.java:409)

         at org.apache.jackrabbit.core.ItemManager.createItemData(ItemManager.java:804)

         at org.apache.jackrabbit.core.ItemManager.getItemData(ItemManager.java:379)

         at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:316)

         at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:610)

         at org.apache.jackrabbit.core.SessionImpl.getNodeById(SessionImpl.java:493)

         at org.apache.jackrabbit.core.VersionManagerImpl$1.perform(VersionManagerImpl.java:122)

         at org.apache.jackrabbit.core.VersionManagerImpl$1.perform(VersionManagerImpl.java:114)

         at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:200)

         at org.apache.jackrabbit.core.VersionManagerImpl.perform(VersionManagerImpl.java:95)

         at org.apache.jackrabbit.core.VersionManagerImpl.checkin(VersionManagerImpl.java:114)

         at org.apache.jackrabbit.core.VersionManagerImpl.checkin(VersionManagerImpl.java:100)

 

I’ve tried the same with geronimo’s transaction manager but with the same result. Do you
really have to use a new session after each transaction commit/rollback?

 

Thanks for your help!

 

Marlis


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message