You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by vanyatka <ib...@gmail.com> on 2010/05/30 00:59:36 UTC

ClassCastException prevents thorough endpoint testing

Hey,

Just ran into the problem of testing endpoint when the endpoint method
should throw business exception. In the Integration Test I have to catch &
verify this exception. To my frustration, the call on the endpoint does not
throw desired exception, but rather 

java.lang.ClassCastException: java.lang.Class cannot be cast to
javax.ws.rs.core.Response

The endpoint configuration (client test side) is done via Spring, as
follows:

    <jaxrs:client id="helloWorldEndpoint" 
        address="${jetty.url}"
        serviceClass="endpoint.HelloWorldEndpointImpl">
    </jaxrs:client>


In the business scenario when endpoint finishes normally, the test works
fine, endpoint returns Response object.

Tried to register ResponseExceptionMapper, but no avail, ClassCastException
issue persists.

Any suggestions on what could be the matter and how to make IT tests handle
exceptions in endpoints are very welcome :thinking:

-Ivan
-- 
View this message in context: http://old.nabble.com/ClassCastException-prevents-thorough-endpoint-testing-tp28719118p28719118.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: ClassCastException prevents thorough endpoint testing

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

sorry, unfortunately I didn't manage to look at this issue in time for it be
fixed in 2.2.9...
Given that I've just started a new job. Thus I'd appreciate you opening a
JIRA and attaching
some sample code/config exactly reflecting the way (including classes,
interfaces) it is done in the real case.
It will make it easier for myself or others to investigate. Alternatively,
If you could debug and see what is really happening then it would help too

cheers, Sergey

On Mon, May 31, 2010 at 7:34 PM, vanyatka <ib...@gmail.com> wrote:

>
> Hi, Sergey
>
> I spotted couple of configuration issues in spring context, most notably I
> wrongly used the implementation class instead of interface declaration in
> jaxrs:client section. Now changed to interface.
>
> About moving @Path and @GET (in fact @POST is being used), they were
> already
> in the interface declaration.
>
> Also, I tried to remove @Transactional from endpoint. The final result I
> got
> so far is a different stack trace (no mention of CGLIB). Here it is:
>
> java.lang.ClassCastException: java.lang.Class cannot be cast to
> javax.ws.rs.core.Response
>         at $Proxy124.createHelloWorld(Unknown Source)
>        at
>
> endpoint.it.AdvKeywordSetEndpointIT.testCreateHelloWorld(HelloWorldEndpointIT.java:47)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at
>
> org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
>        at
>
> org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
>        at
>
> org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
>        at
>
> org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
>        at
>
> org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
>        at
>
> org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
>        at
>
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
>        at
>
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
>        at
>
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
>        at
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
>        at
> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>        at
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
>        at
>
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
>        at
>
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>        at
>
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>        at
>
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at
>
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
>        at
>
> org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:241)
>        at
>
> org.codehaus.mojo.failsafe.IntegrationTestMojo.execute(IntegrationTestMojo.java:555)
>        at
>
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>        at
>
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>        at
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>        at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>         at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
>
>
>
>
>
> Sergey Beryozkin-5 wrote:
> >
> > Hi
> >
> > It looks like the issue is caused either by the fact that CGLIB is being
> > used on the client side or by Spring adding a proxy wrapper
> > (@Transactional)
> > or by the combination of both factors.
> > I'd appreciate you helping me with narrowing down the cause and I'll then
> > fix it before 2.2.9 gets released as I'm short of time right now.
> > So please try first :
> > - create a HelloService interface and then move @Path and @GET
> annotations
> > to that interface - this should result in no CGLIB involved; try
> > with/without @Transactional
> >
> > thanks, Sergey
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/ClassCastException-prevents-thorough-endpoint-testing-tp28719118p28733956.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Re: ClassCastException prevents thorough endpoint testing

Posted by vanyatka <ib...@gmail.com>.
Hi, Sergey

I spotted couple of configuration issues in spring context, most notably I
wrongly used the implementation class instead of interface declaration in
jaxrs:client section. Now changed to interface.

About moving @Path and @GET (in fact @POST is being used), they were already
in the interface declaration. 

Also, I tried to remove @Transactional from endpoint. The final result I got
so far is a different stack trace (no mention of CGLIB). Here it is:

