tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabio Jun Takada Chino (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TOMEE-2223) Incorrect JPA entity used when running under docker
Date Tue, 21 Aug 2018 22:54:00 GMT

    [ https://issues.apache.org/jira/browse/TOMEE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16588118#comment-16588118
] 

Fabio Jun Takada Chino commented on TOMEE-2223:
-----------------------------------------------

Hi,

The application is not an EAR but a simple pre-expanded WAR running alone in the server. There
is no duplicated classes involved.

Anyway, I think I found the cause of the problem. The Local annotation for EntityBRepository
was incorrectly pointing to the interface of the EntityARepository even thou it does not implement
that interface. When I fixed the annotation, the error vanished.

This is a simplified version of what happened:
 # interface IEntityARepository extends IBaseRepository<EntityA, String>
 # interface IEntityBRepository extends IBaseRepository<EntityB, EntityBKey>
 # class BaseRepository<EntityType, KeyType> implements IBaseRepository<EntityType,
KeyType>
 # class EntityARepostory extends BaseRepository<EntityA, String> implements IEntityARepository
 # class EntityBRepostory extends BaseRepository<EntityB, EntityBKey> implements IEntityBRepository
 # The Local annotation for EntityARepostory and EntityBRepostory were pointing to IEntityARepository.
 # The EJB proxy was was implementing IEntityARepository but was delegating the calls to an
instance of EntityBRepostory;

Since EntityBRepostory does not implement the interface IEntityARepostory, the proxy behavior
in 7 should not be possible but it is exactly what is happening. In fact, I think that it
should generate an error because it is quite simple to see that, although EntityBRepostory's
Local annotation is pointing to IEntityARepostory, it is not implemented by EntityBRepostory.
This should help the identification of this problems faster.

Furthermore, the random nature of this issue delayed the identification of the problem even
more because sometimes TomEE was using the annotations blindly while in other situations it
was using the actual class hierarchy to create the EJB proxies.

Do you think it's possible to implement an error message to at least alert to this kind of
situation?

Thanks in advance,

> Incorrect JPA entity used when running under docker
> ---------------------------------------------------
>
>                 Key: TOMEE-2223
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2223
>             Project: TomEE
>          Issue Type: Bug
>          Components: TomEE Core Server
>    Affects Versions: 7.0.5
>         Environment: * Docker version 17.12.1-ce, build 7390fc6;
> * Official Ubuntu 18.04 (x64) docker image with OpenJDK 8 installed;
> * apache-tomee-webprofile-7.0.5;
> * Apache Derby 10.14.2.0 (embedded);
>            Reporter: Fabio Jun Takada Chino
>            Priority: Minor
>
> While packing a very simple web application inside a docker container based on the official
Ubuntu 18.04 image, I found a very inconvenient error related to OpenJPA using the wrong entity
to access the database.
> When it happens, the following exception can be found in the log:
> {{org.apache.openjpa.persistence.ArgumentException : The given value "test" cannot be
converted into an identity for "class EntityB".  The value is the wrong type (java.lang.String)}}{{
using the wrong entity to store information inside}}
> The major problem with this code is that the actual method is trying to access the entity
EntityA instead of EntityB. The conversion error occurs because the ID for EntityB is a composite
value while the ID for EntityA is indeed a string.
> Given that, I tried to trace the issue using a remote debugger but, when I activate,
the problem vanishes. It does not matter if the debugger is connected or not. Since it is
not a critical application, I can workaround it by leaving the remote debugger enabled but
it would be a real issue for production environment.
> The docker image I'm using as the base can be found in the Docker Hub with the name opencs/ubuntu-openjdk-8-headless.
> The application is a single WAR file with some EJBs, JPA entities, a few servlets and
a few JSF pages. Almost all JPA entities have single primary keys but one of them have a composite
key with 2 strings.
> Thanks in advance,
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message