pombreda / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 1 forks source link

java.lang.ClassCastException: sun.proxy.$Proxy9 cannot be cast to se.example.EnvRequirement #783

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Description of the issue:

I am not sure if it is a Guice issue but since I, for some reason, could not 
post
in google-guice group ( maybe because I attached a zip file).

Maybe someone could help med shed some light on this issue?

br,

//mike

Steps to reproduce:
1. Run the NewTest ( testng testcase).
2.
3.

java.lang.ClassCastException: sun.proxy.$Proxy9 cannot be cast to 
se.example.EnvRequirement
    at se.example.MyHandler.handleEnvironment(MyHandler.java:32)
    at se.example.MyHandler.check(MyHandler.java:21)
    at se.example.MyListener.beforeInvocation(MyListener.java:34)
    at org.testng.internal.invokers.InvokedMethodListenerInvoker$InvokeBeforeInvocationWithoutContextStrategy.callMethod(InvokedMethodListenerInvoker.java:84)
    at org.testng.internal.invokers.InvokedMethodListenerInvoker.invokeListener(InvokedMethodListenerInvoker.java:62)
    at org.testng.internal.Invoker.runInvokedMethodListeners(Invoker.java:619)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:540)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Original issue reported on code.google.com by mikaelpe...@gmail.com on 28 Nov 2013 at 10:54

Attachments:

GoogleCodeExporter commented 9 years ago
In MyHandler.java you're casting TrxRequirement to EnvRequirement, but 
TrxRequirement does not extend EnvRequirement - it is only annotated by it, so 
I don't see how this cast could ever succeed. The method being called 
(replaceId) then casts it back into TrxRequirement, so this temporary cast to 
EnvRequirement appears to have no use.

Original comment by mccu...@gmail.com on 28 Nov 2013 at 12:25