java.lang.ClassCastException: java.lang.Class cannot be cast to
javax.ws.rs.core.Response
	at $Proxy124.createHelloWorld(Unknown Source)
	at
endpoint.it.AdvKeywordSetEndpointIT.testCreateHelloWorld(HelloWorldEndpointIT.java:47)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
	at
org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
	at
org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
	at
org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
	at
org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
	at
org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
	at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
	at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
	at
org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:241)
	at
org.codehaus.mojo.failsafe.IntegrationTestMojo.execute(IntegrationTestMojo.java:555)
	at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
	at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)





Sergey Beryozkin-5 wrote:
> 
> Hi
> 
> It looks like the issue is caused either by the fact that CGLIB is being
> used on the client side or by Spring adding a proxy wrapper
> (@Transactional)
> or by the combination of both factors.
> I'd appreciate you helping me with narrowing down the cause and I'll then
> fix it before 2.2.9 gets released as I'm short of time right now.
> So please try first :
> - create a HelloService interface and then move @Path and @GET annotations
> to that interface - this should result in no CGLIB involved; try
> with/without @Transactional
> 
> thanks, Sergey
> 
> 

-- 
View this message in context: http://old.nabble.com/ClassCastException-prevents-thorough-endpoint-testing-tp28719118p28733956.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: ClassCastException prevents thorough endpoint testing

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

It looks like the issue is caused either by the fact that CGLIB is being
used on the client side or by Spring adding a proxy wrapper (@Transactional)
or by the combination of both factors.
I'd appreciate you helping me with narrowing down the cause and I'll then
fix it before 2.2.9 gets released as I'm short of time right now.
So please try first :
- create a HelloService interface and then move @Path and @GET annotations
to that interface - this should result in no CGLIB involved; try
with/without @Transactional

thanks, Sergey


On Mon, May 31, 2010 at 2:48 PM, vanyatka <ib...@gmail.com> wrote:

>
> Well, registering exception mapper didn't make the issue go away:
>
> @Provider
> public class DefaultExceptionMapper implements ExceptionMapper<Throwable> {
>        private final static Logger log =
> LoggerFactory.getLogger(DefaultExceptionMapper.class);
>        private final static String DEFAULT_ERROR_CODE = "999"; // TODO
>        public Response toResponse(Throwable t) {
>                return
>
> Response.status(Status.INTERNAL_SERVER_ERROR).entity(dto).type("application/xml").build();
>    }
>
>
> As well as upgrating cxf to version 2.2.7 :-)
>
>
> vanyatka wrote:
> >
> >
> > Also, let me mention that no jaxrs:providers are registered for
> > jaxrs:server
> >
> >
> > Sergey Beryozkin-5 wrote:
> >>
> >> What is the signature of the method in "endpoint.HelloWorldEndpointImpl"
> >> which is being tested ?
> >> How does the stack trace look like and what CXF version you're using ?
> >> cheers, Sergey
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/ClassCastException-prevents-thorough-endpoint-testing-tp28719118p28731178.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Re: ClassCastException prevents thorough endpoint testing

Posted by vanyatka <ib...@gmail.com>.
Well, registering exception mapper didn't make the issue go away:

@Provider
public class DefaultExceptionMapper implements ExceptionMapper<Throwable> {
	private final static Logger log =
LoggerFactory.getLogger(DefaultExceptionMapper.class);
 	private final static String DEFAULT_ERROR_CODE = "999"; // TODO
	public Response toResponse(Throwable t) {
		return
Response.status(Status.INTERNAL_SERVER_ERROR).entity(dto).type("application/xml").build();
    }


As well as upgrating cxf to version 2.2.7 :-)


vanyatka wrote:
> 
> 
> Also, let me mention that no jaxrs:providers are registered for
> jaxrs:server
> 
> 
> Sergey Beryozkin-5 wrote:
>> 
>> What is the signature of the method in "endpoint.HelloWorldEndpointImpl"
>> which is being tested ?
>> How does the stack trace look like and what CXF version you're using ?
>> cheers, Sergey
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/ClassCastException-prevents-thorough-endpoint-testing-tp28719118p28731178.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: ClassCastException prevents thorough endpoint testing

Posted by vanyatka <ib...@gmail.com>.
Hi, Sergey

Here is the method signature:

 @POST
 @Transactional
 @Path("/testPath")
 Response createHelloWorld(TestDto testDto);

Here is the implementation:

