[jboss-user] [JBoss Portal Users] - Re: ava.lang.ClassCastException: org.jboss.portal.portlet.im

guenther.herndl@softcon.de do-not-reply at jboss.com
Thu Sep 10 06:07:22 EDT 2009


If I use our default SEAM Solution:
/**
 * 
 */
package de.softcon.ivory.invserver.action.report;



import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.Map;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponseWrapper;

import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Import;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.core.Manager;
import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
import org.jboss.seam.document.DocumentStore;
import org.jboss.seam.log.Log;





/**
 * @author mbaumgar
 *
 */
@Name("downloadComponent")
@Import("org.jboss.seam.pdf")
public class DownloadComponent
{

	
    @In(value = "#{facesContext.externalContext}")
    private ExternalContext externalContext;
    @Logger
    private Log log;

    public void download(String filename, File reportFile)
    {
        int read = 0;
        byte[] bytes = new byte[1000];

        ActionResponseImpl res = (ActionResponseImpl)FacesContext.getCurrentInstance().getExternalContext().getResponse();
           
         
        HttpServletResponseWrapper response = res.getRealResponse();
        response.setContentType("application/xls");
        response.setContentLength((int) reportFile.length());
        response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\";");
        log.info("Content-Disposition attachment; filename=\"" + filename + "\";");
        log.error("Content-Disposition attachment; filename=\"" + filename + "\";");
        try
        {
            ServletOutputStream os = response.getOutputStream();

            FileInputStream fis = new FileInputStream(reportFile);

            while ((read = fis.read(bytes)) != -1)
            {
                os.write(bytes, 0, read);
            }
            fis.close();

            os.flush();
            os.close();

            FacesContext.getCurrentInstance().responseComplete();
        }
        catch (Exception e)
        {
            if (log.isErrorEnabled())
            {
                log.error(DownloadComponent.class, e);
            }
        }
    }
}

I get the follwing exception with wrong file-names and lost extension (.pdf or .xls):

2009-09-10 11:51:08,161 DEBUG [org.jboss.seam.Component] trying to inject with EL expression: #{facesContext.externalContext}
2009-09-10 11:51:08,161 INFO  [de.softcon.ivory.invserver.action.report.DownloadComponent] Content-Disposition attachment; filename="listOfAsset.pdf";
2009-09-10 11:51:08,161 ERROR [de.softcon.ivory.invserver.action.report.DownloadComponent] Content-Disposition attachment; filename="listOfAsset.pdf";
2009-09-10 11:51:08,161 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecycle] Exiting InvokeApplicationsPhase
2009-09-10 11:51:08,161 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase INVOKE_APPLICATION 5
2009-09-10 11:51:08,161 DEBUG [org.jboss.seam.jsf.SeamPhaseListener] committing transaction after phase: INVOKE_APPLICATION 5
2009-09-10 11:51:08,161 DEBUG [org.jboss.seam.transaction.UTTransaction] committing JTA transaction
2009-09-10 11:51:08,161 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction before completion callback
2009-09-10 11:51:08,161 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
2009-09-10 11:51:08,161 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
2009-09-10 11:51:08,161 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] automatically flushing session
2009-09-10 11:51:08,161 DEBUG [org.hibernate.impl.SessionImpl] automatically flushing session
2009-09-10 11:51:08,161 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] flushing session
2009-09-10 11:51:08,161 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades
2009-09-10 11:51:08,161 DEBUG [org.hibernate.engine.Cascade] processing cascade ACTION_PERSIST_ON_FLUSH for: de.softcon.ivory.invserver.model.tenant.Tenant
2009-09-10 11:51:08,161 DEBUG [org.hibernate.engine.Cascade] done processing cascade ACTION_PERSIST_ON_FLUSH for: de.softcon.ivory.invserver.model.tenant.Tenant
..........
Lines Deleted
..........
2009-09-10 11:51:08,161 DEBUG [org.jboss.seam.contexts.FacesLifecycle] <<< End JSF request for /invserverproject/faces
2009-09-10 11:51:08,161 DEBUG [javax.enterprise.resource.webcontainer.jsf.timing]  [TIMING] - [516ms] : Execution time for phase (including any PhaseListeners) -> INVOKE_APPLICATION 5
2009-09-10 11:51:08,161 DEBUG [org.jboss.portal.core.identity.cache.IdentityCacheService] Identity cache invalidated
2009-09-10 11:51:08,161 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction after completion callback, status: 4
2009-09-10 11:51:08,161 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
2009-09-10 11:51:08,161 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
2009-09-10 11:51:08,161 DEBUG [org.hibernate.transaction.CacheSynchronization] automatically closing session
2009-09-10 11:51:08,161 DEBUG [org.hibernate.impl.SessionImpl] automatically closing session
2009-09-10 11:51:08,161 DEBUG [org.hibernate.impl.SessionImpl] closing session
2009-09-10 11:51:08,161 DEBUG [org.hibernate.jdbc.ConnectionManager] connection already null in cleanup : no action
2009-09-10 11:51:08,177 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction after completion callback, status: 4
2009-09-10 11:51:08,177 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
2009-09-10 11:51:08,177 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
2009-09-10 11:51:08,177 DEBUG [org.hibernate.transaction.CacheSynchronization] automatically closing session
2009-09-10 11:51:08,177 DEBUG [org.hibernate.impl.SessionImpl] automatically closing session
2009-09-10 11:51:08,177 DEBUG [org.hibernate.impl.SessionImpl] closing session
2009-09-10 11:51:08,177 DEBUG [org.hibernate.jdbc.ConnectionManager] connection already null in cleanup : no action
2009-09-10 11:51:08,177 ERROR [org.jboss.portal.server.servlet.PortalServlet] Unexpected exception
java.lang.IllegalStateException
	at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:435)
	at org.jboss.portal.core.controller.handler.HTTPResponse$1.sendResponse(HTTPResponse.java:56)
	at org.jboss.portal.core.controller.Controller.sendResponse(Controller.java:363)
	at org.jboss.portal.core.controller.Controller.processHandlerResponse(Controller.java:349)
	at org.jboss.portal.core.controller.Controller.processCommandResponse(Controller.java:329)
	at org.jboss.portal.core.controller.Controller.processCommand(Controller.java:303)
	at org.jboss.portal.core.controller.Controller.handle(Controller.java:261)
	at org.jboss.portal.server.RequestControllerDispatcher.invoke(RequestControllerDispatcher.java:51)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
	at org.jboss.portal.core.cms.aspect.IdentityBindingInterceptor.invoke(IdentityBindingInterceptor.java:47)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.server.aspects.server.ContentTypeInterceptor.invoke(ContentTypeInterceptor.java:68)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.PortalContextPathInterceptor.invoke(PortalContextPathInterceptor.java:45)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.LocaleInterceptor.invoke(LocaleInterceptor.java:96)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.UserInterceptor.invoke(UserInterceptor.java:196)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.server.aspects.server.SignOutInterceptor.invoke(SignOutInterceptor.java:98)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.impl.api.user.UserEventBridgeTriggerInterceptor.invoke(UserEventBridgeTriggerInterceptor.java:65)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.IdentityCacheInterceptor.invoke(IdentityCacheInterceptor.java:68)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor.org$jboss$portal$core$aspects$server$TransactionInterceptor$invoke$aop(TransactionInterceptor.java:49)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
	at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:253)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
	at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:262)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor.invoke(TransactionInterceptor.java)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.server.aspects.LockInterceptor$InternalLock.invoke(LockInterceptor.java:69)
	at org.jboss.portal.server.aspects.LockInterceptor.invoke(LockInterceptor.java:130)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.common.invocation.Invocation.invoke(Invocation.java:157)
	at org.jboss.portal.server.servlet.PortalServlet.service(PortalServlet.java:252)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
	at java.lang.Thread.run(Thread.java:619)
