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(Archivist.java:518)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446)
    at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:338)
    at org.glassfish.web.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:91)
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:420)
    at com.sun.enterprise.deployment.archivist.Archivist.openWith(Archivist.java:292)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:232)
    at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:188)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:222)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:878)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:818)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:374)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:537)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
    at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:164)
    at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:595)
    at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:482)
    at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:410)
    at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:401)
    at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:233)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)
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(AnnotationProcessorImpl.java:367)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:375)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:289)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:217)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)
    at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:626)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462)
    … 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(AbstractResourceHandler.java:186)
    at com.sun.enterprise.deployment.annotation.handlers.PostConstructHandler.processAnnotation(PostConstructHandler.java:72)
    at com.sun.enterprise.deployment.annotation.handlers.AbstractResourceHandler.processAnnotation(AbstractResourceHandler.java:142)
    at com.sun.enterprise.deployment.annotation.factory.SJSASFactory$LazyAnnotationHandler.processAnnotation(SJSASFactory.java:148)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:344)
    … 33 more

Looking at Github src, this is what I see:

@PostConstruct
    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.

https://github.com/liquibase/liquibase/pull/25

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.


Nathan

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(BaseContainer.java:1984)
        at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
        at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
        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:
https://github.com/liquibase/liquibase/pull/25