Hi Thiago To test it I would create a fake tomee - min libs used by the remoteserver, in target/mytest/faketomee and create a plain junit test and a nested main class using remote server that the unit test will launch through a fork. Then you just need to check the exit code of your fork (Process).
Sirona has that logic for its javaagent if you dont know with this block of text how to start ;). On the idea, 3 points: 1. I d replace the flag by an integer which is the exit code. If not set dont kill otherwise use it as exit code 2. IIRC this is not the only place it can happen so it is a partial impl probably 3. Why not just implementing in deployer utils (where we have our webapp deployer) a ExitDeploymentExceptionManager, can be set through system properties and in your docker you can add this jar easily Hope it makes sense. Le 9 nov. 2017 03:51, "Thiago Veronezi" <[email protected]> a écrit : > Guys, > > https://github.com/apache/tomee/pull/111 > > I've created this PR to kill the JVM on any deployment failure. I need to > get an error code from TomEE so docker knows the server died due to some > application error. This way, it will know it needs to start a new container > and try it again until the application is successfully deployed. > > Do we have something like this already implemented? If yes, how to use it? > > If no, do you guys agree with this approach, or do you think theres a > better way to get a system error? > > If you guys agree with the approach, do you have any tip on how to unit > test this? It looks like we can do it with junit ( > https://stackoverflow.com/questions/309396/java-how-to- > test-methods-that-call-system-exit), > but I would like to know if you guys can see any clever way to test it > without too much bytecode trickery. > > Example of output with this PR... > > 09-Nov-2017 02:38:39.532 INFO [main] > org.apache.openejb.config.AutoConfig.createContainer Auto-creating a > container for bean servlets.Comp1358857082: Container(type=MANAGED, > id=Default Managed Container) > 09-Nov-2017 02:38:39.591 INFO [main] > org.apache.openejb.config.OutputGeneratedDescriptors.writeEjbJar Dumping > Generated ejb-jar.xml to: > /opt/tomee/temp/ejb-jar-4480173124784608261ejbs.xml > 09-Nov-2017 02:38:39.842 INFO [main] > org.apache.openejb.config.OutputGeneratedDescriptors.writeOpenejbJar > Dumping Generated openejb-jar.xml to: > /opt/tomee/temp/openejb-jar-1229834934073978679ejbs.xml > 09-Nov-2017 02:38:39.888 SEVERE [main] > org.apache.openejb.config.ReportValidationResults.logResults FAIL ... > Hello: Missing > class <home> com.lala.support.demo.ear.ejb2.hello.HelloHomeeeee > 09-Nov-2017 02:38:39.889 SEVERE [main] > org.apache.openejb.config.ReportValidationResults.logResults Invalid > EjbModule(name=ejbs, path=/opt/tomee/apps/app/ejbs.jar) > 09-Nov-2017 02:38:39.892 INFO [main] > org.apache.openejb.config.ReportValidationResults.deploy Set the > 'openejb.validation.output.level' system property to VERBOSE for increased > validation details. > 09-Nov-2017 02:38:39.893 WARNING [main] > org.apache.openejb.config.ConfigurationFactory.configureApplication Jar > not > loaded. /opt/tomee/apps/app.ear. Module failed validation. > AppModule(name=app) > 09-Nov-2017 02:38:39.893 WARNING [main] > org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration > System property tomee.kill.jvm.on.deployment.failure activated. We will > kill the JVM due to deployment failure. > laplata:demo-tomee-ear tveronezi$ > > []s, > Thiago. >
