JBehave
  1. JBehave
  2. JBEHAVE-337

Document how to configure jbehave-maven-plugin to be aware of log4j dependency

    Details

    • Type: Task Task
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.1
    • Component/s: Maven Plugin
    • Labels:
      None
    • Environment:
      Ubuntu 10.4, sun java 1.6.0_20-b02, maven 2.2.1
    • Number of attachments :
      1

      Description

      If my pom.xml contains a dependency on log4j then when I run the target mvn integration-test I get a stack trace indicating that the jbehave-maven-plugin can't find the log4j classes. I've attached a trivial maven project that reproduces the issue. I do not see this issue when I run the tests in eclipse as junit tests and the tests run fine if I remove log4j.

      The following is the complete stack trace:

      java.lang.NoClassDefFoundError: org/apache/log4j/Priority
      at freemarker.log.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:65)
      at freemarker.log.Logger.getLogger(Logger.java:255)
      at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
      at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
      at freemarker.template.ObjectWrapper.<clinit>(ObjectWrapper.java:69)
      at freemarker.core.Configurable.<init>(Configurable.java:132)
      at freemarker.template.Configuration.<init>(Configuration.java:109)
      at freemarker.template.Configuration.<clinit>(Configuration.java:96)
      at org.jbehave.core.reporters.FreemarkerViewGenerator.configure(FreemarkerViewGenerator.java:208)
      at org.jbehave.core.reporters.FreemarkerViewGenerator.<init>(FreemarkerViewGenerator.java:60)
      at org.jbehave.core.configuration.Configuration.<init>(Configuration.java:159)
      at org.jbehave.core.configuration.MostUsefulConfiguration.<init>(MostUsefulConfiguration.java:49)
      at org.jbehave.core.embedder.Embedder.<init>(Embedder.java:30)
      at org.jbehave.core.embedder.Embedder.<init>(Embedder.java:37)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at java.lang.Class.newInstance0(Class.java:355)
      at java.lang.Class.newInstance(Class.java:308)
      at org.jbehave.core.embedder.EmbedderClassLoader.newInstance(EmbedderClassLoader.java:37)
      at org.jbehave.mojo.AbstractEmbedderMojo.newEmbedder(AbstractEmbedderMojo.java:228)
      at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:15)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
      at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
      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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
      at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
      at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
      at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      ... 42 more

        Activity

        Hide
        Mauro Talevi added a comment -

        Add dependency to plugin rather than the project (see example below) and it will be picked up. This is a Maven classloading issue that is independent of the JBehave plugin. We'll update the documentation to reflect this common use case.

        <plugin>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-maven-plugin</artifactId>
        <dependencies>
        <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        </dependency>
        </dependencies>
        </plugin>

        Show
        Mauro Talevi added a comment - Add dependency to plugin rather than the project (see example below) and it will be picked up. This is a Maven classloading issue that is independent of the JBehave plugin. We'll update the documentation to reflect this common use case. <plugin> <groupId>org.jbehave</groupId> <artifactId>jbehave-maven-plugin</artifactId> <dependencies> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> </dependencies> </plugin>
        Mauro Talevi made changes -
        Field Original Value New Value
        Summary jbehave-maven-plugin thows NoClassDefFoundError org/apache/log4j/Priority when maven project includes log4j dependency Document how to configure jbehave-maven-plugin to be aware of log4j dependency
        Issue Type Bug [ 1 ] Task [ 3 ]
        Fix Version/s 3.1 [ 16511 ]
        Hide
        Mauro Talevi added a comment -

        Updated maven-goals.html page.

        Show
        Mauro Talevi added a comment - Updated maven-goals.html page.
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Damien LG added a comment -

        Exactly the issue I was facing, just had to RTFM ^^

        Show
        Damien LG added a comment - Exactly the issue I was facing, just had to RTFM ^^

          People

          • Assignee:
            Unassigned
            Reporter:
            Jonathan Choate
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: