12 Replies Latest reply on Oct 23, 2008 8:43 AM by swathi samala

    how to insert an image using hibernate entity in Seam

    swathi samala Newbie

      Hi all,
      Can anybody please help me, I have written an entity to store images into the database,and written an action class to save the image to the database, and the view I have written in xhtml using richfaces.
      But when am executing am facing the following exception, am not understanding how to solve that .... any help will be appreciated.


      Action Class:


       import java.io.ByteArrayOutputStream;
      import java.io.File;
      import java.io.IOException;
      import java.io.InputStream;
      import java.rmi.server.UID;
      import java.util.ArrayList;
      import java.util.Date;
      import java.util.HashMap;
      import java.util.List;
      import java.util.Map;
      import java.util.Set;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.richfaces.event.UploadEvent;
      import org.richfaces.model.UploadItem;
      
      @Name("fileUploadHome")
      public class FileUploadHome {
           
           
           @In(scope=ScopeType.SESSION,required=false)
           @Out(scope=ScopeType.SESSION, required=false)
           File file;
      
           @In(scope=ScopeType.SESSION,required=false)
           @Out(scope=ScopeType.SESSION, required=false)
           UploadItem upload;
           
           private List data = new ArrayList();
           
           private boolean flag;
           
           private String fileTypes = "*";
           
           private Integer maxFiles = 5;
           
           private String width = "400";
           
           private String height = "210";
           
           public boolean isFlag() {
                return flag;
           }
           
           public List getFileList () {
               return data;
           }
      
      
           public void setFlag(boolean flag) {
                this.flag = flag;
           }
           
           public void listener(UploadEvent event){
               UploadItem item = event.getUploadItem();
               System.out.println("File : '" + item.getFileName() + "' was uploaded");
               if (item.isTempFile()) {
                String file = item.getFileName();
                //System.out.println("Absolute Path : '" + file.getAbsolutePath() + "'!");
                //file.delete();
               }else {
                    try {
                          ByteArrayOutputStream b = new ByteArrayOutputStream();
                          b.write(item.getData());
                          System.out.println(b.toString());
                     } catch (Exception e) {
                          // TODO: handle exception
                     }
                
               }
           }
      
           
           
           public List getData() {
               return data;
           }
      
           
           public void setData(List data) {
               this.data = data;
           }
      
           
           public String getFileTypes() {
               return fileTypes;
           }
      
           
           public void setFileTypes(String fileTypes) {
               this.fileTypes = fileTypes;
           }
      
           
           public Integer getMaxFiles() {
               return maxFiles;
           }
      
           
           public void setMaxFiles(Integer maxFiles) {
               this.maxFiles = maxFiles;
           }
      
           
           public String getWidth() {
               return width;
           }
      
           
           public void setWidth(String width) {
               this.width = width;
           }
      
           
           public String getHeight() {
               return height;
           }
      
           
           public void setHeight(String height) {
               this.height = height;
           }
      
           public File getFile() {
                return file;
           }
      
           public void setFile(File file) {
                this.file = file;
           }
      
           public UploadItem getUpload() {
                return upload;
           }
      
           public void setUpload(UploadItem upload) {
                this.upload = upload;
           }
           
           
      }
      


      xhtml:


       <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich">
      
          <style>
      .top {
          vertical-align: top;
          
      }
      .info {
          height: 202px;
          overflow: auto;
      }
      </style>
       <h:form>
              <s:decorate for="road" template="../layout/edit.xhtml">
                      <h:panelGrid id="uploadGrid" columns="2" cellspacing="2" width="100%" cellpadding="0"
                      columnClasses="#{formLnF.getColumnOneSettings(skinBean.skin)}, #{formLnF.getColumnTwoSettings(skinBean.skin)}">
                  <h:column><a4j:region>
                  <h:panelGrid columns="2" columnClasses="top,top">
                  <rich:fileUpload id="file" fileUploadListener="#{fileUploadHome.listener}"
                  maxFilesQuantity="5" immediateUpload="true" ajaxSingle="true">
                  <a4j:support event="onuploadcomplete" reRender="fileInfoPanel" ajaxSingle="true">
                  <s:conversationPropagation type="join" /></a4j:support>
                  <f:facet name="label">
                      <h:outputText value="{_KB}KB from {KB}KB uploaded, Time Elapsed: {mm}:{ss}" />
                  </f:facet>
                  </rich:fileUpload>
                  <rich:panel id="fileInfoPanel" header="Uploaded Files Info" style="height:242px;width:200px;overflow: auto;" headerClass="headerHeight">
                  <h:outputText value="No files currently uploaded"  rendered="#{empty contexts.sessionContext.get('fileInfoList')}" />
                  <rich:dataList var="fileInfo" value="#{contexts.sessionContext.get('fileInfoList')}" rows="3">
                  <h:outputText value="#{fileInfo.filePath}"></h:outputText><br/>
                  <h:outputText value="Size: " style="font-weight:bold;"></h:outputText>
                  <h:outputText value="#{fileInfo.fileSize}"/>
                 
                  </rich:dataList>
                  </rich:panel>
                  </h:panelGrid>
                        <h:message for="file" style="color:RED;"></h:message>
                            <a4j:commandButton id="actionButton" action="#{fileUploadHome.clearUploadedData}"
                          ajaxSingle="true"
                          reRender="file, fileInfoPanel" value="Clear Uploaded Data"/>
                          </a4j:region>
                    </h:column>   
                 
                 
                  </h:panelGrid>  
                  </s:decorate>
                    </h:form>
      
      
         </ui:composition>
      


      Entity:


       import javax.persistence.Entity;
      import org.jboss.seam.annotations.Name;
      import com.sun.istack.internal.NotNull;
      import javax.persistence.Id;
      
      @Entity(name="fileUpload")
      @Name("fileUpload")
      public class FileUpload{
           
           @Id
           @NotNull
           private String fileName;
           
           @NotNull
           private String image;
      
           public String getFileName() {
                return fileName;
           }
      
           public void setFileName(String fileName) {
                this.fileName = fileName;
           }
      
           public String getImage() {
                return image;
           }
      
           public void setImage(String image) {
                this.image = image;
           }
           
      }



      Exception


      11:06:15,791 ERROR [STDERR] Oct 21, 2008 11:06:15 AM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/fileupload.xhtml]
      com.sun.facelets.tag.TagException: /fileupload.xhtml @26,75 <rich:fileUpload> Tag Library supports namespace: http://richfaces.org/rich, but no tag was defined for name: fileUpload
           at com.sun.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:193)
           at com.sun.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:194)
           at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
           at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
           at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
           at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
           at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
           at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
           at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
           at com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:232)
           at com.sun.facelets.compiler.Compiler.compile(Compiler.java:105)
           at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:197)
           at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:144)
           at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:95)
           at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:517)
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
           at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
           at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           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:179)
           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)
      





        • 2. Re: how to insert an image using hibernate entity in Seam
          swathi samala Newbie

          Yeah Nicklas I think I have included all the library files.... can u tell me if there id any thing wrong in the code......

          • 3. Re: how to insert an image using hibernate entity in Seam
            Nicklas Karlsson Master

            I'm no RF expert so I can't say when the component was added, make sure you have the latest version. 3.2.2 has it. You might want to check that e.g. your faces-config.xml in the RF-ui.jar file knows about the upload component.

            • 4. Re: how to insert an image using hibernate entity in Seam
              swathi samala Newbie

              After adding the jar files of RF3.2.2 vesion am getting the following error.
              Error



               12:13:58,619 WARN  [renderkit] Unable to find component with ID road in view.
              12:13:58,666 ERROR [ExceptionFilter] handling uncaught exception
              javax.servlet.ServletException: Servlet execution threw an exception
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                   at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                   at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                   at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                   at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                   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:179)
                   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)
              Caused by: java.lang.NoSuchMethodError: org.richfaces.renderkit.AbstractProgressBarRenderer.writeScriptBody(Ljava/io/Writer;Ljava/lang/String;)V
                   at org.richfaces.renderkit.AbstractProgressBarRenderer.getMarkup(AbstractProgressBarRenderer.java:138)
                   at org.richfaces.renderkit.AbstractProgressBarRenderer.encodeInitialScript(AbstractProgressBarRenderer.java:253)
                   at org.richfaces.renderkit.AbstractProgressBarRenderer.encodeProgressState(AbstractProgressBarRenderer.java:423)
                   at org.richfaces.renderkit.ProgressBarRenderer.doEncodeEnd(ProgressBarRenderer.java:228)
                   at org.richfaces.renderkit.ProgressBarRenderer.doEncodeEnd(ProgressBarRenderer.java:237)
                   at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:135)
                   at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
                   at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:286)
                   at org.richfaces.renderkit.FileUploadRendererBase.renderProgress(FileUploadRendererBase.java:625)
                   at org.richfaces.renderkit.html.FileUploadRenderer.doEncodeEnd(FileUploadRenderer.java:258)
                   at org.richfaces.renderkit.html.FileUploadRenderer.doEncodeEnd(FileUploadRenderer.java:383)
                   at org.ajax4jsf.renderkit.RendererBase.encodeEnd(RendererBase.java:135)
                   at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
                   at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:279)
                   at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
                   at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
                   at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeChildren(AjaxContainerRenderer.java:97)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at org.ajax4jsf.component.UIAjaxRegion.encodeChildren(UIAjaxRegion.java:113)
                   at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
                   at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:276)
                   at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
                   at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
                   at org.jboss.seam.ui.renderkit.ValidateAllRendererBase.doEncodeChildren(ValidateAllRendererBase.java:33)
                   at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
                   at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
                   at org.jboss.seam.ui.renderkit.DecorateRendererBase.doEncodeChildren(DecorateRendererBase.java:103)
                   at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                   at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                   at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                   at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                   at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
                   at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                   at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                   at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                   ... 36 more
              12:13:58,666 ERROR [ExceptionFilter] exception root cause
              12:13:59,151 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui.jar!/META-INF/a4j.taglib.xml
              12:13:59,166 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui-3.2.2.GA.jar!/META-INF/a4j.taglib.xml
              12:13:59,182 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui.jar!/META-INF/ajax4jsf.taglib.xml
              12:13:59,198 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui-3.2.2.GA.jar!/META-INF/ajax4jsf.taglib.xml
              12:13:59,260 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui.jar!/META-INF/rich.taglib.xml
              12:13:59,276 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui-3.2.2.GA.jar!/META-INF/rich.taglib.xml
              12:13:59,291 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui.jar!/META-INF/richfaces.taglib.xml
              12:13:59,307 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui-3.2.2.GA.jar!/META-INF/richfaces.taglib.xml
              12:13:59,307 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-core.taglib.xml
              12:13:59,307 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-html.taglib.xml
              12:13:59,323 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-ui.taglib.xml
              12:13:59,323 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-core.taglib.xml
              12:13:59,338 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-fn.taglib.xml
              12:13:59,338 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/jboss-seam-mail.jar!/META-INF/seam-mail.taglib.xml
              12:13:59,338 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/jboss-seam-ui.jar!/META-INF/s.taglib.xml
              12:13:59,354 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/richfaces-ui-3.2.2.GA.jar!/META-INF/jsp.taglib.xml
              12:13:59,369 ERROR [STDERR] Oct 21, 2008 12:13:59 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/E:/sample/jboss-4.2.2.GA/server/default/deploy/fileUpload.war/WEB-INF/lib/jboss-seam-pdf.jar!/META-INF/seam-pdf.taglib.xml
              


              xhtml


               <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:s="http://jboss.com/products/seam/taglib"
                  xmlns:h="http://java.sun.com/jsf/html"
                  xmlns:f="http://java.sun.com/jsf/core"
                  xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich">
              
                  <style>
              .top {
                  vertical-align: top;
                  
              }
              .info {
                  height: 202px;
                  overflow: auto;
              }
              </style>
               <h:form>
                      <s:decorate for="road" template="/layout/edit.xhtml">
                              <h:panelGrid id="uploadGrid" columns="2" cellspacing="2" width="100%" cellpadding="0"
                              columnClasses="#{formLnF.getColumnOneSettings(skinBean.skin)}, #{formLnF.getColumnTwoSettings(skinBean.skin)}">
                          <h:column><a4j:region>
                          <h:panelGrid columns="2" columnClasses="top,top">
                          <rich:fileUpload id="file" fileUploadListener="#{fileUploadHome.listener}"
                          maxFilesQuantity="5" immediateUpload="true" ajaxSingle="true">
                          <a4j:support event="onuploadcomplete" reRender="fileInfoPanel" ajaxSingle="true">
                          <s:conversationPropagation type="join" /></a4j:support>
                          <f:facet name="label">
                              <h:outputText value="{_KB}KB from {KB}KB uploaded, Time Elapsed: {mm}:{ss}" />
                          </f:facet>
                          </rich:fileUpload>
                          <rich:panel id="fileInfoPanel" header="Uploaded Files Info" style="height:242px;width:200px;overflow: auto;" headerClass="headerHeight">
                          <h:outputText value="No files currently uploaded"  rendered="#{empty contexts.sessionContext.get('fileInfoList')}" />
                          <rich:dataList var="fileInfo" value="#{contexts.sessionContext.get('fileInfoList')}" rows="3">
                          <h:outputText value="#{fileInfo.filePath}"></h:outputText><br/>
                          <h:outputText value="Size: " style="font-weight:bold;"></h:outputText>
                          <h:outputText value="#{fileInfo.fileSize}"/>
                         
                          </rich:dataList>
                          </rich:panel>
                          </h:panelGrid>
                                <h:message for="file" style="color:RED;"></h:message>
                                    <a4j:commandButton id="actionButton" action="#{fileUploadHome.clearUploadedData}"
                                  ajaxSingle="true"
                                  reRender="file, fileInfoPanel" value="Clear Uploaded Data"/>
                                  </a4j:region>
                            </h:column>   
                         
                         
                          </h:panelGrid>  
                          </s:decorate>
                            </h:form>
              
              
                 </ui:composition>
              


              • 5. Re: how to insert an image using hibernate entity in Seam
                Nicklas Karlsson Master

                NoSuchMethodError usually indicates some sort of API-implementation mismatch. You might want to take this to the RichFaces forums and give them info on your deployment (EAR/WAR) etc. And make sure you don't have old stuff lying around somewhere.

                • 6. Re: how to insert an image using hibernate entity in Seam
                  swathi samala Newbie

                  Thank you Nicklas... I got it but I want to upload only images.... not any other files..... do u know how to do it

                  • 7. Re: how to insert an image using hibernate entity in Seam
                    swathi samala Newbie

                    hey its not getting stored in database.... the view is  working but its not saving.... help me

                    • 9. Re: how to insert an image using hibernate entity in Seam
                      swathi samala Newbie
                      Thank You charles..... It really worked.... Thank you so much... I have one more problem hope you can help me out...
                      Actually it uploads all types of files... but I want only images like png,gif,bmp,jpg to be uploaded... I have tried it by making small changes in xhtml code like (accept="jpg,png,bmp,gif")

                      xhtml:
                      ------

                      <s:fileUpload id="file"
                                                          data="#{attachmentHome.instance.data}" accept="jpg,png,bmp,gif"
                                                          contentType="#{attachmentHome.instance.contentType}"
                                                          fileName="#{attachmentHome.instance.name}"
                                                          fileSize="#{attachmentHome.instance.size}"/>
                      • 10. Re: how to insert an image using hibernate entity in Seam
                        Nicklas Karlsson Master

                        Never tried but looking at the manual, the form is mages/png,images/jpg which looks like MIME types

                        • 11. Re: how to insert an image using hibernate entity in Seam
                          swathi samala Newbie

                          Yeah I have tried it also


                          <s:fileUpload id="file" 
                                                              data="#{attachmentHome.instance.data}" accept="image/jpg,image/png,image/bmp,image/gif"
                                                              contentType="#{attachmentHome.instance.contentType}"
                                                              fileName="#{attachmentHome.instance.name}"
                                                              fileSize="#{attachmentHome.instance.size}" />



                          its not working...... can u help me

                          • 12. Re: how to insert an image using hibernate entity in Seam
                            swathi samala Newbie

                            I have written persist method in action class (i.e in attachmentHome.java) so now I can restrict others file from uploading...


                            attachmentHome.java


                             @Override
                                public String persist(){
                                     if(!(attachmentcontentType == "jpg,png,gif,bmp") && 
                                               attachmentcontentType != null){
                                          
                                          facesMessages.add("Content type is not Image");
                                     }
                                      return "/attachment.xhtml";
                                     
                                }