[jboss-user] [JBoss Seam] - Re: Seam interceptor ERROR

michaelveit do-not-reply at jboss.com
Thu Mar 1 08:24:14 EST 2007


Hello,

I got the same problem using a user defined interceptor.
Without ICEfaces, it's running fine, but with ICEfaces I get:

2007-03-01 14:02:06,140 ERROR [com.icesoft.faces.facelets.D2DFaceletViewHandler] Problem in renderResponse: /moses/image.xhtml Not Found in ExternalContext as a Resource
  | java.io.FileNotFoundException: /moses/image.xhtml Not Found in ExternalContext as a Resource
  | 	at com.sun.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:114)
  | 	at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:86)
  | 	at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:259)
  | 	at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:149)
  | 	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
  | 	at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.renderCycle(BlockingServlet.java:457)
  | 	at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.receiveUpdates(BlockingServlet.java:444)
  | 	at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.executeRequest(BlockingServlet.java:324)
  | 	at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:186)
  | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | ...
  | 

The configuration in web.xml looks like this:
    <lifecycle>
  |         <!-- Phase listener needed to display images via beans -->
  |         <phase-listener>de.classname.webfrontend.ImagePhaseListener</phase-listener>
  |         <!-- Phase listener needed for all Seam applications -->
  |         <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
  |     </lifecycle>
  | 

The phase listener is reading a thumbnail from the database for web output:
package de.classpath.webfrontend;
  | 
  | import java.io.IOException;
  | 
  | import javax.ejb.Stateless;
  | import javax.faces.context.FacesContext;
  | import javax.faces.event.PhaseEvent;
  | import javax.faces.event.PhaseId;
  | import javax.faces.event.PhaseListener;
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | import javax.servlet.http.HttpServletRequest;
  | import javax.servlet.http.HttpServletResponse;
  | import de.classpath.RefObjectBeanLocal;
  | 
  | @Stateless
  | public class ImagePhaseListener implements PhaseListener {
  | 
  | 	private static final long serialVersionUID = 6849469082858433451L;
  | 	// Praefix used for URL: /moses/image.seam
  | 	public final static String IMAGE_VIEW_ID = "image";
  | 
  | 	// Beans
  | 	RefObjectBeanLocal refObjectBean = null;
  | 
  | 	public void afterPhase(PhaseEvent event) {
  | 		FacesContext context = event.getFacesContext();
  | 		String viewId = context.getViewRoot().getViewId();
  | 		if (viewId.indexOf(IMAGE_VIEW_ID) != -1) {
  | 			handleImageRequest(context);
  | 		}
  | 	}
  | 
  | 	public void beforePhase(PhaseEvent event) {
  | 		//Do nothing here...
  | 	}
  | 
  | 	public PhaseId getPhaseId() {
  | 		return PhaseId.RESTORE_VIEW;
  | 	}
  | 
  | 	private void handleImageRequest(FacesContext context) {
  | 		byte [] imagedata = null;
  | 		Integer refDataId = null;
  | 		Integer thumbnailtypeId = null;
  | 		String param;
  | 
  | 		HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
  | 		HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
  | 
  | 	
  | 			// Read thumbnail from database via bean,
  | 			// because EntityManager is not supported in output beans!!!
  | 			if (refObjectBean == null) {
  | 				try {
  | 				Context namingContext = new InitialContext();
  | 				refObjectBean = (RefObjectBeanLocal) namingContext.lookup("myproject/RefObjectBean/local");
  | 				} catch (NamingException exception) {
  | 					throw new RuntimeException(exception);
  | 				}
  | 			}
  | 			if (refObjectBean == null) throw new RuntimeException("refObjectBean ist null!");
  | 	
  | 			// Parse request parameters
  | 			param = request.getParameter("refDataId");
  | 			if (param != null) {
  | 				refDataId = Integer.parseInt(param);
  | 			}
  | 			param = request.getParameter("thumbnailtypeId");
  | 			if (param != null) {
  | 				thumbnailtypeId = Integer.parseInt(param);
  | 			}
  | 	
  | 			// Get image
  | 			if (refDataId != null)
  | 			{
  | 				if (thumbnailtypeId == null)
  | 				{
  | 					imagedata = refObjectBean.getImagedata(refDataId);
  | 				}
  | 				else
  | 				{
  | 					imagedata = refObjectBean.getThumbnail(refDataId, thumbnailtypeId);
  | 				}
  | 			}
  | 	
  | 
  | 			try {
  | 				response.setContentLength(imagedata.length);
  | 				response.getOutputStream().write(imagedata);
  | 			} catch (IOException exception) {
  | 				throw new RuntimeException(exception);
  | 			}
  | 			context.responseComplete();
  | 	}
  |    
  | }

I can't understand the following things:

1) The image is displayed using the URL image.seam, but the error message shows image.xhtml

2) The page is displayed completely with all thumbnails, but when I try to leave the page via a trivial link, the error occurs. There is no reason why to  call the method again...

Any ideas?

Greetings
  Michael

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

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



More information about the jboss-user mailing list