[jira] [Commented] (TOMEE-2223) Incorrect JPA entity used when running under docker
[ https://issues.apache.org/jira/browse/TOMEE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16586940#comment-16586940 ] Romain Manni-Bucau commented on TOMEE-2223: --- EJB dont use constructors until it is a CDI constructor so it is likely you code is ignored and you end up on such an issue. Mobe your constructor code to a postconstruct method and it should work. > 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)
[jira] [Comment Edited] (TOMEE-2223) Incorrect JPA entity used when running under docker
[ https://issues.apache.org/jira/browse/TOMEE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16586785#comment-16586785 ] Fabio Jun Takada Chino edited comment on TOMEE-2223 at 8/21/18 1:40 AM: Hi, In the first few attempts, I was lucky enough to replicate the issue and attach the debugger to see what is happening. The issue is not related to OpenJPA but with the incorrect generation of the EJB proxies that is mixing the inner instances after it. In order to save time, I wrote a single base abstract class called BaseRepository that has a constructor that receives the actual class that will be used to access the database (field entityClass). This class has a method called find(KeyType) that calls em.find(this.entityClass, key). Each concrete class is implemented as EntityARepository extends BaseRepository passing EntityA.class to the base constructor and EntityBRepository extends BaseRepository When the issue occurs, I'm calling an EJB that is an instance of EntityARepository, the proxy says that it is indeed a proxy to EntityARepository but, when I intercept the method find() from BaseRepository, the proxy is calling a concreate instance of EntityBRepository instead. I already used this construction before in other JEE servers and earlier versions of TomEE and it never happened before. In fact, is is not happening outside the docker container. Thanks in advance, Fabio was (Author: fjtc): Hi, In the first few attempts, I was lucky enough to replicate the issue and attach the debugger to see what is happening. The issue is not related to OpenJPA but with the incorrect generation of the EJB proxies that is mixing the inner instances after it. In order to save time, I wrote a single base abstract class called BaseRepository that has a constructor that receives the actual class that will be used to access the database (field entityClass). This class has a method called find(KeyType) that calls em.find(this.entityClass, key). Each concrete class is implemented as EntityARepository extends BaseRepository passing EntityA.class to the base constructor and EntityBRepository extends BaseRepository When the issue occurs, I'm calling an EJB that is an instance of EntityARepository, the proxy says that it is indeed a proxy to EntityARepository but, when I intercept the method find() from BaseRepository, the proxy is calling a concreate instance of EntityBRepository instead. I already used this construction before in other JEE servers and earlier versions of TomEE and it never happened before. In fact, is is not happening outside the docker container. Thanks in advance, Fabio > 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)
[jira] [Comment Edited] (TOMEE-2223) Incorrect JPA entity used when running under docker
[ https://issues.apache.org/jira/browse/TOMEE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16586728#comment-16586728 ] Fabio Jun Takada Chino edited comment on TOMEE-2223 at 8/21/18 1:40 AM: I tried again, this time with: At first, it appeared that the issue had vanished but after a few restarts, I got the same problem again. I'll try to replicate the issue in debug mode and attach a debugger after I got the first error in order to see if it can reveal what is happening within the code. As soon as I have news I'll write again. Fabio, was (Author: fjtc): I tried again, this time with: At first, it appeared that the issue had vanished but after a few restarts, I got the same problem again. I'll try to replicate the issue in debug mode and attach a debugger after I got the first error in order to see if it can reveal what is happening within the code. As soon as I have news I'll write again. Fabio, > 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)
[jira] [Commented] (TOMEE-2223) Incorrect JPA entity used when running under docker
[ https://issues.apache.org/jira/browse/TOMEE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16586785#comment-16586785 ] Fabio Jun Takada Chino commented on TOMEE-2223: --- Hi, In the first few attempts, I was lucky enough to replicate the issue and attach the debugger to see what is happening. The issue is not related to OpenJPA but with the incorrect generation of the EJB proxies that is mixing the inner instances after it. In order to save time, I wrote a single base abstract class called BaseRepository that has a constructor that receives the actual class that will be used to access the database (field entityClass). This class has a method called find(KeyType) that calls em.find(this.entityClass, key). Each concrete class is implemented as EntityARepository extends BaseRepository passing EntityA.class to the base constructor and EntityBRepository extends BaseRepository When the issue occurs, I'm calling an EJB that is an instance of EntityARepository, the proxy says that it is indeed a proxy to EntityARepository but, when I intercept the method find() from BaseRepository, the proxy is calling a concreate instance of EntityBRepository instead. I already used this construction before in other JEE servers and earlier versions of TomEE and it never happened before. In fact, is is not happening outside the docker container. Thanks in advance, Fabio > 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)
[jira] [Commented] (TOMEE-2223) Incorrect JPA entity used when running under docker
[ https://issues.apache.org/jira/browse/TOMEE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16586728#comment-16586728 ] Fabio Jun Takada Chino commented on TOMEE-2223: --- I tried again, this time with: At first, it appeared that the issue had vanished but after a few restarts, I got the same problem again. I'll try to replicate the issue in debug mode and attach a debugger after I got the first error in order to see if it can reveal what is happening within the code. As soon as I have news I'll write again. Fabio, > 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)
[1/2] tomee git commit: avoid to scan too much when reactor has itest jars
Repository: tomee Updated Branches: refs/heads/tomee-7.1.x 3f96b4280 -> 86379b927 avoid to scan too much when reactor has itest jars (cherry picked from commit 76cd27f) Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/86379b92 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/86379b92 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/86379b92 Branch: refs/heads/tomee-7.1.x Commit: 86379b927e072cab03666bfb988dd24ea799528f Parents: 11a2081 Author: Romain Manni-Bucau Authored: Wed May 16 08:39:44 2018 +0100 Committer: Roberto Cortez Committed: Mon Aug 20 22:16:51 2018 +0100 -- .../openejb-core/src/main/resources/default.exclusions | 3 +++ .../org/apache/openejb/config/EarModuleNamesTest.java | 10 +- .../org/apache/openejb/config/rules/InvokeMethod.java | 12 3 files changed, 24 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/tomee/blob/86379b92/container/openejb-core/src/main/resources/default.exclusions -- diff --git a/container/openejb-core/src/main/resources/default.exclusions b/container/openejb-core/src/main/resources/default.exclusions index d46396b..9bcd832 100644 --- a/container/openejb-core/src/main/resources/default.exclusions +++ b/container/openejb-core/src/main/resources/default.exclusions @@ -33,6 +33,7 @@ axis2- batchee-jbatch bcprov- bootstrap.jar +bsh- bval-core bval-jsr byte-buddy @@ -63,6 +64,7 @@ commons-pool2- cryptacular- cssparser- cxf- +debugger-agent deploy.jar derby- derbyclient- @@ -141,6 +143,7 @@ jsr311- jsse.jar juli- junit- +junit5- kahadb- kotlin-runtime leveldb http://git-wip-us.apache.org/repos/asf/tomee/blob/86379b92/container/openejb-core/src/test/java/org/apache/openejb/config/EarModuleNamesTest.java -- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/EarModuleNamesTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/EarModuleNamesTest.java index eadab2f..cbb6096 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/EarModuleNamesTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/EarModuleNamesTest.java @@ -29,6 +29,7 @@ import javax.ejb.Singleton; import java.io.File; import java.util.HashMap; import java.util.Map; +import java.util.stream.Stream; import static org.junit.Assert.assertEquals; @@ -36,15 +37,23 @@ import static org.junit.Assert.assertEquals; * @version $Rev$ $Date$ */ public class EarModuleNamesTest { +private static final String[] ORIGINAL_EXCLUSIONS = NewLoaderLogic.getExclusions(); + @BeforeClass public static void preventDefaults() { System.setProperty("openejb.environment.default", "false"); SystemInstance.reset(); +// we use it in a bunch of other tests but not here +NewLoaderLogic.setExclusions( +Stream.concat(Stream.of(ORIGINAL_EXCLUSIONS), +Stream.of("openejb-itest", "failover-ejb")) + .toArray(String[]::new)); } @AfterClass public static void reset() { System.clearProperty("openejb.environment.default"); +NewLoaderLogic.setExclusions(ORIGINAL_EXCLUSIONS); SystemInstance.reset(); } @@ -215,7 +224,6 @@ public class EarModuleNamesTest { assertEquals("testIdWebapp", appInfo.webApps.get(0).moduleId); } - @Singleton public static class Orange { http://git-wip-us.apache.org/repos/asf/tomee/blob/86379b92/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java -- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java index 7ef0dbd..d7c6eb0 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java @@ -22,6 +22,7 @@ import org.apache.openejb.assembler.classic.TransactionServiceInfo; import org.apache.openejb.config.AppModule; import org.apache.openejb.config.ConfigurationFactory; import org.apache.openejb.config.EjbModule; +import org.apache.openejb.config.NewLoaderLogic; import org.apache.openejb.config.OutputGeneratedDescriptors; import org.apache.openejb.config.ValidationContext; import org.apache.openejb.config.ValidationFailedException; @@ -39,6 +40,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.ResourceBundle; import java
[2/2] tomee git commit: fix broken stateless bean
fix broken stateless bean blew up in other tests with validation errors (cherry picked from commit ddd970b) Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/11a20818 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/11a20818 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/11a20818 Branch: refs/heads/tomee-7.1.x Commit: 11a2081879d0c5f20a81ab8f21285fe7e671b9b2 Parents: 3f96b42 Author: Mark Struberg Authored: Tue May 15 20:59:50 2018 +0100 Committer: Roberto Cortez Committed: Mon Aug 20 22:16:51 2018 +0100 -- .../test/stateful/AnnotatedFieldInjectionStatefulBean.java | 8 1 file changed, 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/tomee/blob/11a20818/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulBean.java -- diff --git a/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulBean.java b/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulBean.java index d194c44..2219f8f 100644 --- a/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulBean.java +++ b/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/AnnotatedFieldInjectionStatefulBean.java @@ -103,14 +103,6 @@ public class AnnotatedFieldInjectionStatefulBean { private BasicStatefulBusinessRemote statefulBusinessRemote; -@Init -public void create(final String name) { -} - -@Remove -public void remove() { -} - public void lookupEntityBean() throws TestFailureException { try { Assert.assertNotNull("The EJBObject is null", bmpHome);
[jira] [Commented] (TOMEE-2223) Incorrect JPA entity used when running under docker
[ https://issues.apache.org/jira/browse/TOMEE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16586391#comment-16586391 ] Romain Manni-Bucau commented on TOMEE-2223: --- Hmm maybe set the cavhe mode to none, ensure sql queries are logged to be able to check cache is not used. If it doesnt help you should try sharing a reproducer as a girhub maven project with a failing unit test. > 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)
[jira] [Commented] (TOMEE-2223) Incorrect JPA entity used when running under docker
[ https://issues.apache.org/jira/browse/TOMEE-2223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16586381#comment-16586381 ] Fabio Jun Takada Chino commented on TOMEE-2223: --- Hi Romain, I changed the persistence parameters to: {{ }} {{ }} {{ }} {{ }} but I still got the same results but with a lower frequency when debug is disabled. The comparison of the startup logs lead to a dead end because they are exactly the same. No errors nor warnings. Is there any additional parameter that I can activate in order to get more information about the execution of the error? Thanks in advance, Fabio > 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)
[1/2] tomee git commit: jdk 11 compatibility
Repository: tomee Updated Branches: refs/heads/tomee-7.0.x e157f6d7c -> e4ba57043 jdk 11 compatibility Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/84f96946 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/84f96946 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/84f96946 Branch: refs/heads/tomee-7.0.x Commit: 84f9694678403e326f48e504aa5e9145ca7cbe97 Parents: e157f6d Author: Vicente Rossello Authored: Wed Aug 15 23:55:01 2018 +0200 Committer: Jonathan Gallimore Committed: Mon Aug 20 14:37:40 2018 +0100 -- .../util/proxy/LocalBeanProxyFactory.java | 37 +--- 1 file changed, 33 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/tomee/blob/84f96946/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java -- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java index 8a0dd8a..a36f7b8 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java @@ -17,6 +17,9 @@ package org.apache.openejb.util.proxy; + +import org.apache.openejb.util.LogCategory; +import org.apache.openejb.util.Logger; import org.apache.openejb.util.Debug; import org.apache.xbean.asm6.ClassWriter; import org.apache.xbean.asm6.Label; @@ -47,6 +50,8 @@ import java.util.concurrent.locks.ReentrantLock; public class LocalBeanProxyFactory implements Opcodes { +private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, QueryProxy.class); + public static final InvocationHandler NON_BUSINESS_HANDLER = new NonBusinessHandler(); private static final String BUSSINESS_HANDLER_NAME = "businessHandler"; @@ -700,7 +705,7 @@ public class LocalBeanProxyFactory implements Opcodes { // sun.misc.Unsafe private static final Object unsafe; -private static final Method defineClass; +private static final Method unsafeDefineClass; private static final Method allocateInstance; private static final Method putObject; private static final Method objectFieldOffset; @@ -774,7 +779,7 @@ public class LocalBeanProxyFactory implements Opcodes { } } }); -defineClass = AccessController.doPrivileged(new PrivilegedAction() { +unsafeDefineClass = AccessController.doPrivileged(new PrivilegedAction() { @Override public Method run() { try { @@ -782,7 +787,8 @@ public class LocalBeanProxyFactory implements Opcodes { mtd.setAccessible(true); return mtd; } catch (final Exception e) { -throw new IllegalStateException("Cannot get sun.misc.Unsafe.defineClass", e); +LOGGER.debug("Unsafe's defineClass not available, will use classloader's defineClass"); +return null; } } }); @@ -816,8 +822,31 @@ public class LocalBeanProxyFactory implements Opcodes { // it is super important to pass a classloader as first parameter otherwise if API class is in a "permanent" classloader then it will leak public static Class defineClass(final ClassLoader loader, final Class clsToProxy, final String proxyName, final byte[] proxyBytes) throws IllegalAccessException, InvocationTargetException { -return (Class) defineClass.invoke(unsafe, proxyName, proxyBytes, 0, proxyBytes.length, loader, clsToProxy.getProtectionDomain()); +if (unsafeDefineClass != null) { +return (Class) unsafeDefineClass.invoke(unsafe, proxyName, proxyBytes, 0, proxyBytes.length, loader, clsToProxy.getProtectionDomain()); +} else { +return (Class) getClassLoaderDefineClassMethod(loader).invoke(loader, proxyName, proxyBytes, 0, proxyBytes.length, clsToProxy.getProtectionDomain()); +} +} + +private static Method getClassLoaderDefineClassMethod(ClassLoader classLoader) { +Class clazz = classLoader.getClass(); +Method defineClassMethod = null; +do { +try { +defineClassMethod = clazz.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class, ProtectionDomain.class); +} catch (NoSuchMethodException e) { +
[2/2] tomee git commit: typo
typo Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e4ba5704 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e4ba5704 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e4ba5704 Branch: refs/heads/tomee-7.0.x Commit: e4ba570435b23a73c3b20f8cb3da4ccf6ee595c6 Parents: 84f9694 Author: Vicente Rossello Authored: Thu Aug 16 00:16:38 2018 +0200 Committer: Jonathan Gallimore Committed: Mon Aug 20 14:37:49 2018 +0100 -- .../java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/tomee/blob/e4ba5704/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java -- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java index a36f7b8..20e9ab9 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java @@ -50,7 +50,7 @@ import java.util.concurrent.locks.ReentrantLock; public class LocalBeanProxyFactory implements Opcodes { -private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, QueryProxy.class); +private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, LocalBeanProxyFactory.class); public static final InvocationHandler NON_BUSINESS_HANDLER = new NonBusinessHandler();