0 Replies Latest reply on Jun 6, 2007 2:06 AM by kishore kumar

    No bridge set

    kishore kumar Newbie

      i am getting following error and i am unable to get the servletcontext in portlet...can any one solve my problem please...


      
      import java.io.IOException;
      import java.util.HashMap;
      
      import javax.portlet.GenericPortlet;
      import javax.portlet.PortletException;
      import javax.portlet.RenderRequest;
      import javax.portlet.RenderResponse;
      
      import java.io.InputStream;
      import java.io.IOException;
      import java.util.Properties;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      
      
      import org.apache.portals.bridges.common.ServletContextProvider;
      import org.eclipse.birt.report.engine.api.EngineConfig;
      import org.eclipse.birt.report.engine.api.EngineConstants;
      import org.eclipse.birt.report.engine.api.HTMLRenderContext;
      import org.eclipse.birt.report.engine.api.HTMLRenderOption;
      import org.eclipse.birt.report.engine.api.IReportEngine;
      import org.eclipse.birt.report.engine.api.IReportRunnable;
      import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
      
      import javax.servlet.*;
      import javax.servlet.http.HttpServletRequest;
      
      import org.eclipse.birt.core.framework.PlatformServletContext;
      import org.eclipse.birt.core.framework.IPlatformContext;
      import org.eclipse.birt.core.framework.Platform;
      import org.eclipse.birt.core.exception.BirtException;
      import org.eclipse.birt.report.engine.api.IReportEngineFactory;
      import org.jboss.portal.bridge.JBossServletContextProvider;
      
      
      public class BirtPortlet extends GenericPortlet{
      
       /**
       *
       */
       private static final long serialVersionUID = 1L;
      
       /**
       * Constructor of the object.
       */
       private IReportEngine birtReportEngine = null;
       protected static Logger logger = Logger.getLogger( "org.eclipse.birt" );
      
       public BirtPortlet() {
       super();
       System.out.println("i am construtor BirtPortlet()************");
      
       }
      
       /**
       * Destruction of the portlet.
       */
       public void destroy() {
       super.destroy();
       System.out.println("i am destroy method destroyBirtengine************");
       BirtEngine.destroyBirtEngine();
       }
      
       public void doView(javax.portlet.RenderRequest req, javax.portlet.RenderResponse resp)
       throws javax.portlet.PortletException, java.io.IOException {
       resp.setContentType("text/html");
      
       // Name of your report
       System.out.println("i am reading the rpt file ******************");
       String reportName = "ui/jsp/new_report_1.rptdesign";
       //HttpServletRequest hRequest=(HttpServletRequest)req;
      
       //ServletContext sc = ((PortletContextImpl)req.getPortletSession().getPortletContext()).getServletContext();
       System.out.println("i am getting jbossservletcontext");
      
       ServletContext sc= new JBossServletContextProvider().getServletContext(this);
       // JBossServletContextProvider prov = new JBossServletContextProvider();
       //HttpServletRequest hreq = prov.getHttpServletRequest(this, req);
      
      
       System.out.println("after contextprovider****************"+sc);
       //ServletContext sc =x.getServletContext(this);
      
       this.birtReportEngine = BirtEngine.getBirtEngine(sc);
      
       //setup image directory
       HTMLRenderContext renderContext = new HTMLRenderContext();
       renderContext.setBaseImageURL(req.getContextPath()+"/images");
       renderContext.setImageDirectory(sc.getRealPath("/images"));
      
       logger.log( Level.FINE, "image directory " + sc.getRealPath("/images"));
       System.out.println("stdout image directory " + sc.getRealPath("/images"));
      
       HashMap contextMap = new HashMap();
       contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
      
       IReportRunnable design;
       try
       {
       //Open report design
       design = birtReportEngine.openReportDesign( sc.getRealPath("/Reports")+"/"+reportName );
       //create task to run and render report
       IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask( design );
       task.setAppContext( contextMap );
      
       //set output options
       HTMLRenderOption options = new HTMLRenderOption();
       options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
       options.setOutputStream(resp.getPortletOutputStream());
       task.setRenderOption(options);
      
       //run report
       task.run();
       task.close();
       }catch (Exception e){
      
       e.printStackTrace();
       throw new javax.portlet.PortletException( e );
       }
       }
      
      
       /**
       * Initialization of the portlet.
       *
       * @throws PortletException if an error occure
       */
       public void init() throws javax.portlet.PortletException {
       BirtEngine.initBirtConfig();
       }
      
      }
      
      
      
      error is:
      
      
      
      11:22:22,250 ERROR [com_gss_webexpenses_portlet_BirtPortlet] The portlet threw an exception
      java.lang.IllegalStateException: No bridge set
       at org.jboss.portal.bridge.JBossServletContextProvider.getServletContext(JBossServletContextProvider.java:65)
       at com.gss.webexpenses.portlet.BirtPortlet.doView(Unknown Source)
       at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:235)
       at javax.portlet.GenericPortlet.render(GenericPortlet.java:163)
       at org.jboss.portal.portlet.container.PortletContainer.invokeRender(PortletContainer.java:518)
       at org.jboss.portal.portlet.container.PortletContainer.dispatch(PortletContainer.java:434)
       at org.jboss.portal.portlet.container.PortletContainerInvoker$1.dispatch(PortletContainerInvoker.java:144)
       at org.jboss.portal.portlet.invocation.PortletInvocation.dispatch(PortletInvocation.java:223)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:141)
       at org.jboss.portal.core.aspects.portlet.TransactionInterceptor.org$jboss$portal$core$aspects$portlet$Transactio
      nInterceptor$invokeNotSupported$aop(TransactionInterceptor.java:85)
       at org.jboss.portal.core.aspects.portlet.TransactionInterceptor$invokeNotSupported_4827075286966232824.invokeNex
      t(TransactionInterceptor$invokeNotSupported_4827075286966232824.java)
       at org.jboss.aspects.tx.TxPolicy.invokeInNoTx(TxPolicy.java:66)
       at org.jboss.aspects.tx.TxInterceptor$NotSupported.invoke(TxInterceptor.java:101)
       at org.jboss.portal.core.aspects.portlet.TransactionInterceptor$invokeNotSupported_4827075286966232824.invokeNex
      t(TransactionInterceptor$invokeNotSupported_4827075286966232824.java)
       at org.jboss.portal.core.aspects.portlet.TransactionInterceptor.invokeNotSupported(TransactionInterceptor.java)
       at org.jboss.portal.core.aspects.portlet.TransactionInterceptor.invoke(TransactionInterceptor.java:55)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.core.aspects.portlet.HeaderInterceptor.invoke(HeaderInterceptor.java:50)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.portlet.aspects.portlet.ProducerCacheInterceptor.invoke(ProducerCacheInterceptor.java:51)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.portlet.aspects.portlet.ModesInterceptor.invoke(ModesInterceptor.java:60)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.bridge.BridgeInterceptor.invoke(BridgeInterceptor.java:46)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.portlet.aspects.portlet.WindowStatesInterceptor.invoke(WindowStatesInterceptor.java:55)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.portlet.aspects.portlet.PortletSessionSynchronizationInterceptor.invoke(PortletSessionSynchr
      onizationInterceptor.java:77)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor$InvokeNextCommand.execute(ContextDispat
      cherInterceptor.java:141)
       at sun.reflect.GeneratedMethodAccessor292.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.portal.server.servlet.CommandServlet.doGet(CommandServlet.java:99)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
       at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:539)
       at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
       at org.jboss.portal.portlet.impl.spi.AbstractRequestContext.include(AbstractRequestContext.java:194)
       at org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor$1.include(ContextDispatcherInterceptor.
      java:69)
       at org.jboss.portal.server.servlet.CommandServlet.include(CommandServlet.java:79)
       at org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor.invoke(ContextDispatcherInterceptor.jav
      a:75)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.portlet.aspects.portlet.ContextTrackerInterceptor.invoke(ContextTrackerInterceptor.java:49)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.portlet.aspects.portlet.SecureTransportInterceptor.invoke(SecureTransportInterceptor.java:65
      )
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.portlet.aspects.portlet.ValveInterceptor.invoke(ValveInterceptor.java:57)
       at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
       at org.jboss.portal.common.invocation.Invocation.invoke(Invocation.java:171)
       at org.jboss.portal.portlet.container.PortletContainerInvoker.invoke(PortletContainerInvoker.java:115)
       at sun.reflect.GeneratedMethodAccessor291.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:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)