tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quintin Beukes (JIRA)" <>
Subject [jira] Updated: (OPENEJB-1070) LocalInitialContextFactory can't be extended
Date Thu, 10 Sep 2009 13:26:57 GMT


Quintin Beukes updated OPENEJB-1070:

    Attachment: reflection.patch

Applies the following change to: container/openejb-core/src/main/java/org/apache/openejb/client/

Constructor constructor = localInitialContext.getConstructor(Hashtable.class, this.getClass());

Constructor constructor = localInitialContext.getConstructor(Hashtable.class, LocalInitialContextFactory.class);

> LocalInitialContextFactory can't be extended
> --------------------------------------------
>                 Key: OPENEJB-1070
>                 URL:
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1.2
>            Reporter: Quintin Beukes
>            Priority: Trivial
>             Fix For: 3.1.2
>         Attachments: reflection.patch
> When extended org.apache.openejb.client.LocalInitialContextFactory you can't use it to
create a new InitialContext. This is due to the way it constructs the LocalInitialContext
object using reflection, ie.:
>             Constructor constructor = localInitialContext.getConstructor(Hashtable.class,
> If you extend it this.getClass() returns the new classes identity, and there won't be
such a constructor unless you override getInitialContext(Hashtable) and do it yourself. In
most cases this is fine, though there might be cases where you override it for other purposes,
and in these cases it becomes a problem.
> Also. Anyone who used it like this in previous versions who upgrade will receive NoSuchMethod
> Since it's intended for this.getClass() to return a LocalInitialContextFactory always
(since that's the only constructor provided by LocalInitialContext), you might as well reference
the class object statically, like so:
>             Constructor constructor = localInitialContext.getConstructor(Hashtable.class,
> This all happens in this file: container/openejb-core/src/main/java/org/apache/openejb/client/
> Further, I assume for compatibility you still provide: ./container/openejb-core/src/main/java/org/openejb/client/
> People who are using this file will also get an error, since it is simple an extension
of the former, and thus the reflection won't work.
> I attached a patch to fix this problem as described.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message