Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么JBehaveMaven插件会给我一个NoClassDefFoundError?_Maven_Jbehave_Jbehave Maven Plugin - Fatal编程技术网

为什么JBehaveMaven插件会给我一个NoClassDefFoundError?

为什么JBehaveMaven插件会给我一个NoClassDefFoundError?,maven,jbehave,jbehave-maven-plugin,Maven,Jbehave,Jbehave Maven Plugin,当我运行mvn集成测试-e com.example.mymodule时,出现以下错误: [ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.5:run-stories-as-embeddables (embeddable-stories) on project com.example.mymodule: Failed to run stories as embeddables: Failure in runnin

当我运行
mvn集成测试-e com.example.mymodule
时,出现以下错误:

[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.5:run-stories-as-embeddables (embeddable-stories) on project com.example.mymodule: Failed to run stories as embeddables: Failure in running embeddable: com.example.mymodule.TheStories: Could not initialize class freemarker.ext.beans.BeansWrapper -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.5:run-stories-as-embeddables (embeddable-stories) on project com.example.mymodule: Failed to run stories as embeddables
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to run stories as embeddables
    at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:20)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.jbehave.core.embedder.Embedder$RunningEmbeddablesFailed: Failure in running embeddable: com.example.mymodule.TheStories
    at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:130)
    at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:18)
    ... 21 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class freemarker.ext.beans.BeansWrapper
    at freemarker.template.ObjectWrapper.<clinit>(ObjectWrapper.java:69)
    at freemarker.core.Configurable.<init>(Configurable.java:139)
    at freemarker.template.Configuration.<init>(Configuration.java:142)
    at freemarker.template.Configuration.<clinit>(Configuration.java:127)
    at org.jbehave.core.reporters.FreemarkerProcessor.configuration(FreemarkerProcessor.java:30)
    at org.jbehave.core.reporters.FreemarkerProcessor.process(FreemarkerProcessor.java:21)
    at org.jbehave.core.reporters.TemplateableViewGenerator.write(TemplateableViewGenerator.java:267)
    at org.jbehave.core.reporters.TemplateableViewGenerator.createReports(TemplateableViewGenerator.java:219)
    at org.jbehave.core.reporters.TemplateableViewGenerator.generateReportsView(TemplateableViewGenerator.java:110)
    at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:249)
    at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:237)
    at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:213)
    at org.jbehave.core.junit.JUnitStories.run(JUnitStories.java:20)
    at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:121)
    ... 22 more
我使用
javap
确认类
freemarker.ext.beans.BeansWrapper
存在于这个jar中:

javap -classpath C:\Users\CONOR2\.m2\repository\org\freemarker\freemarker\2.3.19\freemarker-2.3.19.jar freemarker.ext.beans.BeansWrapper
以下是my pom.xml中我的部门的相关部分:

<dependency>
    <groupId>org.jbehave</groupId>
    <artifactId>jbehave-core</artifactId>
    <version>3.9.5</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jbehave</groupId>
    <artifactId>jbehave-core</artifactId>
    <version>3.9.5</version>
    <classifier>resources</classifier>
    <type>zip</type>
</dependency>
<dependency>
    <groupId>org.jbehave.site</groupId>
    <artifactId>jbehave-site-resources</artifactId>
    <version>3.2</version>
    <type>zip</type>
</dependency>

org.jbehave
jbehave核
3.9.5
测试
org.jbehave
jbehave核
3.9.5
资源
拉链
org.jbehave.site
jbehave站点资源
3.2
拉链
以下是我的插件部分:

<plugin>
    <groupId>org.jbehave</groupId>
    <artifactId>jbehave-maven-plugin</artifactId>
    <version>3.9.5</version>
    <executions>
        <execution>
            <id>unpack-view-resources</id>
            <phase>process-resources</phase>
            <goals>
                <goal>unpack-view-resources</goal>
            </goals>
        </execution>
        <execution>
            <id>embeddable-stories</id>
            <phase>integration-test</phase>
            <configuration>
                <includes>
                    <include>com/example/mymodule/TheStories.java</include>
                </includes>
                <excludes />
                <ignoreFailureInStories>true</ignoreFailureInStories>
                <ignoreFailureInView>false</ignoreFailureInView>
                <scope>test</scope>
                <threads>1</threads>
                <metaFilters>
                    <metaFilter></metaFilter>
                </metaFilters>
            </configuration>
            <goals>
                <goal>run-stories-as-embeddables</goal>
            </goals>
        </execution>
    </executions>
</plugin>

org.jbehave
JBehaveMaven插件
3.9.5
解压缩视图资源
过程资源
解压缩视图资源
可嵌入的故事
集成测试
com/example/mymodule/TheStories.java
真的
假的
测试
1.
把故事当作儿戏讲

我在版本3.9.5和4.0.3中尝试了这一点,但在两个版本中都出现了相同的错误。

结果是jbehave maven插件在log4j中遇到了问题。添加log4j:log4j和org.slf4j:slf4j-log4j作为插件的依赖项解决了这个问题。

结果是jbehave-maven插件在log4j上遇到了问题。添加log4j:log4j和org.slf4j:slf4j-log4j作为插件的依赖项修复了这个问题

<plugin>
    <groupId>org.jbehave</groupId>
    <artifactId>jbehave-maven-plugin</artifactId>
    <version>3.9.5</version>
    <executions>
        <execution>
            <id>unpack-view-resources</id>
            <phase>process-resources</phase>
            <goals>
                <goal>unpack-view-resources</goal>
            </goals>
        </execution>
        <execution>
            <id>embeddable-stories</id>
            <phase>integration-test</phase>
            <configuration>
                <includes>
                    <include>com/example/mymodule/TheStories.java</include>
                </includes>
                <excludes />
                <ignoreFailureInStories>true</ignoreFailureInStories>
                <ignoreFailureInView>false</ignoreFailureInView>
                <scope>test</scope>
                <threads>1</threads>
                <metaFilters>
                    <metaFilter></metaFilter>
                </metaFilters>
            </configuration>
            <goals>
                <goal>run-stories-as-embeddables</goal>
            </goals>
        </execution>
    </executions>
</plugin>