@Override 
public Response createHelloWorld(TestDto testDto) 
{ 
  if(true) { throw new RuntimeException("test createHelloWorld"); } 
  return Response.ok().build(); 
}

The stack looks as follows:

java.lang.ClassCastException: java.lang.Class cannot be cast to
javax.ws.rs.core.Response
	at
endpoint.HelloWorldEndpointImpl$$EnhancerByCGLIB$$47ebfd41.createHelloWorld(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy167.createHelloWorld(Unknown Source)
	at
endpoint.it.HelloWorldEndpointIT.testCreateHelloWorld(HelloWorldEndpointIT.java:44)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
	at
org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
	at
org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
	at
org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
	at
org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
	at
org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
	at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
	at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
	at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
	at
org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:241)
	at
org.codehaus.mojo.failsafe.IntegrationTestMojo.execute(IntegrationTestMojo.java:555)
	at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
	at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
	at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)


Here is the list of cxf dependencies used:

C:\U\i\cw\L-6\o\project> mvn dependency:tree | grep -i cxf
[INFO] |  |  \- org.apache.cxf:cxf-bundle:jar:2.2.5:compile
[INFO] |  +- org.apache.cxf:cxf-api:jar:2.2.5:compile
[INFO] |  |  \- org.apache.cxf:cxf-common-schemas:jar:2.2.5:compile
[INFO] |  +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.2.5:compile
[INFO] |  |  +- org.apache.cxf:cxf-rt-bindings-soap:jar:2.2.5:compile
[INFO] |  |  |  +- org.apache.cxf:cxf-tools-common:jar:2.2.5:compile
[INFO] |  |  |  \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.2.5:compile
[INFO] |  |  +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.2.5:compile
[INFO] |  |  +- org.apache.cxf:cxf-rt-ws-addr:jar:2.2.5:compile
[INFO] |  +- org.apache.cxf:cxf-rt-transports-http:jar:2.2.5:compile
[INFO] |  +- org.apache.cxf:cxf-rt-ws-security:jar:2.2.5:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:2.2.3:compile
[INFO] |  +- org.apache.cxf:cxf-common-utilities:jar:2.2.3:compile
[INFO] |  +- org.apache.cxf:cxf-rt-core:jar:2.2.3:compile
[INFO] |  +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.2.3:compile
[INFO] |  +- org.apache.cxf:cxf-rt-databinding-aegis:jar:2.2.3:compile


Also, let me mention that no jaxrs:providers are registered for jaxrs:server



Sergey Beryozkin-5 wrote:
> 
> What is the signature of the method in "endpoint.HelloWorldEndpointImpl"
> which is being tested ?
> How does the stack trace look like and what CXF version you're using ?
> cheers, Sergey
> 

-- 
View this message in context: http://old.nabble.com/ClassCastException-prevents-thorough-endpoint-testing-tp28719118p28730939.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: ClassCastException prevents thorough endpoint testing

Posted by Sergey Beryozkin <sb...@gmail.com>.
HI

On Sat, May 29, 2010 at 11:59 PM, vanyatka <ib...@gmail.com> wrote:

>
> Hey,
>
> Just ran into the problem of testing endpoint when the endpoint method
> should throw business exception. In the Integration Test I have to catch &
> verify this exception. To my frustration, the call on the endpoint does not
> throw desired exception, but rather
>
> java.lang.ClassCastException: java.lang.Class cannot be cast to
> javax.ws.rs.core.Response
>
> The endpoint configuration (client test side) is done via Spring, as
> follows:
>
>    <jaxrs:client id="helloWorldEndpoint"
>        address="${jetty.url}"
>        serviceClass="endpoint.HelloWorldEndpointImpl">
>    </jaxrs:client>
>
>
> In the business scenario when endpoint finishes normally, the test works
> fine, endpoint returns Response object.
>
> Tried to register ResponseExceptionMapper, but no avail, ClassCastException
> issue persists.
>
> Any suggestions on what could be the matter and how to make IT tests handle
> exceptions in endpoints are very welcome :thinking:
>
>
What is the signature of the method in "endpoint.HelloWorldEndpointImpl"
which is being tested ?
How does the stack trace look like and what CXF version you're using ?
cheers, Sergey





> -Ivan
> --
> View this message in context:
> http://old.nabble.com/ClassCastException-prevents-thorough-endpoint-testing-tp28719118p28719118.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>