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.
On 28 November 2013 09:03, mikael petterson <[email protected]>wrote: > Hi, > > I am using Guice but I get a class cast exception that I cannot figure out > what it depends on > > > 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) > > > Could be a regular java problem but I am not sure. > > I attached all files as a runnable project ( HappyTesting) that can be > imported into Eclipse. > > br, > > //mike > > //mike > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/google-guice. > For more options, visit https://groups.google.com/groups/opt_out. > -- Cheers, Stuart -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. For more options, visit https://groups.google.com/groups/opt_out.
