xtalbike
xtalbike

Reputation: 1

micronaut already associated with parent beanfactory error running grails 4 app on standalone tomcat 8.5

Tomcat 8.5.71 Grails 4.0.11 RHEL 7.8

The application runs fine with the embedded tomcat but won't load with standalone. Stacktrace is:

java.lang.IllegalStateException: Error starting child at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:757) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1016) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1903) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gdbxt]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) ... 9 more Caused by: java.lang.IllegalStateException: Already associated with parent BeanFactory: io.micronaut.spring.context.factory.MicronautBeanFactory@347aa4db: defining beans []; root of factory hierarchy at org.springframework.beans.factory.support.AbstractBeanFactory.setParentBeanFactory(AbstractBeanFactory.java:718) at org.springframework.context.support.GenericApplicationContext.setParent(GenericApplicationContext.java:158) at org.springframework.boot.builder.ParentContextApplicationContextInitializer.initialize(ParentContextApplicationContextInitializer.java:58) at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:623) at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:367) at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) at grails.boot.GrailsApp.run(GrailsApp.groovy:99) at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151) at org.grails.boot.context.web.GrailsAppServletInitializer.createRootApplicationContext(GrailsAppServletInitializer.groovy:57) at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91) at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5221) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ... 10 more

war file built for standalone tomcat has build.gradle with

provided "org.springframework.boot:spring-boot-starter-tomcat"

I have

server: port: 8091

in application.yml and also have the connector set to 8091 in the tomcat server.xml

This app is ported from grails 2.5.5. and is quite large with a number of additional dependencies. It has quartz jobs which I disabled with quartz.pluginEnabled: false in application.yml.

It does get as far as running bootstrap.groovy since it prints out some logging from that code.

Can someone point me to a possible cause of this sort of error?

Upvotes: 0

Views: 316

Answers (1)

xtalbike
xtalbike

Reputation: 1

Turns out that I had created an extra package in the grails-app/init folder when migrating by creating a new grails 4 project and copying over the files from the grails2 project. The error was due to trying to instantiate a second Application from the Application.groovy in that second init folder. Surprising that it worked with the built in tomcat and run-app.

Upvotes: 0

Related Questions