2009-09-10 11:51:08,177 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/portal].[PortalServletWithPathMapping]] Servlet.service() for servlet PortalServletWithPathMapping threw exception
java.lang.IllegalStateException
	at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:435)
	at org.jboss.portal.core.controller.handler.HTTPResponse$1.sendResponse(HTTPResponse.java:56)
	at org.jboss.portal.core.controller.Controller.sendResponse(Controller.java:363)
	at org.jboss.portal.core.controller.Controller.processHandlerResponse(Controller.java:349)
	at org.jboss.portal.core.controller.Controller.processCommandResponse(Controller.java:329)
	at org.jboss.portal.core.controller.Controller.processCommand(Controller.java:303)
	at org.jboss.portal.core.controller.Controller.handle(Controller.java:261)
	at org.jboss.portal.server.RequestControllerDispatcher.invoke(RequestControllerDispatcher.java:51)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
	at org.jboss.portal.core.cms.aspect.IdentityBindingInterceptor.invoke(IdentityBindingInterceptor.java:47)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.server.aspects.server.ContentTypeInterceptor.invoke(ContentTypeInterceptor.java:68)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.PortalContextPathInterceptor.invoke(PortalContextPathInterceptor.java:45)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.LocaleInterceptor.invoke(LocaleInterceptor.java:96)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.UserInterceptor.invoke(UserInterceptor.java:196)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.server.aspects.server.SignOutInterceptor.invoke(SignOutInterceptor.java:98)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.impl.api.user.UserEventBridgeTriggerInterceptor.invoke(UserEventBridgeTriggerInterceptor.java:65)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.IdentityCacheInterceptor.invoke(IdentityCacheInterceptor.java:68)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor.org$jboss$portal$core$aspects$server$TransactionInterceptor$invoke$aop(TransactionInterceptor.java:49)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
	at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:253)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
	at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:262)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
	at org.jboss.portal.core.aspects.server.TransactionInterceptor.invoke(TransactionInterceptor.java)
	at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:38)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.server.aspects.LockInterceptor$InternalLock.invoke(LockInterceptor.java:69)
	at org.jboss.portal.server.aspects.LockInterceptor.invoke(LockInterceptor.java:130)
	at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
	at org.jboss.portal.common.invocation.Invocation.invoke(Invocation.java:157)
	at org.jboss.portal.server.servlet.PortalServlet.service(PortalServlet.java:252)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
	at java.lang.Thread.run(Thread.java:619)
2009-09-10 11:51:09,614 DEBUG [org.jbpm.job.executor.JobExecutorThread] acquiring jobs for execution...



View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4254367#4254367

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4254367



More information about the jboss-user mailing list