upgrade tomcat7-maven-plugin to cargo-maven3-plugin with contianer Id tomcat9x
Asked Answered
B

1

4

please help , configuring cargo-maven3-plugin and facing the problem below , thank you and appreciate those who have experience on the cargo and tomcat 9 plugin . thank you very much

pom.xml file configuration for cargo-maven3-plugin

<plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <configuration>
                <container>
                    <containerId>tomcat9x</containerId>
                    <type>embedded</type>
                    <zipUrlInstaller>
                        <url>https://repo.maven.apache.org/maven3/org/apache/tomcat/tomcat/9.0.58/tomcat-9.0.58.zip</url>
                    </zipUrlInstaller>
                </container>
                <deployables>
                    <deployable>
                        <properties>
                            <context></context>
                        </properties>
                    </deployable>
                </deployables>
                <configuration>
                    <properties>
                        <cargo.servlet.port>8082</cargo.servlet.port>
                    </properties>
                </configuration>
            </configuration>
        </plugin>

tomcat 9 server console startup error log :

Feb 10, 2022 5:10:20 PM org.apache.catalina.startup.ContextConfig authenticatorConfig
SEVERE: Cannot instantiate an authenticator of class [org.apache.catalina.authenticator.NonLoginAuthenticator]
java.lang.NoClassDefFoundError: javax/security/auth/message/config/RegistrationListener
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
    at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at org.apache.catalina.startup.ContextConfig.authenticatorConfig(ContextConfig.java:395)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:997)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:303)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5135)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
    at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:788)
    at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:738)
    at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:249)
    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.codehaus.cargo.container.tomcat.internal.TomcatEmbedded$Wrapper.invoke(TomcatEmbedded.java:454)
    at org.codehaus.cargo.container.tomcat.internal.TomcatEmbedded$Wrapper.invoke(TomcatEmbedded.java:413)
    at org.codehaus.cargo.container.tomcat.internal.TomcatEmbedded$Embedded.createContext(TomcatEmbedded.java:712)
    at org.codehaus.cargo.container.tomcat.TomcatEmbeddedLocalDeployer.deploy(TomcatEmbeddedLocalDeployer.java:91)
    at org.codehaus.cargo.container.tomcat.TomcatEmbeddedLocalDeployer.redeploy(TomcatEmbeddedLocalDeployer.java:149)
    at org.codehaus.cargo.container.tomcat.internal.AbstractCatalinaEmbeddedLocalContainer.doStart(AbstractCatalinaEmbeddedLocalContainer.java:166)
    at org.codehaus.cargo.container.spi.AbstractEmbeddedLocalContainer.startInternal(AbstractEmbeddedLocalContainer.java:78)
    at org.codehaus.cargo.container.spi.AbstractLocalContainer.start(AbstractLocalContainer.java:228)
    at org.codehaus.cargo.maven3.ContainerStartMojo.executeLocalContainerAction(ContainerStartMojo.java:83)
    at org.codehaus.cargo.maven3.ContainerRunMojo.doExecute(ContainerRunMojo.java:95)
    at org.codehaus.cargo.maven3.AbstractCargoMojo.execute(AbstractCargoMojo.java:439)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: java.lang.ClassNotFoundException: javax.security.auth.message.config.RegistrationListener
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 72 more

server startup log show got classNotFoundException for RegistrationListener

tomcat 7 not problem

Migrating version tomcat 7 to tomcat 9 , java 8 to java 11

Anyone know what wrong with my configuration ?

Buenabuenaventura answered 10/2, 2022 at 9:33 Comment(3)
Try to introduce tomcat-jaspic-api.Consonantal
Seems to be a problem with recent couple of versions. What if you try <version>1.9.8</version> ?Liking
@Tzyy Khong Hiew - Did you ever solve this? If so, can you post the solution?Adiana
C
0

Using embedded server comes with "health warnings" (https://codehaus-cargo.github.io/cargo/Embedded+Container.html) so when I migrated from tomcat7-maven-plugin to cargo-maven3-plugin I gave up on it and let it run standalone.

My configuration that works is below (it copies the db driver and context.xml in before tomcat starts with the <files> and <configfiles> tags):

                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven3-plugin</artifactId>
                    <version>1.9.9</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.tomcat</groupId>
                            <artifactId>tomcat-catalina</artifactId>
                            <version>9.0.74</version>
                        </dependency>
                        <dependency>
                            <groupId>javax.security.auth.message</groupId>
                            <artifactId>javax.security.auth.message-api</artifactId>
                            <version>1.1</version>
                        </dependency>
                        <dependency>
                            <groupId>xalan</groupId>
                            <artifactId>xalan</artifactId>
                            <version>2.7.1</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <skip>${skipITs}</skip>
                        <configuration>
                            <files>
                                <file>
                                    <file>${project.build.directory}/${project.build.finalName}/WEB-INF/lib/postgresql-${postgres.version}.jar</file>
                                    <todir>/common/lib</todir>
                                    <tofile>postgresql-${postgres.version}.jar</tofile>
                                </file>
                            </files>
                            <configfiles>
                                <configfile>
                                    <file>src/test/resources/tomcat/context.xml</file>
                                    <todir>conf/Catalina/localhost/</todir>
                                    <tofile>context.xml.default</tofile>
                                </configfile>
                            </configfiles>
                            <properties>
                                <cargo.start.jvmargs>
                                    -Xdebug
                                    -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
                                    -Xnoagent
                                    -Dmy.property=value
                                </cargo.start.jvmargs>
                                <cargo.servlet.port>${server.http.port}</cargo.servlet.port>
                            </properties>
                        </configuration>
                        <container>
                            <systemProperties>
                            </systemProperties>
                            <containerId>tomcat9x</containerId>
                            <zipUrlInstaller>
                                <url>
                                    https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat/9.0.62/tomcat-9.0.62.zip
                                </url>
                            </zipUrlInstaller>
                        </container>
                    </configuration>
                    <executions>
                        <execution>
                            <id>start-tomcat</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start</goal>
                            </goals>
                            <configuration>
                                <skip>${skipITs}</skip>
                            </configuration>
                        </execution>
                        <execution>
                            <id>stop-tomcat</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                            <configuration>
                                <skip>${skipITs}</skip>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
Cheeseparing answered 31/5, 2023 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.