This message was deleted.
# questions
s
This message was deleted.
s
I'm seeing an exception thrown when tryin to deploy the war on tomcat 9. Creating an app from scratch using Grails Forge and only adding the database migration feature will generate the same error.
g
What error?
s
When the war deploys to tomcat 9, with the database-migration dependency added (I've tried both with and without the liquibase dependency recommended in the docs):
Copy code
implementation("org.grails.plugins:database-migration:4.2.1")
implementation 'org.liquibase:liquibase-core:4.19.1'
Tomcat 9 throws an exception when deploying the war with Java 11:
java.lang.IllegalStateException: Error starting child
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:686)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:658)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:661)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1025)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1919)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:826)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:476)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1619)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:318)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:114)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:345)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:893)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:794)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:248)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:921)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/demoall-0.1]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:419)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:186)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:683)
... 37 more
Caused by: java.lang.NullPointerException
at org.springframework.boot.cli.app.SpringApplicationWebApplicationInitializer.getSources(SpringApplicationWebApplicationInitializer.java:61)
at org.springframework.boot.cli.app.SpringApplicationWebApplicationInitializer.onStartup(SpringApplicationWebApplicationInitializer.java:47)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4904)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
... 38 more
When the database-migration dependency is removed, the war deploys fine.
Also, in case it's helpful, with the database-migration dependency added, running dbm tasks works fine, it's just when deploying the war that causes an error.
m
Remove the dependency grails-shell when packaging the war, grails-shell should not be on the runtime classpath because database-migration depends on it
๐Ÿ‘ 1
g
@spiridon can you run this with java -jar directly?
๐Ÿ˜‚,sorry, never saw this error before, however, I used java -jar directly and it runs fine. If you look at the line number 60 of SpringApplicationWebApplicationInitializer, which throws a null exception.
Copy code
private String[] getSources(ServletContext servletContext) throws IOException {
    Manifest manifest = getManifest(servletContext);
    if (manifest == null) {
       throw new IllegalStateException("Unable to read manifest");
    }
    String sources = manifest.getMainAttributes().getValue(SOURCE_ENTRY);
    return sources.split(",");
}

private Manifest getManifest(ServletContext servletContext) throws IOException {
    InputStream stream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF");
    return (stream != null) ? new Manifest(stream) : null;
}
Copy code
manifest.getMainAttributes().getValue(SOURCE_ENTRY);
I guess the manifest is null.
Copy code
InputStream stream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF");
You can find many threads related to this issue on SO.
๐Ÿ‘ 1
s
@Michael Yan I see the database-migration plugin has a dependency on grails-shell, but wasn't sure how to remove the specific grails-shell dependency when packaging the war since grails-shell is not explicitly listed in build.gradle -- I may not be following, but appreciate the help!
m
@spiridon try it like this, configurations { developmentOnly runtimeClasspath { // Excludes from database-migration exclude group: 'org.grails', module: 'grails-shell' } }
๐Ÿ™ 3
s
Thank you @Michael Yan, that did the trick. Since the database-migration plugin has been the same for a while, and never explicitly needed the exclusion for the grails-shell before, was trying to track down my deploy issues looking elsewhere, so appreciate it!
m
My pleasure!
p
@spiridon Please report an issue.
๐Ÿ‘ 1
d
@spiridon can you share your build.gradle and application.groovy files. Iโ€™m getting an error trying with the migration plugin
Copy code
Command execution error: liquibase/command/core/InternalDiffChangelogCommandStep
Any command i run related to the plugin has same error.
Imโ€™ on grails 6.1.2
Copy code
runCommand -Pargs="dbm-gorm-diff cl_changeset.groovy"
ignore figured it out. Canโ€™t use the latest liquibase version had to use the 4.19.0 version
4.24.X does not work and throws that error
s
Sorry, was on travel for a few days! Glad you figured it out. And yes, I'm using database migration plugin 4.2.1 with liquibase plugin 4.19.1
100 Views