Details
Description
I have an application that uses activemq-camel and deploys/works fine with GlassFish v3. I tried to deploy the same application on GlassFish v4 and get this error:
remote failure: Error occurred during deployment: Exception while deploying the app [appname] : The lifecycle method [afterPropertiesSet] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void org.apache.activemq.camel.component.CamelEndpointLoader.afterPropertiesSet() throws java.lang.Exception] of type [METHOD]. Please see server.log for more details.
Command deploy failed.
It appears that CamelEndpointLoader has a @PostConstruct method that throws an Exception and per the Java EE spec that isn't allowed. Apparently GlassFish v3 was lenient but v4 is not.
Looking at the code, it is easy to fix. The afterPropertiesSet method just needs to catch the exceptions from addQueue/addTopic and log them at the end of the method like it does earlier in the method. If a failure to add these during the method should actually be considered a failure, then something like IllegalStateException or another unchecked exception should be thrown instead.
This fix has been tested and verified to get past the problem.