Apache Tomcat Maven Plugin
  1. Apache Tomcat Maven Plugin
  2. MTOMCAT-81

mvn tomcat:run does not work with spring tomcat classloader

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Not a Problem
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu 10.10

      Description

      I have been trying for weeks to get the mvn tomcat:run work for my Spring based project. I use the spring-tomcat-weaver.jar for doing the class loading in Tomcat. When I run my project using mvn tomcat:run command it gives me a class not found. Below is a stack trace of what I get:

      SEVERE: LifecycleException
      java.lang.ClassNotFoundException: org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader
      at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
      at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
      at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      at org.apache.catalina.loader.WebappLoader.createClassLoader(WebappLoader.java:801)
      at org.apache.catalina.loader.WebappLoader.start(WebappLoader.java:661)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4504)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
      at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
      at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
      at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

        Activity

        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        need a sample project to test it.

        Show
        Olivier Lamy (*$^¨%`£) added a comment - need a sample project to test it.
        Hide
        DZ added a comment -

        To reproduce this, add following lines in file META-INF/context.xml
        <?xml version="1.0" encoding="UTF-8"?>
        <Context path="/AnyWebApp">
        <Loader
        loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
        useSystemClassLoaderAsParent="false" />
        </Context>

        This is a typical config for spring + tomcat + maven.

        Show
        DZ added a comment - To reproduce this, add following lines in file META-INF/context.xml <?xml version="1.0" encoding="UTF-8"?> <Context path="/AnyWebApp"> <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false" /> </Context> This is a typical config for spring + tomcat + maven.
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        how is declared your dependency on spring-tomcat-weaver or spring-instrument-tomcat ?

        Show
        Olivier Lamy (*$^¨%`£) added a comment - how is declared your dependency on spring-tomcat-weaver or spring-instrument-tomcat ?
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        use useSeparateTomcatClassloader=true

        Show
        Olivier Lamy (*$^¨%`£) added a comment - use useSeparateTomcatClassloader=true

          People

          • Assignee:
            Unassigned
            Reporter:
            Jothi Shankar Kumar
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development