Hi Brian,
the JBehave mojos use the @requiresDependencyResolution <scope> to
resolve dependencies, where the default scope is "runtime", which does
not include "provided" dependencies.
In general, this tends to work as JBehave stories are run either at
compile scope - in their own Maven project - or in test scope.
May I ask you why you feel the need to declare your dependency as
provided in a testing module?
I've tried out your project and it works fine if you declare your
dependencies at "compile" scope. I'm using latest Maven release 3.0.4
and latest JDK 1.6.
Else, explicitly declaring the dependency in the plugin <dependencies>
also works.
Cheers, M
On 02/07/2012 22:53, Brian wrote:
Hi,
I've created a dumb project on github using a jbehave artifact:
https://github.com/bclozel/jbehave-scope-provided
Maven documentation
<http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope>
says scope=provided dependencies are within compile + test classpaths.
JBehave embedder is using both depending on configuration.
mvn --version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
With this configuration, my embedder classpath does not contain the
javax.servlet JAR. When the dependency scope is changed to "compile",
then this JAR is listed in classpath elements.
Any pointer here would be really helpful.
Thanks,
-- Brian
On Mon, Jul 2, 2012 at 4:58 PM, Mauro Talevi
<[email protected] <mailto:[email protected]>> wrote:
Hi Brian,
can you provide us with a sample project (with pom.xml and the
simplest source possible) reproducing this issue?
Thanks
On 02/07/2012 15:51, Brian wrote:
Hello there
I've been trying to use jbehave on a project and I ran into some
problems.
When running the maven goal, I got the following error:
[ERROR] Failed to execute goal
org.jbehave:jbehave-maven-plugin:3.6.7:run-stories-as-embeddables
(default-cli) on project springmvc-router: Execution
default-cli of goal
org.jbehave:jbehave-maven-plugin:3.6.7:run-stories-as-embeddables
failed: A required class was missing while executing
org.jbehave:jbehave-maven-plugin:3.6.7:run-stories-as-embeddables:
javax/servlet/http/HttpServletRequest
It looks like jbehave's Embedder classloader can't locate
the HttpServletRequest. This dependency is declared in my main
POM like this:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
If I ever change the scope to "compile", I get another error saying:
Caused by: java.lang.InstantiationException:
org.myproject.OneOfMyProjectClasses
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at
org.jbehave.core.embedder.EmbedderClassLoader.newInstance(EmbedderClassLoader.java:37)
... 24 more
Is there a typo/bug in my configuration?
I've browsed jbehave-maven-plugin (AbstractEmbedderMojo to be
precise) but couldn't anything on dependencies in provided scope.
Should I open an issue about that?
This is the maven config I've added to my POM:
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>${jbehave.version}</version>
<executions>
<execution>
<id>run-stories-as-embeddables</id>
<phase>integration-test</phase>
<configuration>
<scope>test</scope>
<includes>
<include>**/MyStories.java</include>
</includes>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
</plugin>
Thanks
-- Brian