Hi Azeez,
I was not able to get it reproduced in the fatjar so far. It comes
intermittently in my tests as well.
After all 3 of my exception mappers are registered, the map will have the
following :
[org.wso2.msf4j.internal.MicroservicesRegistry] : EXCEPTION MAPPERS :
{class
java.lang.Throwable=org.wso2.carbon.andes.service.internal.exception.mappers.MessageNotFoundMapper@32018c32
}
Throwable being the key and MessageNotFoundMapper being the value.
The exception that is being thrown by my test case by purpose
is org.wso2.carbon.andes.service.exceptions.InternalServerException.
Since the key is Throwable, the MessageNotFoundMapper is returned by
entry.getKey().isAssignableFrom(throwable.getClass()))[1]
[1] -
https://github.com/wso2/msf4j/blob/master/core/src/main/java/org/wso2/msf4j/internal/MicroservicesRegistry.java#L100
Regards,
Hemika
Hemika Kodikara
Software Engineer
WSO2 Inc.
lean . enterprise . middleware
http://wso2.com
Mobile : +94777688882
On Mon, Jun 20, 2016 at 7:55 PM, Afkham Azeez <[email protected]> wrote:
> Can this be reproduced in the standalone (fatjar) mode as well?
>
> On Mon, Jun 20, 2016 at 7:53 PM, Afkham Azeez <[email protected]> wrote:
>
>> So what has happened in the wrong exception mapper for an exception has
>> got registered?
>>
>> On Mon, Jun 20, 2016 at 7:03 PM, Hemika Kodikara <[email protected]> wrote:
>>
>>> Hi All,
>>>
>>> I am currently writing unit test cases where exception mappers are being
>>> used in my service. Intermittently I get the following error when running
>>> my tests :
>>>
>>> ==============
>>> java.lang.ClassCastException:
>>> org.wso2.carbon.andes.service.exceptions.InternalServerException cannot be
>>> cast to org.wso2.carbon.andes.service.exceptions.MessageNotFoundException
>>> at
>>> org.wso2.carbon.andes.service.internal.exception.mappers.MessageNotFoundMapper.toResponse(MessageNotFoundMapper.java:30)
>>> at
>>> org.wso2.msf4j.internal.MSF4JMessageProcessor.handleThrowable(MSF4JMessageProcessor.java:138)
>>> at
>>> org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:81)
>>> at
>>> org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler$1.run(WorkerPoolDispatchingSourceHandler.java:125)
>>> at
>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>>> at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>>> at java.lang.Thread.run(Thread.java:745)
>>> ==============
>>>
>>> In the above exception, "MessageNotFoundException" maps to
>>> "MessageNotFoundMapper" and "InternalServerException" maps to
>>> "InternalServerErrorMapper".
>>>
>>> The 2 exception classes have nothing in common and the 2 mapper classes
>>> also have nothing in common.
>>>
>>> I debugged further to find the issue with the attached
>>> patch(ex-map-msf4j.diff) for logging(not sure whether I have the latest
>>> code).
>>>
>>> Following is the output when the error occurs :
>>>
>>> [org.wso2.msf4j.internal.MicroservicesRegistry] : CLASS : public
>>> javax.ws.rs.core.Response
>>> org.wso2.carbon.andes.service.internal.exception.mappers.DestinationNotFoundMapper.toResponse(
>>> *java.lang.Throwable*)
>>> ....
>>> [org.wso2.msf4j.internal.MicroservicesRegistry] : CLASS : public
>>> javax.ws.rs.core.Response
>>> org.wso2.carbon.andes.service.internal.exception.mappers.InternalServerErrorMapper.toResponse(
>>> *java.lang.Throwable*)
>>> ....
>>> [org.wso2.msf4j.internal.MicroservicesRegistry] : CLASS : public
>>> javax.ws.rs.core.Response
>>> org.wso2.carbon.andes.service.internal.exception.mappers.MessageNotFoundMapper.toResponse(
>>> *java.lang.Throwable*)
>>>
>>> The issue here is that the paramtype is as "java.lang.Throwable". The
>>> correct value should be as follows since there is a comparator for the
>>> exceptionMapper map :
>>>
>>> [org.wso2.msf4j.internal.MicroservicesRegistry] : CLASS : public
>>> javax.ws.rs.core.Response
>>> org.wso2.carbon.andes.service.internal.exception.mappers.DestinationNotFoundMapper.toResponse(
>>> *org.wso2.carbon.andes.service.exceptions.DestinationNotFoundException*)
>>> .....
>>> [org.wso2.msf4j.internal.MicroservicesRegistry] : CLASS : public
>>> javax.ws.rs.core.Response
>>> org.wso2.carbon.andes.service.internal.exception.mappers.InternalServerErrorMapper.toResponse(
>>> *org.wso2.carbon.andes.service.exceptions.InternalServerException*)
>>> .....
>>> [org.wso2.msf4j.internal.MicroservicesRegistry] : CLASS : public
>>> javax.ws.rs.core.Response
>>> org.wso2.carbon.andes.service.internal.exception.mappers.MessageNotFoundMapper.toResponse(
>>> *org.wso2.carbon.andes.service.exceptions.MessageNotFoundException*)
>>>
>>>
>>> According to what I was able to find out, this is an JDK error[1][2](Bug:
>>> 8029459 <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8029459>)
>>> for the method "em.getClass().getMethods()"[3].
>>>
>>> Any advice on how to proceed or that needs to be checked from my side ?
>>>
>>> [1] -
>>> http://www.oracle.com/technetwork/java/javase/8-known-issues-2157115.html
>>> [2] - http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8029459
>>> [3] -
>>> https://github.com/wso2/msf4j/blob/master/core/src/main/java/org/wso2/msf4j/internal/MicroservicesRegistry.java#L84
>>>
>>> Regards,
>>> Hemika
>>>
>>> Hemika Kodikara
>>> Software Engineer
>>> WSO2 Inc.
>>> lean . enterprise . middleware
>>> http://wso2.com
>>>
>>> Mobile : +94777688882
>>>
>>
>>
>>
>> --
>> *Afkham Azeez*
>> Director of Architecture; WSO2, Inc.; http://wso2.com
>> Member; Apache Software Foundation; http://www.apache.org/
>> * <http://www.apache.org/>*
>> *email: **[email protected]* <[email protected]>
>> * cell: +94 77 3320919 <%2B94%2077%203320919>blog: *
>> *http://blog.afkham.org* <http://blog.afkham.org>
>> *twitter: **http://twitter.com/afkham_azeez*
>> <http://twitter.com/afkham_azeez>
>> *linked-in: **http://lk.linkedin.com/in/afkhamazeez
>> <http://lk.linkedin.com/in/afkhamazeez>*
>>
>> *Lean . Enterprise . Middleware*
>>
>
>
>
> --
> *Afkham Azeez*
> Director of Architecture; WSO2, Inc.; http://wso2.com
> Member; Apache Software Foundation; http://www.apache.org/
> * <http://www.apache.org/>*
> *email: **[email protected]* <[email protected]>
> * cell: +94 77 3320919 <%2B94%2077%203320919>blog: *
> *http://blog.afkham.org* <http://blog.afkham.org>
> *twitter: **http://twitter.com/afkham_azeez*
> <http://twitter.com/afkham_azeez>
> *linked-in: **http://lk.linkedin.com/in/afkhamazeez
> <http://lk.linkedin.com/in/afkhamazeez>*
>
> *Lean . Enterprise . Middleware*
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev