[jboss-jira] [JBoss JIRA] Commented: (JBAS-4295) throw a 'no transaction' exception instead of NPE

Alexey Loubyansky (JIRA) jira-events at lists.jboss.org
Wed Apr 4 05:07:58 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBAS-4295?page=comments#action_12358346 ] 
            
Alexey Loubyansky commented on JBAS-4295:
-----------------------------------------

The following has been committed to Branch_4_0 and Branch_4_2. Branch_5_0 is currently in code freeze mode because of the next beta release.

       private void loadOnlyFromCache(EntityEnterpriseContext ctx)
       {
          PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext();
+         if(pctx == null)
+         {
+            throw new EJBException("Persistence context is not available! Make sure the CMR collection is accessed in the transaction it was obtained.");
+         }
          pctx.loadCachedRelations(cmrIndex, this);
       }


> throw a 'no transaction' exception instead of NPE
> -------------------------------------------------
>
>                 Key: JBAS-4295
>                 URL: http://jira.jboss.com/jira/browse/JBAS-4295
>             Project: JBoss Application Server
>          Issue Type: Task
>      Security Level: Public(Everyone can see) 
>          Components: CMP service
>    Affects Versions: JBossAS-5.0.0.Beta1, JBossAS-4.0.5.GA, JBossAS-4.2.0.CR1
>            Reporter: Alexey Loubyansky
>         Assigned To: Alexey Loubyansky
>             Fix For: JBossAS-4.2.0.GA, JBossAS-5.0.0.Beta2,  JBossAS-5.0.0.Beta3
>
>
> java.lang.NullPointerException
> at org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCCMRFieldBridge2$CollectionValuedFieldState.loadOnlyFromCache(JDBCCMRFieldBridge2.java:1085)
> was caused by calling size() on a CMR collection w/o a transaction. It would be better to throw an exception with a message explaining the problem.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list