The lifecycle method [onStartup] must not throw a checked exception when deploying in JEE7 GlassFish 4

Hi all,

Just discovered this library today and it’s been what I have been looking for for a long time! Glad I found it. Now to learn how to use it.

I found an article on use it from about 2 years ago along with Shiro for security. Liquibase was used to configure the Shiro Jdbcrealm tables. Shiro btw is very good too!

Anyway, I put the latest 3.0.1 jar file in my WEB-INF/lib folder, and have the context listener configured in my web.xml. When I deploy, I am getting the below exception. I found a link from about a year ago on the github commit that someone fixed this issue for dealing with CDI and Glassfish 4. Yet, I am still getting it, so not quite sure if that code is in the 3.0.1 or not yet there. Says it was merged.

Any help to shed light on this would be fantastic! I can’t wait to use this library to keep my database up to date with changes!

Thank you.

[2013-07-07T12:43:49.476-0700] [glassfish 4.0] [SEVERE] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=109 _ThreadName=AutoDeployer] [timeMillis: 1373226229476] [levelValue: 1000] [[
  Exception during lifecycle processing
java.lang.IllegalStateException: The lifecycle method [onStartup] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void liquibase.integration.cdi.CDILiquibase.onStartup() throws liquibase.exception.LiquibaseException] of type [METHOD]
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(
    at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(
    at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(
    at com.sun.enterprise.deployment.archivist.Archivist.openWith(
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(
    at org.glassfish.javaee.core.deployment.DolProvider.processDOL(
    at org.glassfish.javaee.core.deployment.DolProvider.load(
    at org.glassfish.javaee.core.deployment.DolProvider.load(
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(
    at org.glassfish.deployment.admin.DeployCommand.execute(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(
    at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(
    at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(
    at org.glassfish.deployment.autodeploy.AutoDeployService$
    at java.util.TimerThread.mainLoop(
Caused by: The lifecycle method [onStartup] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void liquibase.integration.cdi.CDILiquibase.onStartup() throws liquibase.exception.LiquibaseException] of type [METHOD]
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(
    at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(
    at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(
    … 27 more
Caused by: java.lang.IllegalArgumentException: The lifecycle method [onStartup] must not throw a checked exception
    at com.sun.enterprise.deployment.annotation.handlers.AbstractResourceHandler.validateAnnotatedLifecycleMethod(
    at com.sun.enterprise.deployment.annotation.handlers.PostConstructHandler.processAnnotation(
    at com.sun.enterprise.deployment.annotation.handlers.AbstractResourceHandler.processAnnotation(
    at com.sun.enterprise.deployment.annotation.factory.SJSASFactory$LazyAnnotationHandler.processAnnotation(
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(
    … 33 more

Looking at Github src, this is what I see:

    public void onStartup() throws LiquibaseException {

According to the spec from JEE5, the @PostConstruct shouldn’t throw a typed exception. I am curious if this is part of the source since way back when, how could anyone have deployed this with a JEE app? Also not sure how the one link I found that indicates some guy made changes and that they were merged that fixed this, why it’s not here now?

Hopefully someone else has deployed with JEE containers and can fill me in on what I am missing.

This is the link to the “fix” that I would assume fixes this issue, but isn’t in the 3.0.1 jar.

My bad on the above link… there is another reply about 4 days ago that someone else is seeing the same problem I got. I finally got the src, and built it. I removed the throws and stuff, built it, and deployed. It seems to get past that issue now, but now I am getting an Unsatisfied dependencies for type [DataSource] which I am trying to track down.

Still, regarding this issue, seems the code should be updated to adhere to the spec.

I removed the thrown exception in 3.0.2. The CDI code was contributed so I’m not quite sure how the LiquibaseType annotation should be used, however.


Using the 3.0.2 does not work for me anyone else more luck?

  1. WARNING:   AS-CDI-005
    WARNING:   Class ‘javax.ejb.PostActivate’ not found, interception based on it is not enabled
    WARNING:   Class ‘javax.ejb.PrePassivate’ not found, interception based on it is not enabled
    WARNING:   WELD-001473 javax.enterprise.inject.spi.Bean implementation liquibase.integration.cdi.CDIBootstrap$1@1a7587a declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won’t be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.
    SEVERE:   No valid EE environment for injection of liquibase.integration.cdi.CDILiquibase
    SEVERE:   Exception during lifecycle processing
    org.glassfish.deployment.common.DeploymentException: CDI deployment failure:Exception List with 1 exceptions:
    Exception 0 :
    javax.ejb.EJBException: Versuch, aufzurufen, während Container in Initializing enthalten ist
        at com.sun.ejb.containers.BaseContainer.postInvoke(
        at com.sun.ejb.containers.BaseContainer.postInvoke(
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(
        at com.sun.proxy.$Proxy351.createConfig(Unknown Source)
        at org.easy.scrum.service.db.EJB31_Generated__LiquibaseProducer__Intf____Bean.createConfig(Unknown Source)

Will post more comments here: