Hi,
For example this would not work if you have unsatisified resource-ref:
09-Nov-2017 09:38:59.118 SEVERE [localhost-startStop-1]
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal Unable to
deploy collapsed ear in war
StandardEngine[Catalina].StandardHost[localhost].StandardContext[]
org.apache.openejb.OpenEJBException: Can't find resource for null. (No
provider available for resource-ref 'null' of type
'xxx.yyy.zzz.KeyStoreService' for '.Comp154478778'.)
at
org.apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java:1224)
at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:873)
at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:201)
at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1037)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1277)
at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1125)
at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:133
Or when a ServletContextListener fails:
09-Nov-2017 09:51:30.180 SEVERE [localhost-startStop-1]
org.apache.catalina.core.StandardContext.startInternal One or more
listeners failed to start. Full details will be found in the appropriate
container log file
09-Nov-2017 09:51:30.180 SEVERE [localhost-startStop-1]
org.apache.catalina.core.StandardContext.startInternal Context [] startup
failed due to previous errors
I didn't test it with ServletContainerInitializer, but I\m pretty sure it
will not work as well.
Have you considered using Tomcat's LifecycleListener to intercept
LifecycleEvent's ?
Best regards,
Svetlin
2017-11-09 4:50 GMT+02:00 Thiago Veronezi <[email protected]>:
> 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.
>