1 Reply Latest reply on Feb 18, 2011 5:25 PM by njanken

    fileupload + WebLogic Portal

    njanken

      We are using richfaces with WebLogic Portal, and have been mostly successful. However, we are trying to use the richfaces fileupload component and are getting an error.

      The relevant part of the stacktrace is:

      Caused by: java.lang.IllegalAccessException: Class org.richfaces.renderkit.FileUploadRendererBase can not access a member of class com.bea.portlet.container.PortletSessionImpl with modifiers "public"
       at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
       at java.lang.reflect.Method.invoke(Method.java:588)
       at org.richfaces.renderkit.FileUploadRendererBase.getSessionId(FileUploadRendererBase.java:731)
       at org.richfaces.renderkit.html.FileUploadRenderer.doEncodeEnd(FileUploadRenderer.java:379)
       at org.richfaces.renderkit.html.FileUploadRenderer.doEncodeEnd(FileUploadRenderer.java:391)
       at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:134)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:829)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:894)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:890)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)


      I've looked at the RichFaces code where this exception is being thrown and it looks approximatly like the following:
      Object session = context.getExternalContext().getSession(false);
      Class sessionClass = session.getClass();
      Method getIdMethod = sesssionClass.getMethod("getId", new Class[0]);


      The type of the class being retrieved from "context.getExternalContext().getSession(false)" is "com.bea.portlet.container.PortletSessionImpl" which does not have a default constructor. Therefore, I believe when "new Class[0]" is called, the object cannot be constructed and the "getId" cannot be retrieved, thus resulting in the exception

      Is there a way around this?



        • 1. Re: fileupload + WebLogic Portal
          njanken

          Fixed this a long time ago by creating my own FileUploadRendererBase class with the following method

           

          public String getSessionId(FacesContext context, UIComponent component) {

            String id = null;

            Object session = context.getExternalContext().getSession(false);

            if (session != null) {

             if (session instanceof HttpSession) {

              id = ((HttpSession) session).getId();

             } else if(session instanceof PortletSession) {

              id =((PortletSession) session).getId();

             } else {

              Class<? extends Object> sesssionClass = session.getClass();

              try {

               Method getIdMethod = sesssionClass.getMethod("getId");

               id = (String) getIdMethod.invoke(session);

              } catch (SecurityException e) {

               throw new FacesException(e.getMessage(), e);

              } catch (NoSuchMethodException e) {

               throw new FacesException(e.getMessage(), e);

              } catch (IllegalArgumentException e) {

               throw new FacesException(e.getMessage(), e);

              } catch (IllegalAccessException e) {

               throw new FacesException(e.getMessage(), e);

              } catch (InvocationTargetException e) {

               Throwable cause = e.getCause();

               throw new FacesException(cause.getMessage(), cause);

              }

             }

            }

           

            return id;

          }


          Then inserted the class into the RichFaces JAR file.