9 Replies Latest reply on Mar 22, 2006 6:59 PM by Andrew Oliver

    Problems when process mail

    Eric VIDAL Newbie

      Hi,

      I have developped a Mail Listener that process the MailBody.
      When i try to read the content of the mail body doing that

      MailBody body = smtpMessage.getMailBody();
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      body.write(out);
      byte[] buffer = out.toByteArray();
      String message = new String(buffer) ;


      or that

      MailBody body = smtpMessage.getMailBody();
      int sizeInBytes = body.getSize();
      InputStream is = body.getInputStream();
      byte buffer[] = new byte[sizeInBytes];
      int offset = 0;
      for(int numRead = 0;offset < buffer.length && (numRead = is.read(buffer, offset, buffer.length - offset)) >= 0;offset += numRead);
      String message = new String(buffer) ;



      I've got a strange Exception :
      java.util.zip.ZipException: unknown compression method

      This is the complete stack for the fisrt code part :

      17:16:45,026 ERROR [JMSContainerInvoker] Exception in JMSCI message listener
      javax.ejb.TransactionRolledbackLocalException
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:247)
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
       at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
       at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:94)
       at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
       at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
       at org.jboss.ejb.Container.invoke(Container.java:873)
       at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:1077)
       at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1379)
       at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
       at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:904)
       at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:160)
       at org.jboss.mq.SpySession.run(SpySession.java:333)
       at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.management.RuntimeMBeanException
       at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:162)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:149)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
       at $Proxy97.processMail(Unknown Source)
       at org.jboss.mail.delivery.DeliveryMDB.onMessage(DeliveryMDB.java:72)
       at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
       at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:475)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
       at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:101)
       at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
       ... 16 more
      Caused by: javax.management.RuntimeMBeanException
       at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:162)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:149)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
       at $Proxy59.send(Unknown Source)
       at org.jboss.mail.MailListenerChainService.processMail(MailListenerChainService.java:166)
       at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       ... 35 more
      Caused by: org.jboss.mail.MailException: java.util.zip.ZipException: unknown compression method
       at org.jboss.mail.message.StoredMailBody.write(StoredMailBody.java:161)
       at org.jboss.mail.message.StoredMailBody.write(StoredMailBody.java:146)
       at com.prosodie.ucpsmtpconnector.maillisteners.Smtp2UcpMailListener.send(Smtp2UcpMailListener.java:73)
       at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       ... 46 more
      Caused by: java.util.zip.ZipException: unknown compression method
       at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:140)
       at java.io.FilterInputStream.read(FilterInputStream.java:90)
       at org.jboss.mail.util.io.SimpleCopier.copy(SimpleCopier.java:37)
       at org.jboss.mail.message.StoredMailBody.write(StoredMailBody.java:157)
       ... 52 more


      Is something i doing wrong when i process the mail ?
      Please help...