Service Virtualization

 View Only
Expand all | Collapse all

JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

  • 1.  JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 13, 2016 12:21 PM

    Hi All,

    We are testing REST API which is talking to LISA MQ, we are seeing below error at client end (LISA Rest step) "JMSBytesMessage cannot be cast to javax.jms.TextMessage". We have got the msg.format=MQSTR in metadata response for each mq responses, this is still failing. As anyone seen this before please? let me know if we have some solution around getting this working. Apologies for pasting complete message was thinking if someone needs complete message to look out for error.

     

     

    HTTP Status 500 - Request failed.

    -------------------------------------------------------------------------------

    type Exception report

    message Request failed.

    description The server encountered an internal error that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: java.lang.ClassCastException: com.ibm.jms.JMSBytesMessage cannot be cast to javax.jms.TextMessage

      org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:485)

      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)

      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)

      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)

      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    root cause

    java.lang.ClassCastException: com.ibm.jms.JMSBytesMessage cannot be cast to javax.jms.TextMessage

      com.capitalone.webservice.utilities.JmsAdapter.sendMessage(JmsAdapter.java:98)

      com.capitalone.uk.coreapi.directdebit.dao.SetUpDirectDebitDaoImpl.setUpFixedPaymentDetails(SetUpDirectDebitDaoImpl.java:201)

      com.capitalone.uk.coreapi.directdebit.dao.SetUpDirectDebitDaoImpl$$FastClassBySpringCGLIB$$28fa0f1d.invoke(<generated>)

      org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

      org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

      org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)

      com.capitalone.uk.coreapi.directdebit.aop.LoggerAOP.logAround(LoggerAOP.java:39)

      sun.reflect.GeneratedMethodAccessor500.invoke(Unknown Source)

      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      java.lang.reflect.Method.invoke(Method.java:606)

      org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)

      org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)

      org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

      org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

      org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)

      com.capitalone.uk.coreapi.directdebit.dao.SetUpDirectDebitDaoImpl$$EnhancerBySpringCGLIB$$a7090f23.setUpFixedPaymentDetails(<generated>)

      com.capitalone.uk.coreapi.directdebit.service.SetUpDirectDebitServiceImpl.setUpDirectDebit(SetUpDirectDebitServiceImpl.java:70)

      com.capitalone.uk.coreapi.directdebit.service.SetUpDirectDebitServiceImpl$$FastClassBySpringCGLIB$$e358bd63.invoke(<generated>)

      org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

      org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

      org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)

      com.capitalone.uk.coreapi.directdebit.aop.LoggerAOP.logAround(LoggerAOP.java:39)

      sun.reflect.GeneratedMethodAccessor500.invoke(Unknown Source)

      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      java.lang.reflect.Method.invoke(Method.java:606)

      org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)

      org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)

      org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

      org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

      org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)

      com.capitalone.uk.coreapi.directdebit.service.SetUpDirectDebitServiceImpl$$EnhancerBySpringCGLIB$$dacfaaa9.setUpDirectDebit(<generated>)

      com.capitalone.uk.coreapi.directdebit.endpoint.SetUpDirectDebitEndpoint.setUpDirectDebit(SetUpDirectDebitEndpoint.java:112)

      com.capitalone.uk.coreapi.directdebit.endpoint.SetUpDirectDebitEndpoint$$FastClassBySpringCGLIB$$305b5741.invoke(<generated>)

      org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

      org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

      org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)

      com.capitalone.uk.coreapi.directdebit.aop.LoggerAOP.logAround(LoggerAOP.java:39)

      sun.reflect.GeneratedMethodAccessor500.invoke(Unknown Source)

      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      java.lang.reflect.Method.invoke(Method.java:606)

      org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)

      org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)

      org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

      org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:58)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

      org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)

      org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

      org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)

      com.capitalone.uk.coreapi.directdebit.endpoint.SetUpDirectDebitEndpoint$$EnhancerBySpringCGLIB$$30e236f0.setUpDirectDebit(<generated>)

      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      java.lang.reflect.Method.invoke(Method.java:606)

      org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)

      org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)

      org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)

      org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)

      org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)

      org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)

      org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)

      org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)

      org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:309)

      org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)

      org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)

      org.glassfish.jersey.internal.Errors.process(Errors.java:315)

      org.glassfish.jersey.internal.Errors.process(Errors.java:297)

      org.glassfish.jersey.internal.Errors.process(Errors.java:267)

      org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)

      org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:292)

      org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1139)

      org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:460)

      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)

      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)

      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)

      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)



  • 2.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 13, 2016 03:35 PM

    Let me make sure I understand your scenario.  You're using LISA to make a REST call into your application, and as a result, your application sends an IBM MQ Message to a virtual service being run by LISA?  Is that correct? 

     

    What version of LISA are you using?  Your application is clearly using IBM MQ JMS Mode, how have you configured your VSE transport protocol?  If you're using the old MQ Series transport protocol, then for Client Mode did you select JMS Mode or Native Mode?  If you're using the new IBM MQ Native protocol, then you should actually be using the 'JMS' protocol with IBM MQ connection assets.

     

    How did you create the virtual service, by recording or with RR pairs?  Have you tried testing the VS directly, with a LISA MQ/JMS step, to see how it actually responds?



  • 3.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 15, 2016 04:33 PM

    Hi Kevin, I should have been little clear. We have developed MQ virtual services and this works perfectly when tested from LISA MQ test step. Now the challenge when I test it from API deployed on tomcat configured to talk LISA MQ's, at LISA MQ the call is coming and VSE responds with exact match just that API is not able to handle type of message returned from LISA queue. 



  • 4.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 15, 2016 04:54 PM

    My questions about LISA version and MQ Native Mode versus MQ JMS Mode still stand.  What version of LISA are you on?  When you were using LISA to test the MQ portion, were you using the new IBM MQ Native step, or the old MS step with 'Native Client' mode selected, or were you using the new JMS step with an IBM MQ connectoin factory, or the old MQ step with 'JMS Mode' selected?  Until you test the MQ portion with a *JMS* client then you are not testing it like your application does.



  • 5.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 17, 2016 04:44 AM

    Sorry for delay Kevin. I am using IBM MQ Series and DevTest version is 8.3. I am testing with IBM Websphere MQ step and it works from here however when I test from client side (Lisa REST step or SOAPui) it fails intermittently (which I found yesterday).



  • 6.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 17, 2016 11:27 AM

    You still haven't answered my question about Client Mode.  Did you using 'Native' or 'JMS' when you configured the VSE recorder:

    Screen Shot 2016-05-17 at 10.22.45 AM.png

     

    and your MQ test step:

    Screen Shot 2016-05-17 at 10.22.03 AM.png

     

    Also, are you sure your application is using the exact same IBM MQ jar files that LISA is using?



  • 7.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 17, 2016 11:39 AM

    Its native client



  • 8.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 17, 2016 11:41 AM

    I am pretty sure the jar files are in place..for one of the api's it doesn't work rest all are working fine...now I think it might be code issue...we are still investigating it.



  • 9.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 17, 2016 11:50 AM

    Have you tried JMS mode?  From the error you're getting it's clear that your application is using JMS Mode.  If you're using Native mode from LISA then it is not communicating with MQ the same way that your application is.  Can you at least try JMS mode with your MQ test step and see what kind of result you get?



  • 10.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 17, 2016 11:57 AM

    I am testing it from LISA MQ test step with 'native mode' and it works fine. I am getting your point with the error application is throwing but the application behaves normal sometimes that is it returns response and intermittently it throws cast error message and at virtual service end we receive and send the response as per the match.



  • 11.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted May 17, 2016 12:59 PM

    Can you please try it with your test test using JMS Mode and see what happens?

     

    I would also highly recommend re-recording your service with JMS mode.  You should not be mixing Native and JMS modes, it does not always work.



  • 12.  Re: JMSBytesMessage cannot be cast to javax.jms.TextMessage Error

    Posted Jan 17, 2017 03:20 PM

    Sandeep,

    Did you get a chance to do your test using JMS Mode as Kevin recommended?