Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UndeclaredThrowableException #280

Closed
dkowis opened this issue Mar 29, 2012 · 8 comments
Closed

UndeclaredThrowableException #280

dkowis opened this issue Mar 29, 2012 · 8 comments

Comments

@dkowis
Copy link
Member

dkowis commented Mar 29, 2012

I just encountered this when updating our project to cucumber-jvm 1.0.0. I have tried running against latest HEAD as well (1.0.1-SNAPSHOT I think I built my snapshot artifacts right before the 1.0.1 release was cut).

our cucumber run includes some negated tags to prevent including any features that are tagged with "@slow" or something.

We also, have multiple glue paths specified, because there are some java steps and a lot more ruby stepdefinitions.

main:
     [echo] Running Cucumber Ruby Features
     [java] Feature: Configuration Item (CI) Validation
     [java]   
     [java]   As a
     [java]   I need
     [java] Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
     [java]     at $Proxy67.result(Unknown Source)
     [java]     at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:163)
     [java]     at cucumber.runtime.Runtime.runHooks(Runtime.java:148)
     [java]     at cucumber.runtime.Runtime.runBeforeHooks(Runtime.java:139)
     [java]     at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:32)
     [java]     at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:112)
     [java]     at cucumber.runtime.Runtime.run(Runtime.java:94)
     [java]     at cucumber.runtime.Runtime.run(Runtime.java:82)
     [java]     at cucumber.cli.Main.run(Main.java:20)
     [java]     at cucumber.cli.Main.main(Main.java:12)
     [java] Caused by: java.lang.reflect.InvocationTargetException
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at cucumber.runtime.RuntimeOptions$2.invoke(RuntimeOptions.java:103)
     [java]     ... 10 more
     [java] Caused by: java.lang.NullPointerException
     [java]     at gherkin.formatter.PrettyFormatter.result(PrettyFormatter.java:198)
     [java]     ... 15 more

Relevant part of the pom.xml that actually exectutes the cucmber CLI:

<target>
    <echo message="Running Cucumber Ruby Features" />
    <java fork="true" classname="cucumber.cli.Main" classpathref="maven.test.classpath" failonerror="true" maxmemory="512m">
        <!-- set up system properties things for the cucumber-spring backend -->
        <sysproperty key="log4j.configuration" value="file:///${project.basedir}/target/test-classes/log4j.properties" />
        <sysproperty key="incident.properties.location" value="${project.basedir}/target/properties/${incident.environment}/incident-service.properties" />

        <arg value="-f" />
        <arg value="pretty" />
        <!-- add a second pretty outputter to a file -->
        <arg value="-f" />
        <arg value="pretty:target/pretty-ruby.log" />
        <!-- add an html barfer to put an html report out -->
        <arg value="-f" />
        <arg value="html:target" />
        <!-- add a JSON barfer to get out lots o JSON -->
        <arg value="-f" />
        <arg value="json-pretty:target/incident-service.json" />
        <!-- specify a tag or two -->
        <arg value="-t" />
        <arg value="${cucumber.smix.tags}" />
        <arg value="-t" />
        <arg value="${cucumber.tags}" />
        <arg value="-t" />
        <arg value="${cucumber.zendesk.tags}" />
        <!-- glue path for ruby stuff -->
        <arg value="--glue" />
        <arg value="src/test/features/" />
        <!-- glue path for spring annotated step defs -->
        <arg value="--glue" />
        <arg value="step_definitions" />
        <!-- Feature file path to find features in -->
        <arg value="src/test/features" />
    </java>
</target>

I think the issue has to do with tags, or maybe the multitude of formatters we're using, but I'm not sure. I can try building a smaller sample project to bring out the problem, because I couldn't get it duplicated by just adding a Background to a cucumber-jruby project and negate some tags.

@dkowis
Copy link
Member Author

dkowis commented Mar 29, 2012

When running my project against the tags in the cucumber-jvm repo, the last working one was RC16. First one that will evidence the same error is RC23. Perhaps I can set up some kind of git bisect fun stuff to figure out where this happened, heh. Quite a bit has changed between the two, however....

@dkowis
Copy link
Member Author

dkowis commented Mar 29, 2012

Found this issue on gherkin: cucumber/gherkin#171

I thought it might be related, because I get a different error when I don't use the pretty formatter:
FF--- But that leads me to believe that something is still exploding. I don't know what it is yet.

I haven't been able to duplicate whatever is exploding in a sample project yet. It must be something obscure :(

@dkowis
Copy link
Member Author

dkowis commented Mar 29, 2012

So I can run the scenario in JUnit and it executes just fine. Something must be broken in the CLI process flow. Even if I use the pretty formatter.

This seems to properly execute the scenario from JUnit:

@Cucumber.Options(features = "com/rackspace/incident/features/CIValidation.feature", format = "pretty")

@dkowis
Copy link
Member Author

dkowis commented Mar 29, 2012

So with lots of printlns, I found an issue:

     [java] I caught a throwable! No unique bean of type [step_definitions.ServiceMixContractSteps] is defined: expected single bean but found 2: serviceMixContractSteps,step_definitions.ServiceMixContractSteps

Turns out some how we have multiple beans being detected. Perhaps the glue path is being handled differently now or something. I'll debug it more and figure out if it's a problem in our project, or a problem with how cucumber-jvm loads it's stuff. It might be related to us because we're using two backends at the same time (spring and jruby.)

@dkowis
Copy link
Member Author

dkowis commented Mar 29, 2012

I think the problem here is that an exception is being swallowed in a before hook, and so the formatter isn't available for it to mark a step as failed or whatever.

The exception is valid, the spring startup stuff failed to start up and horked an exception, which was caught, but couldn't be written because it's not associated with any step.

So I say the root cause of this issue is issue #133

Exceptions at a certain state of the process. being swallowed and aren't making it out to the console, thus making the root cause much more difficult to determine.

@dkowis
Copy link
Member Author

dkowis commented Mar 29, 2012

cucumber/gherkin#172 Here's the gherkin bug that's relevant to this problem.

@aslakhellesoy
Copy link
Contributor

Since cucumber/gherkin#172 and #133 are fixed I believe this is no longer an issue in Cucumber-JVM.

Please ask for this to be reopened if it's still broken.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants