cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: JaxRS - Issue with Restful app aspect
Date Mon, 30 Jan 2012 15:04:54 GMT
Hi

On 30/01/12 14:24, Kiren Pillay wrote:
> Hi All,
>
> I have a transaction aspect which returns an object called Response. The
> Aspect works fine,  ie, when debugging it, the value at the return point is
> exactly as expected and no exceptions are thrown. However, once this is
> completed, I am getting a classCast exception with an error trace shown
> below:
>
> za.co.vodacom.pams.messaging.response.Response cannot be cast to
> za.co.vodacom.pams.rechargerecords.RechargeRecords
> $Proxy69.query(Unknown Source)
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> java.lang.reflect.Method.invoke(Method.java:597)
> org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
>
> At no point in my application code am I doing this cast. RechargeRecords is
> a subclass of Payload, its a Jaxb generated object.
>
> My problem is that I have no line numbers which tells me exactly where this
> cast occurs. It doesn't look like its in my application code but rather
> within the cxf AbstractInvoker's proxy. Any ideas to help me resolve this
> problem (more specifically, finding where the it actually happens) ?

What does the actual resource method return ?
is it Response or some Payload instance ?

It appears that the resource method is typed to return Payload while
the aspect returns Response so it confuses the runtime a bit...

Cheers, Sergey




>
> Regards
> Kiren
> CXF 2.5.1
>
>
> @Around("execution(@za.co.pams.bs.PAMSTransaction * *(..))")
> public Object recordStats(ProceedingJoinPoint point) throws Throwable {
>
> Response response = null;
>
> if (resultObject instanceof Response) {
> response = (Response) resultObject;
> }
> else
> if (Payload.class.isAssignableFrom(resultObject.getClass())) {
>
> response = of.createResponse();
>
> Payload payload = (Payload) resultObject;
> response.setPayload(payload);
> }
>
> try {
> populateSystemInfo(took, response);
> response.setMethodSignature(point.getSignature().toString());
>
> response.getRequestParams().addAll(list);
>
> auditWorker.createSuccessfulAuditRecord(response);
> }catch (Throwable e) {
>           response.setDuration(0);  // Test code just to prove no exceptions
> where thrown here
> }
>
> return response;
> }
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message