You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "seenu.atluri" <se...@gmail.com> on 2015/12/24 10:16:00 UTC

ArrayIndexOutofBoundsException on calling finder method with no args.

Hi Romain,

I have below finder method.

 <named-query name="TimeCategoryCMP.findDefaultTimeCategory">
            <query>SELECT OBJECT(o) from TimeCategoryCMP o WHERE
o.defaultFlag = 1</query>
</named-query>

When it is called and there is no result for the given query, openEJB is
expected to throw ObjectNotFoundException, but it is throwing EJB exception
as below.

javax.ejb.EJBException: The transaction has been marked rollback only
because the bean encountered a non-application exception
:java.lang.ArrayIndexOutOfBoundsException : 0

When i looked at the code, I think it is issue with below piece of code in
CmpContainer::findEJBObject()

 if (results.size() != 1) {
                    throw new ObjectNotFoundException("A Enteprise bean with
deployment_id = " +
                        beanContext.getDeploymentID() +
                        " and primarykey = " +
                        args[0] +
                        " Does not exist");
}

When finder method don't have any args, args[0] will throw
ArrayIndexOutofBoundsException. I could catch EJBException in my code and
move forward, but transaction is marked for rollback since it is
non-application exception. 

We are almost done with the migration of our huge application from Weblogic
to TomEE with your timely help. Now we are seeing bunch of failures in our
nightly build due to this issue as we have lot of findAll and finder methods
with no arguments. BTW, we are using "apache-tomee-plus-1.7.2". 

Can you please reply ASAP? Sorry to disturb you during holiday season.

Thanks & Regards,
Srinivas Atluri.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/ArrayIndexOutofBoundsException-on-calling-finder-method-with-no-args-tp4677312.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: ArrayIndexOutofBoundsException on calling finder method with no args.

Posted by Romain Manni-Bucau <rm...@gmail.com>.
backported to 1.7.4-SNAPSHOT branch

if you want to have a try building the snapshot it would be awesome


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-24 16:42 GMT+01:00 seenu.atluri <se...@gmail.com>:

> Thanks a lot Romain!!
>
> We do have lot of finder methods with no args. adding a dummy param
> involves
> lot of work. Would it be possible to get this fix pushed to
> apache-tomee-plus-1.7.2?
>
> Thanks & Regards,
> Srinivas Atluri.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/ArrayIndexOutofBoundsException-on-calling-finder-method-with-no-args-tp4677312p4677315.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: ArrayIndexOutofBoundsException on calling finder method with no args.

Posted by "seenu.atluri" <se...@gmail.com>.
Thanks a lot Romain!! 

We do have lot of finder methods with no args. adding a dummy param involves
lot of work. Would it be possible to get this fix pushed to
apache-tomee-plus-1.7.2?

Thanks & Regards,
Srinivas Atluri.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/ArrayIndexOutofBoundsException-on-calling-finder-method-with-no-args-tp4677312p4677315.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: ArrayIndexOutofBoundsException on calling finder method with no args.

Posted by Romain Manni-Bucau <rm...@gmail.com>.
ok, opened https://issues.apache.org/jira/browse/TOMEE-1686

is adding a parameter to this method a quick workaround you can use?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-24 10:16 GMT+01:00 seenu.atluri <se...@gmail.com>:

> Hi Romain,
>
> I have below finder method.
>
>  <named-query name="TimeCategoryCMP.findDefaultTimeCategory">
>             <query>SELECT OBJECT(o) from TimeCategoryCMP o WHERE
> o.defaultFlag = 1</query>
> </named-query>
>
> When it is called and there is no result for the given query, openEJB is
> expected to throw ObjectNotFoundException, but it is throwing EJB exception
> as below.
>
> javax.ejb.EJBException: The transaction has been marked rollback only
> because the bean encountered a non-application exception
> :java.lang.ArrayIndexOutOfBoundsException : 0
>
> When i looked at the code, I think it is issue with below piece of code in
> CmpContainer::findEJBObject()
>
>  if (results.size() != 1) {
>                     throw new ObjectNotFoundException("A Enteprise bean
> with
> deployment_id = " +
>                         beanContext.getDeploymentID() +
>                         " and primarykey = " +
>                         args[0] +
>                         " Does not exist");
> }
>
> When finder method don't have any args, args[0] will throw
> ArrayIndexOutofBoundsException. I could catch EJBException in my code and
> move forward, but transaction is marked for rollback since it is
> non-application exception.
>
> We are almost done with the migration of our huge application from Weblogic
> to TomEE with your timely help. Now we are seeing bunch of failures in our
> nightly build due to this issue as we have lot of findAll and finder
> methods
> with no arguments. BTW, we are using "apache-tomee-plus-1.7.2".
>
> Can you please reply ASAP? Sorry to disturb you during holiday season.
>
> Thanks & Regards,
> Srinivas Atluri.
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/ArrayIndexOutofBoundsException-on-calling-finder-method-with-no-args-tp4677312.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>